blob: bc6cb0a848ea178ce1ef2560559730e0ae56e94d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limProcessMlmMessages.cc contains the code
30 * for processing MLM request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/12/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38#include "palTypes.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053039#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070040#include "aniGlobal.h"
41#include "sirApi.h"
42#include "sirParams.h"
43#include "cfgApi.h"
44
45#include "schApi.h"
46#include "utilsApi.h"
47#include "limUtils.h"
48#include "limAssocUtils.h"
49#include "limPropExtsUtils.h"
50#include "limSecurityUtils.h"
51#include "limSendMessages.h"
52#include "pmmApi.h"
53#include "limSendMessages.h"
54//#include "limSessionUtils.h"
55#include "limSessionUtils.h"
56#ifdef WLAN_FEATURE_VOWIFI_11R
57#include <limFT.h>
58#endif
krunal soni8d13b092013-07-19 13:23:29 -070059#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
60#include "vos_diag_core_log.h"
61#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053062#ifdef WLAN_FEATURE_LFR_MBB
63#include "lim_mbb.h"
64#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070065
66
67// MLM REQ processing function templates
68static void limProcessMlmStartReq(tpAniSirGlobal, tANI_U32 *);
69static void limProcessMlmScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnsone7245742012-09-05 17:12:55 -070070#ifdef FEATURE_OEM_DATA_SUPPORT
71static void limProcessMlmOemDataReq(tpAniSirGlobal, tANI_U32 *);
72#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070073static void limProcessMlmJoinReq(tpAniSirGlobal, tANI_U32 *);
74static void limProcessMlmAuthReq(tpAniSirGlobal, tANI_U32 *);
75static void limProcessMlmAssocReq(tpAniSirGlobal, tANI_U32 *);
76static void limProcessMlmReassocReq(tpAniSirGlobal, tANI_U32 *);
77static void limProcessMlmDisassocReq(tpAniSirGlobal, tANI_U32 *);
78static void limProcessMlmDeauthReq(tpAniSirGlobal, tANI_U32 *);
79static void limProcessMlmSetKeysReq(tpAniSirGlobal, tANI_U32 *);
80
81static void limProcessMlmAddBAReq( tpAniSirGlobal, tANI_U32 * );
82static void limProcessMlmAddBARsp( tpAniSirGlobal, tANI_U32 * );
83static void limProcessMlmDelBAReq( tpAniSirGlobal, tANI_U32 * );
84
85// MLM Timeout event handler templates
86static void limProcessMinChannelTimeout(tpAniSirGlobal);
87static void limProcessMaxChannelTimeout(tpAniSirGlobal);
88static void limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac);
89static void limProcessJoinFailureTimeout(tpAniSirGlobal);
90static void limProcessAuthFailureTimeout(tpAniSirGlobal);
91static void limProcessAuthRspTimeout(tpAniSirGlobal, tANI_U32);
92static void limProcessAssocFailureTimeout(tpAniSirGlobal, tANI_U32);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -080093static void limProcessPeriodicJoinProbeReqTimer(tpAniSirGlobal);
Sushant Kaushik9e923872015-04-02 17:09:31 +053094static void limProcessAuthRetryTimer(tpAniSirGlobal);
95
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97static void limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 * pMsgBuf);
98void
Jeff Johnsone7245742012-09-05 17:12:55 -070099limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700100#define IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) (pMac->lim.gpLimMlmScanReq->backgroundScanMode == eSIR_AGGRESSIVE_BACKGROUND_SCAN)
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700101#define IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac) (pMac->lim.gpLimMlmScanReq->backgroundScanMode == eSIR_NORMAL_BACKGROUND_SCAN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103/**
104 * limProcessMlmReqMessages()
105 *
106 *FUNCTION:
107 * This function is called by limPostMlmMessage(). This
108 * function handles MLM primitives invoked by SME.
109 *
110 *LOGIC:
111 * Depending on the message type, corresponding function will be
112 * called.
113 *
114 *ASSUMPTIONS:
115 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
116 * APIs exposed by Beacon Processing module for setting parameters
117 * at MAC hardware.
118 * 2. If attempt to Reassociate with an AP fails, link with current
119 * AP is restored back.
120 *
121 *NOTE:
122 *
123 * @param pMac Pointer to Global MAC structure
124 * @param msgType Indicates the MLM primitive message type
125 * @param *pMsgBuf A pointer to the MLM message buffer
126 *
127 * @return None
128 */
129
130void
131limProcessMlmReqMessages(tpAniSirGlobal pMac, tpSirMsgQ Msg)
132{
133 switch (Msg->type)
134 {
135 case LIM_MLM_START_REQ: limProcessMlmStartReq(pMac, Msg->bodyptr); break;
136 case LIM_MLM_SCAN_REQ: limProcessMlmScanReq(pMac, Msg->bodyptr); break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700137#ifdef FEATURE_OEM_DATA_SUPPORT
138 case LIM_MLM_OEM_DATA_REQ: limProcessMlmOemDataReq(pMac, Msg->bodyptr); break;
139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 case LIM_MLM_JOIN_REQ: limProcessMlmJoinReq(pMac, Msg->bodyptr); break;
141 case LIM_MLM_AUTH_REQ: limProcessMlmAuthReq(pMac, Msg->bodyptr); break;
142 case LIM_MLM_ASSOC_REQ: limProcessMlmAssocReq(pMac, Msg->bodyptr); break;
143 case LIM_MLM_REASSOC_REQ: limProcessMlmReassocReq(pMac, Msg->bodyptr); break;
144 case LIM_MLM_DISASSOC_REQ: limProcessMlmDisassocReq(pMac, Msg->bodyptr); break;
145 case LIM_MLM_DEAUTH_REQ: limProcessMlmDeauthReq(pMac, Msg->bodyptr); break;
146 case LIM_MLM_SETKEYS_REQ: limProcessMlmSetKeysReq(pMac, Msg->bodyptr); break;
147 case LIM_MLM_REMOVEKEY_REQ: limProcessMlmRemoveKeyReq(pMac, Msg->bodyptr); break;
148 case SIR_LIM_MIN_CHANNEL_TIMEOUT: limProcessMinChannelTimeout(pMac); break;
149 case SIR_LIM_MAX_CHANNEL_TIMEOUT: limProcessMaxChannelTimeout(pMac); break;
150 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
151 limProcessPeriodicProbeReqTimer(pMac); break;
152 case SIR_LIM_JOIN_FAIL_TIMEOUT: limProcessJoinFailureTimeout(pMac); break;
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800153 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
154 limProcessPeriodicJoinProbeReqTimer(pMac); break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 case SIR_LIM_AUTH_FAIL_TIMEOUT: limProcessAuthFailureTimeout(pMac); break;
156 case SIR_LIM_AUTH_RSP_TIMEOUT: limProcessAuthRspTimeout(pMac, Msg->bodyval); break;
157 case SIR_LIM_ASSOC_FAIL_TIMEOUT: limProcessAssocFailureTimeout(pMac, Msg->bodyval); break;
158#ifdef WLAN_FEATURE_VOWIFI_11R
159 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:limProcessFTPreauthRspTimeout(pMac); break;
160#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530161#ifdef WLAN_FEATURE_LFR_MBB
162 case SIR_LIM_PREAUTH_MBB_RSP_TIMEOUT:
163 lim_process_preauth_mbb_rsp_timeout(pMac);
164 break;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530165 case SIR_LIM_REASSOC_MBB_RSP_TIMEOUT:
166 lim_process_reassoc_mbb_rsp_timeout(pMac);
167 break;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case SIR_LIM_REMAIN_CHN_TIMEOUT: limProcessRemainOnChnTimeout(pMac); break;
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800170 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
171 limProcessInsertSingleShotNOATimeout(pMac); break;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530172 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
173 limConvertActiveChannelToPassiveChannel(pMac); break;
Sushant Kaushik9e923872015-04-02 17:09:31 +0530174 case SIR_LIM_AUTH_RETRY_TIMEOUT:
175 limProcessAuthRetryTimer(pMac);
176 break;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800177 case SIR_LIM_DISASSOC_ACK_TIMEOUT: limProcessDisassocAckTimeout(pMac); break;
178 case SIR_LIM_DEAUTH_ACK_TIMEOUT: limProcessDeauthAckTimeout(pMac); break;
Abhishek Singh550aa8c2017-10-30 17:34:53 +0530179 case SIR_LIM_SAP_ECSA_TIMEOUT: lim_process_ap_ecsa_timeout(pMac);break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case LIM_MLM_ADDBA_REQ: limProcessMlmAddBAReq( pMac, Msg->bodyptr ); break;
181 case LIM_MLM_ADDBA_RSP: limProcessMlmAddBARsp( pMac, Msg->bodyptr ); break;
182 case LIM_MLM_DELBA_REQ: limProcessMlmDelBAReq( pMac, Msg->bodyptr ); break;
183 case LIM_MLM_TSPEC_REQ:
184 default:
185 break;
186 } // switch (msgType)
187} /*** end limProcessMlmReqMessages() ***/
188
189
190/**
191 * limSetScanMode()
192 *
193 *FUNCTION:
194 * This function is called to setup system into Scan mode
195 *
196 *LOGIC:
197 * NA
198 *
199 *ASSUMPTIONS:
200 * NA
201 *
202 *NOTE:
203 *
204 * @param pMac - Pointer to Global MAC structure
205 * @return None
206 */
207
208void
209limSetScanMode(tpAniSirGlobal pMac)
210{
211 tSirLinkTrafficCheck checkTraffic;
212
213 /// Set current scan channel id to the first in the channel list
214 pMac->lim.gLimCurrentScanChannelId = 0;
215
Jeff Johnson62c27982013-02-27 17:53:55 -0800216 if ( IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) )
217 {
218 checkTraffic = eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
219 }
220 else if (IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac))
221 {
222 checkTraffic = eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
223 }
224 else
225 checkTraffic = eSIR_CHECK_ROAMING_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530227 limLog(pMac, LOG1, FL("Calling limSendHalInitScanReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_SCAN_WAIT_STATE, checkTraffic);
229
230 return ;
231} /*** end limSetScanMode() ***/
232
233//WLAN_SUSPEND_LINK Related
234
235/* limIsLinkSuspended()
236 *
237 *FUNCTION:
238 * This function returns is link is suspended or not.
239 *
240 *LOGIC:
Jeff Johnson62c27982013-02-27 17:53:55 -0800241 * Since Suspend link uses init scan, it just returns
242 * gLimSystemInScanLearnMode flag.
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 *
244 *ASSUMPTIONS:
245 * NA
246 *
247 *NOTE:
248 *
249 * @param pMac - Pointer to Global MAC structure
250 * @return None
251 */
252tANI_U8
253limIsLinkSuspended(tpAniSirGlobal pMac)
254{
255 return pMac->lim.gLimSystemInScanLearnMode;
256}
257/**
258 * limSuspendLink()
259 *
260 *FUNCTION:
261 * This function is called to suspend traffic. Internally this function uses WDA_INIT_SCAN_REQ.
262 *
263 *LOGIC:
264 * NA
265 *
266 *ASSUMPTIONS:
267 * NA
268 *
269 *NOTE:
270 *
271 * @param pMac - Pointer to Global MAC structure
Jeff Johnson62c27982013-02-27 17:53:55 -0800272 * @param trafficCheck - Takes value from enum tSirLinkTrafficCheck.
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 * @param callback - Callback function to be called after suspending the link.
274 * @param data - Pointer to any buffer that will be passed to callback.
275 * @return None
276 */
277void
278limSuspendLink(tpAniSirGlobal pMac, tSirLinkTrafficCheck trafficCheck, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
279{
280 if( NULL == callback )
281 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700282 limLog( pMac, LOGE, "%s:%d: Invalid parameters", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 return;
284 }
285
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530286 if( pMac->lim.gpLimSuspendCallback ||
287 pMac->lim.gLimSystemInScanLearnMode )
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 {
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700289 limLog( pMac, LOGE, FL("Something is wrong, SuspendLinkCbk:%pK "
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530290 "IsSystemInScanLearnMode:%d"), pMac->lim.gpLimSuspendCallback,
291 pMac->lim.gLimSystemInScanLearnMode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 callback( pMac, eHAL_STATUS_FAILURE, data );
293 return;
294 }
295
296 pMac->lim.gLimSystemInScanLearnMode = 1;
297 pMac->lim.gpLimSuspendCallback = callback;
298 pMac->lim.gpLimSuspendData = data;
299 limSendHalInitScanReq(pMac, eLIM_HAL_SUSPEND_LINK_WAIT_STATE, trafficCheck );
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800300
301 WDA_TrafficStatsTimerActivate(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302}
303
304/**
305 * limResumeLink()
306 *
307 *FUNCTION:
308 * This function is called to Resume traffic after a suspend. Internally this function uses WDA_FINISH_SCAN_REQ.
309 *
310 *LOGIC:
311 * NA
312 *
313 *ASSUMPTIONS:
314 * NA
315 *
316 *NOTE:
317 *
318 * @param pMac - Pointer to Global MAC structure
319 * @param callback - Callback function to be called after Resuming the link.
320 * @param data - Pointer to any buffer that will be passed to callback.
321 * @return None
322 */
323void
324limResumeLink(tpAniSirGlobal pMac, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
325{
326 if( NULL == callback )
327 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700328 limLog( pMac, LOGE, "%s:%d: Invalid parameters", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return;
330 }
331
332 if( pMac->lim.gpLimResumeCallback )
333 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700334 limLog( pMac, LOGE, "%s:%d: gLimResumeLink callback is not NULL...something is wrong", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 callback( pMac, eHAL_STATUS_FAILURE, data );
336 return;
337 }
338
339 pMac->lim.gpLimResumeCallback = callback;
340 pMac->lim.gpLimResumeData = data;
Abhishek Singh53bfb332013-12-12 18:03:29 +0530341
342 /* eLIM_HAL_IDLE_SCAN_STATE state indicate limSendHalInitScanReq failed.
343 * In case limSendHalInitScanReq is success, Scanstate would be
344 * eLIM_HAL_SUSPEND_LINK_STATE
345 */
346 if( eLIM_HAL_IDLE_SCAN_STATE != pMac->lim.gLimHalScanState )
347 {
348 limSendHalFinishScanReq(pMac, eLIM_HAL_RESUME_LINK_WAIT_STATE );
349 }
350 else
351 {
352 limLog(pMac, LOGW, FL("Init Scan failed, we will not call finish scan."
353 " calling the callback with failure status"));
354 pMac->lim.gpLimResumeCallback( pMac, eSIR_FAILURE, pMac->lim.gpLimResumeData);
355 pMac->lim.gpLimResumeCallback = NULL;
356 pMac->lim.gpLimResumeData = NULL;
357 pMac->lim.gLimSystemInScanLearnMode = 0;
358 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800359
360 if(limIsInMCC(pMac))
361 {
362 WDA_TrafficStatsTimerActivate(TRUE);
363 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700364}
365//end WLAN_SUSPEND_LINK Related
366
367
368/**
369 *
370 * limChangeChannelWithCallback()
371 *
372 * FUNCTION:
373 * This function is called to change channel and perform off channel operation
374 * if required. The caller registers a callback to be called at the end of the
Jeff Johnson62c27982013-02-27 17:53:55 -0800375 * channel change.
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 *
377 */
378void
379limChangeChannelWithCallback(tpAniSirGlobal pMac, tANI_U8 newChannel,
380 CHANGE_CHANNEL_CALLBACK callback,
381 tANI_U32 *cbdata, tpPESession psessionEntry)
382{
383 // Sanity checks for the current and new channel
384#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700385 PELOGE(limLog( pMac, LOGE, "Switching channel to %d", newChannel);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700386#endif
387 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
388
389 pMac->lim.gpchangeChannelCallback = callback;
390 pMac->lim.gpchangeChannelData = cbdata;
391
392 limSendSwitchChnlParams(pMac, newChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -0700393 PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 psessionEntry->maxTxPower, psessionEntry->peSessionId);
395
396 return;
397}
398
399
400/**
401 * limContinuePostChannelScan()
402 *
403 *FUNCTION:
404 * This function is called to scan the current channel.
405 *
406 *LOGIC:
407 *
408 *ASSUMPTIONS:
409 * NA
410 *
411 *NOTE:
412 * NA
413 *
414 * @param pMac - Pointer to Global MAC structure
415 *
416 * @return None
417 */
418
419void limContinuePostChannelScan(tpAniSirGlobal pMac)
420{
421 tANI_U8 channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 tANI_U8 i = 0;
423 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530424
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 if( pMac->lim.abortScan || (NULL == pMac->lim.gpLimMlmScanReq ) ||
426 (pMac->lim.gLimCurrentScanChannelId >
427 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)))
428 {
429 pMac->lim.abortScan = 0;
430 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
431 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
432 //Set the resume channel to Any valid channel (invalid).
433 //This will instruct HAL to set it to any previous valid channel.
434 peSetResumeChannel(pMac, 0, 0);
435
436 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
437 return;
438 }
439
440 channelNum = limGetCurrentScanChannel(pMac);
Agarwal Ashish7fed3812014-04-14 15:17:31 +0530441
442 if (channelNum == limGetCurrentOperatingChannel(pMac) &&
443 limIsconnectedOnDFSChannel(channelNum))
444 {
445 limCovertChannelScanType(pMac, channelNum, true);
446 }
447
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 if ((pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN) &&
449 (limActiveScanAllowed(pMac, channelNum)))
450 {
451 TX_TIMER *periodicScanTimer;
Jeff Johnson295189b2012-06-20 16:38:30 -0700452
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -0800453 pMac->lim.probeCounter++;
Abhishek Singh795e1b82015-09-25 15:35:03 +0530454 /* Prepare and send Probe Request frame for all
455 * the SSIDs present in the saved MLM
456 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 do
458 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +0530459 tSirMacAddr gSelfMacAddr;
Abhishek Singh795e1b82015-09-25 15:35:03 +0530460
461 /* Send self MAC as src address if
462 * MAC spoof is not enabled OR
463 * spoofMacAddr is all 0 OR
464 * disableP2PMacSpoof is enabled and scan is P2P scan
465 * else use the spoofMac as src address
466 */
467 if ((pMac->lim.isSpoofingEnabled != TRUE) ||
468 (TRUE ==
469 vos_is_macaddr_zero((v_MACADDR_t *)&pMac->lim.spoofMacAddr)) ||
470 (pMac->roam.configParam.disableP2PMacSpoofing &&
471 pMac->lim.gpLimMlmScanReq->p2pSearch)) {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +0530472 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr, VOS_MAC_ADDRESS_LEN);
473 } else {
474 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr, VOS_MAC_ADDRESS_LEN);
475 }
Abhishek Singh525045c2014-12-15 17:18:45 +0530476 limLog(pMac, LOG1,
Agarwal Ashishfb3b1c82015-08-18 16:57:31 +0530477 FL(" Mac Addr "MAC_ADDRESS_STR " used in sending ProbeReq number %d, for SSID %s on channel: %d"),
478 MAC_ADDR_ARRAY(gSelfMacAddr) ,i, pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 // include additional IE if there is
480 status = limSendProbeReqMgmtFrame( pMac, &pMac->lim.gpLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +0530481 pMac->lim.gpLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 pMac->lim.gpLimMlmScanReq->dot11mode,
483 pMac->lim.gpLimMlmScanReq->uIEFieldLen,
484 (tANI_U8 *)(pMac->lim.gpLimMlmScanReq)+pMac->lim.gpLimMlmScanReq->uIEFieldOffset);
485
486 if ( status != eSIR_SUCCESS)
487 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700488 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);)
490 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
491 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
492 return;
493 }
494 i++;
495 } while (i < pMac->lim.gpLimMlmScanReq->numSsid);
496
497 {
498#if defined WLAN_FEATURE_VOWIFI
499 //If minChannelTime is set to zero, SME is requesting scan to not use min channel timer.
500 //This is used in 11k to request for beacon measurement request with a fixed duration in
501 //max channel time.
502 if( pMac->lim.gpLimMlmScanReq->minChannelTime != 0 )
503 {
504#endif
505 /// TXP has sent Probe Request
506 /// Activate minChannelTimer
507 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
508
509#ifdef GEN6_TODO
Abhishek Singh95f7b252015-10-14 14:15:35 +0530510 /* revisit this piece of code to assign the appropriate sessionId
511 * below priority - LOW/might not be needed
512 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 pMac->lim.limTimers.gLimMinChannelTimer.sessionId = sessionId;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530514#endif
515 if (tx_timer_activate(&pMac->lim.limTimers.gLimMinChannelTimer) !=
516 TX_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530518 limLog(pMac, LOGE, FL("could not start min channel timer"));
519 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
520 limSendHalEndScanReq(pMac, channelNum,
521 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 return;
523 }
524
525 // Initialize max timer too
526 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +0530527 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer) !=
528 TX_SUCCESS)
529 {
530 limLog(pMac, LOGE, FL("could not start max channel timer"));
531 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
532 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
533 limSendHalEndScanReq(pMac, channelNum,
534 eLIM_HAL_END_SCAN_WAIT_STATE);
535 return;
536 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700537#if defined WLAN_FEATURE_VOWIFI
538 }
539 else
540 {
541#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700542 PELOGE(limLog( pMac, LOGE, "Min channel time == 0, Use only max chan timer" );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700543#endif
544 //No Need to start Min channel timer. Start Max Channel timer.
545 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
546 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
547 == TX_TIMER_ERROR)
548 {
549 /// Could not activate max channel timer.
550 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530551 limLog(pMac,LOGE, FL("could not start max channel timer"));
552 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
553 limSendHalEndScanReq(pMac,
554 channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
555 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 }
557
558 }
559#endif
560 }
561 /* Start peridic timer which will trigger probe req based on min/max
562 channel timer */
563 periodicScanTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
Sachin Ahuja49dedd72014-11-24 16:35:24 +0530564 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 if (tx_timer_activate(periodicScanTimer) != TX_SUCCESS)
566 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530567 limLog(pMac, LOGE, FL("could not start periodic probe req "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700568 "timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 }
570 periodicScanTimer->sessionId = channelNum;
571 }
572 else
573 {
574 tANI_U32 val;
Abhishek Singh525045c2014-12-15 17:18:45 +0530575 limLog(pMac, LOG1, FL("START PASSIVE Scan chan %d"), channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576
577 /// Passive Scanning. Activate maxChannelTimer
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer)
579 != TX_SUCCESS)
580 {
581 // Could not deactivate max channel timer.
582 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530583 limLog(pMac, LOGE, FL("Unable to deactivate max channel timer"));
584 limSendHalEndScanReq(pMac, channelNum,
585 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 }
587 else
588 {
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530589 if (pMac->miracast_mode)
590 {
591 val = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
592 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
593 }
594 else if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 &val) != eSIR_SUCCESS)
596 {
597 /**
598 * Could not get max channel value
599 * from CFG. Log error.
600 */
Abhishek Singh95f7b252015-10-14 14:15:35 +0530601 limLog(pMac, LOGE,
602 FL("could not retrieve passive max chan value, Use Def val"));
603 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 }
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530605
606 val = SYS_MS_TO_TICKS(val);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530607 if (tx_timer_change(&pMac->lim.limTimers.gLimMaxChannelTimer,
608 val, 0) != TX_SUCCESS)
609 {
610 // Could not change max channel timer.
611 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530612 limLog(pMac, LOGE, FL("Unable to change max channel timer"));
613 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
614 limSendHalEndScanReq(pMac, channelNum,
615 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530616 return;
617 }
Abhishek Singh95f7b252015-10-14 14:15:35 +0530618 else if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
619 != TX_SUCCESS)
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530620 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530621
622 limLog(pMac, LOGE, FL("could not start max channel timer"));
623 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
624 limSendHalEndScanReq(pMac, channelNum,
625 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530626 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 }
628 }
629 // Wait for Beacons to arrive
630 } // if (pMac->lim.gLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
631
Abhishek Singh95f7b252015-10-14 14:15:35 +0530632 limAddScanChannelInfo(pMac, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return;
634}
635
636
637
638
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530639
640/* limCovertChannelScanType()
641 *
642 *FUNCTION:
643 * This function is called to get the list, change the channel type and set again.
644 *
645 *LOGIC:
646 *
647 *ASSUMPTIONS:
648 * NA
649 *
650 *NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
651 * If a channel is PASSIVE, this fucntion will make it as ACTIVE
652 * NA
653 *
654 * @param pMac - Pointer to Global MAC structure
655 * channelNum - Channel which need to be convert
656 PassiveToActive - Boolean flag to convert channel
657 *
658 * @return None
659 */
660
661
662void limCovertChannelScanType(tpAniSirGlobal pMac,tANI_U8 channelNum, tANI_BOOLEAN passiveToActive)
663{
664
665 tANI_U32 i;
666 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
667 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530668
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530669 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
670 != eSIR_SUCCESS)
671 {
672 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list"));)
673 return ;
674 }
675 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
676 {
677 limLog(pMac, LOGE, FL("Invalid scan control list length:%d"), len);
678 return ;
679 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530680 if (pMac->fActiveScanOnDFSChannels)
681 {
682 limLog(pMac, LOG1, FL("DFS feature triggered,"
683 "block scan type conversion"));
684 return ;
685 }
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530686 for (i=0; (i+1) < len; i+=2)
687 {
688 if (channelPair[i] == channelNum)
689 {
690 if ((eSIR_PASSIVE_SCAN == channelPair[i+1]) && TRUE == passiveToActive)
691 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530692 limLog(pMac, LOG1, FL("Channel %d changed from Passive to Active"),
693 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530694 channelPair[i+1] = eSIR_ACTIVE_SCAN;
695 break ;
696 }
697 if ((eSIR_ACTIVE_SCAN == channelPair[i+1]) && FALSE == passiveToActive)
698 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530699 limLog(pMac, LOG1, FL("Channel %d changed from Active to Passive"),
700 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530701 channelPair[i+1] = eSIR_PASSIVE_SCAN;
702 break ;
703 }
704 }
705 }
706
707 cfgSetStrNotify(pMac, WNI_CFG_SCAN_CONTROL_LIST, (tANI_U8 *)channelPair, len, FALSE);
708 return ;
709}
710
711
712
713
714/* limSetDFSChannelList()
715 *
716 *FUNCTION:
717 * This function is called to convert DFS channel list to active channel list when any
718 * beacon is present on that channel. This function store time for passive channels
719 * which help to know that for how much time channel has been passive.
720 *
721 *LOGIC:
722 *
723 *ASSUMPTIONS:
724 * NA
725 *
726 *NOTE: If a channel is ACTIVE, it won't store any time
727 * If a channel is PAssive, it will store time as timestamp
728 * NA
729 *
730 * @param pMac - Pointer to Global MAC structure
731 * dfsChannelList - DFS channel list.
732 * @return None
733 */
734
735void limSetDFSChannelList(tpAniSirGlobal pMac,tANI_U8 channelNum, tSirDFSChannelList *dfsChannelList)
736{
737
738 tANI_BOOLEAN passiveToActive = TRUE;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530739 tANI_U32 cfgVal;
740
741 if (eSIR_SUCCESS == wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON,
742 &cfgVal))
743 {
744 limLog(pMac, LOG1, FL("WNI_CFG_ACTIVE_PASSIVE_CON: %d"), cfgVal);
745 if (!cfgVal)
746 return;
747 }
748
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530749 if ((1 <= channelNum) && (165 >= channelNum))
750 {
751 if (eANI_BOOLEAN_TRUE == limIsconnectedOnDFSChannel(channelNum))
752 {
753 if (dfsChannelList->timeStamp[channelNum] == 0)
754 {
755 //Received first beacon; Convert DFS channel to Active channel.
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530756 limLog(pMac, LOG1, FL("Received first beacon on DFS channel: %d"), channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530757 limCovertChannelScanType(pMac,channelNum, passiveToActive);
758 }
Abhishek Singh6fcdf652016-11-23 10:59:12 +0530759
760 if (!pMac->fActiveScanOnDFSChannels &&
761 dfsChannelList->timeStamp[channelNum] &&
762 !limActiveScanAllowed(pMac, channelNum))
763 limLog(pMac, LOGE,
764 FL("Received beacon on DFS channel %d with dfs time stamp %lu, but channel is still DFS"),
765 channelNum, dfsChannelList->timeStamp[channelNum]);
766
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530767 dfsChannelList->timeStamp[channelNum] = vos_timer_get_system_time();
768 }
769 else
770 {
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530771 return;
772 }
773 if (!tx_timer_running(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer))
774 {
775 tx_timer_activate(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer);
776 }
777 }
778 else
779 {
780 PELOGE(limLog(pMac, LOGE, FL("Invalid Channel: %d"), channelNum);)
781 return;
782 }
783
784 return;
785}
786
Paul Zhang83289792017-02-28 18:58:52 +0800787void limDoSendAuthMgmtFrame(tpAniSirGlobal pMac, tpPESession psessionEntry)
788{
789 tSirMacAuthFrameBody authFrameBody;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530790
Paul Zhang83289792017-02-28 18:58:52 +0800791 //Prepare & send Authentication frame
792 authFrameBody.authAlgoNumber =
793 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
794 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
795 authFrameBody.authStatusCode = 0;
796 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
797 limSendAuthMgmtFrame(pMac,
798 &authFrameBody,
799 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
800 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
801 if (tx_timer_activate(&pMac->lim.limTimers.gLimAuthFailureTimer)
802 != TX_SUCCESS) {
803 //Could not start Auth failure timer.
804 //Log error
805 limLog(pMac, LOGP,
806 FL("could not start Auth failure timer"));
807 //Cleanup as if auth timer expired
808 limProcessAuthFailureTimeout(pMac);
809 } else {
810 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE,
811 psessionEntry->peSessionId, eLIM_AUTH_RETRY_TIMER));
812 //Activate Auth Retry timer
813 if (tx_timer_activate
814 (&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
815 != TX_SUCCESS) {
816 limLog(pMac, LOGP,
817 FL("could not activate Auth Retry timer"));
818 }
819 }
820 return;
821}
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530822
Jeff Johnson295189b2012-06-20 16:38:30 -0700823/*
824* Creates a Raw frame to be sent before every Scan, if required.
825* If only infra link is active (mlmState = Link Estb), then send Data Null
826* If only BT-AMP-AP link is active(mlmState = BSS_STARTED), then send CTS2Self frame.
827* If only BT-AMP-STA link is active(mlmState = BSS_STARTED or Link Est) then send CTS2Self
828* If Only IBSS link is active, then send CTS2Self
829* for concurrent scenario: Infra+BT or Infra+IBSS, always send CTS2Self, no need to send Data Null
830*
831*/
832static void __limCreateInitScanRawFrame(tpAniSirGlobal pMac,
833 tpInitScanParams pInitScanParam)
834{
835 tANI_U8 i;
836 pInitScanParam->scanEntry.activeBSScnt = 0;
837
838 /* Don't send CTS to self as we have issue with BTQM queues where BTQM can
839 * not handle transmition of CTS2self frames. Sending CTS 2 self at this
840 * juncture also doesn't serve much purpose as probe request frames go out
841 * immediately, No need to notify BSS in IBSS case.
842 * */
843
844 for(i =0; i < pMac->lim.maxBssId; i++)
845 {
846 if(pMac->lim.gpSession[i].valid == TRUE)
847 {
848 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
849 {
850 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
851 (pInitScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
852 {
853 pInitScanParam->scanEntry.bssIdx[pInitScanParam->scanEntry.activeBSScnt]
854 = pMac->lim.gpSession[i].bssIdx;
855 pInitScanParam->scanEntry.activeBSScnt++;
856
857 }
858 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 else if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
860 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
861 )
862 {
863 pInitScanParam->useNoA = TRUE;
864 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
866 }
867 if (pInitScanParam->scanEntry.activeBSScnt)
868 {
869 pInitScanParam->notifyBss = TRUE;
870 pInitScanParam->frameType = SIR_MAC_DATA_FRAME;
871 pInitScanParam->frameLength = 0;
872 }
873}
874
875/*
876* Creates a Raw frame to be sent during finish scan, if required.
877* Send data null frame, only when there is just one session active and that session is
878* in 'link Estb' state.
879* if more than one session is active, don't send any frame.
880* for concurrent scenario: Infra+BT or Infra+IBSS, no need to send Data Null
881*
882*/
883static void __limCreateFinishScanRawFrame(tpAniSirGlobal pMac,
884 tpFinishScanParams pFinishScanParam)
885{
886 tANI_U8 i;
887 pFinishScanParam->scanEntry.activeBSScnt = 0;
888
889 for(i =0; i < pMac->lim.maxBssId; i++)
890 {
891 if(pMac->lim.gpSession[i].valid == TRUE)
892 {
893 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
894 {
895 //BT-STA can either be in LINK-ESTB state or BSS_STARTED State
896 //for BT, need to send CTS2Self
897 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
898 (pFinishScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
899 {
900 pFinishScanParam->scanEntry.bssIdx[pFinishScanParam->scanEntry.activeBSScnt]
901 = pMac->lim.gpSession[i].bssIdx;
902 pFinishScanParam->scanEntry.activeBSScnt++;
903 }
904 }
905 }
906 }
907
908 if (pFinishScanParam->scanEntry.activeBSScnt)
909 {
910 pFinishScanParam->notifyBss = TRUE;
911 pFinishScanParam->frameType = SIR_MAC_DATA_FRAME;
912 pFinishScanParam->frameLength = 0;
913 }
914}
915
916void
917limSendHalInitScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState, tSirLinkTrafficCheck trafficCheck)
918{
919
920
921 tSirMsgQ msg;
922 tpInitScanParams pInitScanParam;
923 tSirRetStatus rc = eSIR_SUCCESS;
924
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530925 pInitScanParam = vos_mem_malloc(sizeof(*pInitScanParam));
926 if ( NULL == pInitScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530928 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 goto error;
930 }
931
932 /*Initialize the pInitScanParam with 0*/
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530933 vos_mem_set((tANI_U8 *)pInitScanParam, sizeof(*pInitScanParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935 msg.type = WDA_INIT_SCAN_REQ;
936 msg.bodyptr = pInitScanParam;
937 msg.bodyval = 0;
938
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530939 vos_mem_set((tANI_U8 *)&pInitScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if (nextState == eLIM_HAL_INIT_LEARN_WAIT_STATE)
941 {
942 pInitScanParam->notifyBss = TRUE;
943 pInitScanParam->notifyHost = FALSE;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700944 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
945 {
946 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
947 }
948 else
949 {
950 pInitScanParam->scanMode = eHAL_SYS_MODE_LEARN;
951 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700952
Jeff Johnsone7245742012-09-05 17:12:55 -0700953 pInitScanParam->frameType = SIR_MAC_CTRL_CTS;
954 __limCreateInitScanRawFrame(pMac, pInitScanParam);
955 pInitScanParam->checkLinkTraffic = trafficCheck;
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 }
957 else
958 {
959 if(nextState == eLIM_HAL_SUSPEND_LINK_WAIT_STATE)
960 {
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700961 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
962 {
963 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SUSPEND_LINK;
964 }
965 else
966 {
967 pInitScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
968 }
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 }
971 else
972 {
Madan Mohan Koyyalamudi94d111d2012-11-19 20:11:26 -0800973 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
974 {
975 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
976 }
977 else
978 {
979 pInitScanParam->scanMode = eHAL_SYS_MODE_SCAN;
980 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982 __limCreateInitScanRawFrame(pMac, pInitScanParam);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 if (pInitScanParam->useNoA)
984 {
985 pInitScanParam->scanDuration = pMac->lim.gTotalScanDuration;
986 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 /* Inform HAL whether it should check for traffic on the link
988 * prior to performing a background scan
989 */
990 pInitScanParam->checkLinkTraffic = trafficCheck;
991 }
992
993 pMac->lim.gLimHalScanState = nextState;
994 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -0700995 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997 rc = wdaPostCtrlMsg(pMac, &msg);
998 if (rc == eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700999 PELOG3(limLog(pMac, LOG3, FL("wdaPostCtrlMsg() return eSIR_SUCCESS pMac=%x nextState=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 pMac, pMac->lim.gLimHalScanState);)
1001 return;
1002 }
1003
1004 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301005 vos_mem_free(pInitScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001006 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001007
1008error:
1009 switch(nextState)
1010 {
1011 case eLIM_HAL_START_SCAN_WAIT_STATE:
Padma, Santhosh Kumar9a3eea12015-02-18 14:05:03 +05301012 case eLIM_HAL_INIT_SCAN_WAIT_STATE:
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1014 break;
1015
Jeff Johnson295189b2012-06-20 16:38:30 -07001016
1017 //WLAN_SUSPEND_LINK Related
1018 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
1019 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1020 if( pMac->lim.gpLimSuspendCallback )
1021 {
1022 pMac->lim.gpLimSuspendCallback( pMac, rc, pMac->lim.gpLimSuspendData );
1023 pMac->lim.gpLimSuspendCallback = NULL;
1024 pMac->lim.gpLimSuspendData = NULL;
1025 }
1026 pMac->lim.gLimSystemInScanLearnMode = 0;
1027 break;
1028 //end WLAN_SUSPEND_LINK Related
1029 default:
1030 break;
1031 }
1032 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1033
1034 return ;
1035}
1036
1037void
1038limSendHalStartScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1039{
1040 tSirMsgQ msg;
1041 tpStartScanParams pStartScanParam;
1042 tSirRetStatus rc = eSIR_SUCCESS;
1043
1044 /**
1045 * The Start scan request to be sent only if Start Scan is not already requested
1046 */
1047 if(pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE)
1048 {
1049
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301050 pStartScanParam = vos_mem_malloc(sizeof(*pStartScanParam));
1051 if ( NULL == pStartScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301053 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 goto error;
1055 }
1056
1057 msg.type = WDA_START_SCAN_REQ;
1058 msg.bodyptr = pStartScanParam;
1059 msg.bodyval = 0;
1060 pStartScanParam->status = eHAL_STATUS_SUCCESS;
1061 pStartScanParam->scanChannel = (tANI_U8)channelNum;
1062
1063 pMac->lim.gLimHalScanState = nextState;
1064 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1065
Jeff Johnsone7245742012-09-05 17:12:55 -07001066 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001067
1068 rc = wdaPostCtrlMsg(pMac, &msg);
1069 if (rc == eSIR_SUCCESS) {
1070 return;
1071 }
1072
1073 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301074 vos_mem_free(pStartScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001075 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077error:
1078 switch(nextState)
1079 {
1080 case eLIM_HAL_START_SCAN_WAIT_STATE:
1081 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1082 break;
1083
Jeff Johnson295189b2012-06-20 16:38:30 -07001084
1085 default:
1086 break;
1087 }
1088 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1089
1090 }
1091 else
1092 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001093 PELOGW(limLog(pMac, LOGW, FL("Invalid state for START_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 }
1095
1096 return;
1097}
1098
1099void limSendHalEndScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1100{
1101 tSirMsgQ msg;
1102 tpEndScanParams pEndScanParam;
1103 tSirRetStatus rc = eSIR_SUCCESS;
1104
1105 /**
1106 * The End scan request to be sent only if End Scan is not already requested or
Leela Venkata Kiran Kumar Reddy Chirala66639a62013-08-29 15:38:19 -07001107 * Start scan is not already requestd.
1108 * after finish scan rsp from firmware host is sending endscan request so adding
1109 * check for IDLE SCAN STATE also added to avoid this issue
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 */
1111 if((pMac->lim.gLimHalScanState != eLIM_HAL_END_SCAN_WAIT_STATE) &&
Leela Venkata Kiran Kumar Reddy Chirala66639a62013-08-29 15:38:19 -07001112 (pMac->lim.gLimHalScanState != eLIM_HAL_IDLE_SCAN_STATE) &&
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07001113 (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE) &&
1114 (pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE) &&
1115 (pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE))
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301116 {
1117 pEndScanParam = vos_mem_malloc(sizeof(*pEndScanParam));
1118 if ( NULL == pEndScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301120 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 goto error;
1122 }
1123
1124 msg.type = WDA_END_SCAN_REQ;
1125 msg.bodyptr = pEndScanParam;
1126 msg.bodyval = 0;
1127 pEndScanParam->status = eHAL_STATUS_SUCCESS;
1128 pEndScanParam->scanChannel = (tANI_U8)channelNum;
1129
1130 pMac->lim.gLimHalScanState = nextState;
1131 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001132 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001133
1134 rc = wdaPostCtrlMsg(pMac, &msg);
1135 if (rc == eSIR_SUCCESS) {
1136 return;
1137 }
1138
1139 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301140 vos_mem_free(pEndScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001141 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001142
1143 error:
1144 switch(nextState)
1145 {
1146 case eLIM_HAL_END_SCAN_WAIT_STATE:
1147 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_END_FAILED);
1148 break;
1149
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
1151 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001152 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg Rcvd invalid nextState %d"), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 break;
1154 }
1155 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001156 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 }
1158 else
1159 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001160 PELOGW(limLog(pMac, LOGW, FL("Invalid state for END_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 }
1162
1163
1164 return;
1165}
1166
Bhargav Shahe3a6ff02016-04-11 16:31:49 +05301167
1168void limSendTLPauseInd(tpAniSirGlobal pMac, uint16_t staId)
1169{
1170 tSirMsgQ msg;
1171 tSirRetStatus rc = eSIR_SUCCESS;
1172
1173 msg.type = WDA_PAUSE_TL_IND;
1174 msg.bodyval = staId;
1175
1176 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1177
1178 rc = wdaPostCtrlMsg(pMac, &msg);
1179 if (rc == eSIR_SUCCESS) {
1180 return;
1181 }
1182
1183 limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);
1184
1185 return;
1186}
1187
Jeff Johnson295189b2012-06-20 16:38:30 -07001188/**
1189 * limSendHalFinishScanReq()
1190 *
1191 *FUNCTION:
1192 * This function is called to finish scan/learn request..
1193 *
1194 *LOGIC:
1195 *
1196 *ASSUMPTIONS:
1197 * NA
1198 *
1199 *NOTE:
1200 * NA
1201 *
1202 * @param pMac - Pointer to Global MAC structure
1203 * @param nextState - this parameters determines whether this call is for scan or learn
1204 *
1205 * @return None
1206 */
1207void limSendHalFinishScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState)
1208{
1209
1210 tSirMsgQ msg;
1211 tpFinishScanParams pFinishScanParam;
1212 tSirRetStatus rc = eSIR_SUCCESS;
1213
1214 if(pMac->lim.gLimHalScanState == nextState)
1215 {
1216 /*
1217 * PE may receive multiple probe responses, while waiting for HAL to send 'FINISH_SCAN_RSP' message
1218 * PE was sending multiple finish scan req messages to HAL
1219 * this check will avoid that.
1220 * If PE is already waiting for the 'finish_scan_rsp' message from HAL, it will ignore this request.
1221 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001222 PELOGW(limLog(pMac, LOGW, FL("Next Scan State is same as the current state: %d "), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 return;
1224 }
1225
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301226 pFinishScanParam = vos_mem_malloc(sizeof(*pFinishScanParam));
1227 if ( NULL == pFinishScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301229 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 goto error;
1231 }
1232
1233 msg.type = WDA_FINISH_SCAN_REQ;
1234 msg.bodyptr = pFinishScanParam;
1235 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001236
1237 peGetResumeChannel(pMac, &pFinishScanParam->currentOperChannel, &pFinishScanParam->cbState);
1238
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301239 vos_mem_set((tANI_U8 *)&pFinishScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
1241 if (nextState == eLIM_HAL_FINISH_LEARN_WAIT_STATE)
1242 {
1243 //AP - No pkt need to be transmitted
1244 pFinishScanParam->scanMode = eHAL_SYS_MODE_LEARN;
1245 pFinishScanParam->notifyBss = FALSE;
1246 pFinishScanParam->notifyHost = FALSE;
1247 pFinishScanParam->frameType = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001248
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 pFinishScanParam->frameLength = 0;
1250 pMac->lim.gLimHalScanState = nextState;
1251 }
1252 else
1253 {
1254 /* If STA is associated with an AP (ie. STA is in
1255 * LINK_ESTABLISHED state), then STA need to inform
1256 * the AP via either DATA-NULL
1257 */
1258 if (nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE)
1259 {
1260 pFinishScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
1261 }
1262 else
1263 {
1264 pFinishScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1265 }
1266 pFinishScanParam->notifyHost = FALSE;
1267 __limCreateFinishScanRawFrame(pMac, pFinishScanParam);
1268 //WLAN_SUSPEND_LINK Related
1269 pMac->lim.gLimHalScanState = nextState;
1270 //end WLAN_SUSPEND_LINK Related
1271 }
1272
1273 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001274 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001275
1276 rc = wdaPostCtrlMsg(pMac, &msg);
1277 if (rc == eSIR_SUCCESS) {
1278 return;
1279 }
1280 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301281 vos_mem_free(pFinishScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001282 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001283
1284 error:
1285 if(nextState == eLIM_HAL_FINISH_SCAN_WAIT_STATE)
1286 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_FINISH_FAILED);
1287 //WLAN_SUSPEND_LINK Related
1288 else if ( nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE )
1289 {
1290 if( pMac->lim.gpLimResumeCallback )
1291 {
1292 pMac->lim.gpLimResumeCallback( pMac, rc, pMac->lim.gpLimResumeData );
1293 pMac->lim.gpLimResumeCallback = NULL;
1294 pMac->lim.gpLimResumeData = NULL;
1295 pMac->lim.gLimSystemInScanLearnMode = 0;
1296 }
1297 }
1298 //end WLAN_SUSPEND_LINK Related
1299 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1300 return;
1301}
1302
1303/**
1304 * limContinueChannelScan()
1305 *
1306 *FUNCTION:
1307 * This function is called by limPerformChannelScan().
1308 * This function is called to continue channel scanning when
1309 * Beacon/Probe Response frame are received.
1310 *
1311 *LOGIC:
1312 * Scan criteria stored in pMac->lim.gLimMlmScanReq is used
1313 * to perform channel scan. In this function MLM sub module
1314 * makes channel switch, sends PROBE REQUEST frame in case of
1315 * ACTIVE SCANNING, starts min/max channel timers, programs
1316 * NAV to probeDelay timer and waits for Beacon/Probe Response.
1317 * Once all required channels are scanned, LIM_MLM_SCAN_CNF
1318 * primitive is used to send Scan results to SME sub module.
1319 *
1320 *ASSUMPTIONS:
1321 * 1. In case of Active scanning, start MAX channel time iff
1322 * MIN channel timer expired and activity is observed on
1323 * the channel.
1324 *
1325 *NOTE:
1326 * NA
1327 *
1328 * @param pMac Pointer to Global MAC structure
1329 * @return None
1330 */
1331void
1332limContinueChannelScan(tpAniSirGlobal pMac)
1333{
1334 tANI_U8 channelNum;
1335
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 if (pMac->lim.gLimCurrentScanChannelId >
1337 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)
1338 || pMac->lim.abortScan)
1339 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 pMac->lim.abortScan = 0;
1341 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1342 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1343
1344 //Set the resume channel to Any valid channel (invalid).
1345 //This will instruct HAL to set it to any previous valid channel.
1346 peSetResumeChannel(pMac, 0, 0);
1347
1348 /// Done scanning all required channels
1349 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 return;
1351 }
1352
1353 /// Atleast one more channel is to be scanned
1354
1355 if ((pMac->lim.gLimReturnAfterFirstMatch & 0x40) ||
1356 (pMac->lim.gLimReturnAfterFirstMatch & 0x80))
1357 {
1358 while (pMac->lim.gLimCurrentScanChannelId <=
1359 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1360 {
1361 if (((limGetCurrentScanChannel(pMac) <= 14) &&
1362 pMac->lim.gLim24Band11dScanDone) ||
1363 ((limGetCurrentScanChannel(pMac) > 14) &&
1364 pMac->lim.gLim50Band11dScanDone))
1365 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001366 limLog(pMac, LOGW, FL("skipping chan %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 limGetCurrentScanChannel(pMac));
1368 pMac->lim.gLimCurrentScanChannelId++;
1369 }
1370 else
1371 break;
1372 }
1373
1374 if (pMac->lim.gLimCurrentScanChannelId >
1375 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1376 {
1377 pMac->lim.abortScan = 0;
1378 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1379 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1380 /// Done scanning all required channels
1381 //Set the resume channel to Any valid channel (invalid).
1382 //This will instruct HAL to set it to any previous valid channel.
1383 peSetResumeChannel(pMac, 0, 0);
1384 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
1385 return;
1386 }
1387 }
1388
1389 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh525045c2014-12-15 17:18:45 +05301390 limLog(pMac, LOG1, FL("Current Channel to be scanned is %d"),
1391 channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392
1393 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_SCAN_WAIT_STATE);
1394 return;
1395} /*** end limContinueChannelScan() ***/
1396
1397
1398
1399/**
1400 * limRestorePreScanState()
1401 *
1402 *FUNCTION:
1403 * This function is called by limContinueChannelScan()
1404 * to restore HW state prior to entering 'scan state'
1405 *
1406 *LOGIC
1407 *
1408 *ASSUMPTIONS:
1409 *
1410 *NOTE:
1411 * NA
1412 *
1413 * @param pMac Pointer to Global MAC structure
1414 * @return None
1415 */
1416void
1417limRestorePreScanState(tpAniSirGlobal pMac)
1418{
1419 int i;
1420
1421 /// Deactivate MIN/MAX channel timers if running
1422 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1423 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1424
1425 /* Re-activate Heartbeat timers for connected sessions as scan
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001426 * is done if the DUT is in active mode
1427 * AND it is not a ROAMING ("background") scan */
1428 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 (ePMM_STATE_READY == pMac->pmm.gPmmState))
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001430 && (pMac->lim.gLimBackgroundScanMode != eSIR_ROAMING_SCAN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 {
1432 for(i=0;i<pMac->lim.maxBssId;i++)
1433 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001434 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1435 (pMac->lim.gpSession[i].valid == TRUE) &&
Yathish9f22e662012-12-10 14:21:35 -08001436 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState) &&
1437 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 {
1439 limReactivateHeartBeatTimer(pMac, peFindSessionBySessionId(pMac,i));
1440 }
1441 }
1442 }
1443
1444 /**
1445 * clean up message queue.
1446 * If SME messages, redirect to deferred queue.
1447 * The rest will be discarded.
1448 */
1449 //limCleanupMsgQ(pMac);
1450
1451 pMac->lim.gLimSystemInScanLearnMode = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301452 limLog(pMac, LOG1, FL("Scan ended, took %ld tu"),
1453 (tx_time_get() - pMac->lim.scanStartTime));
Jeff Johnson295189b2012-06-20 16:38:30 -07001454} /*** limRestorePreScanState() ***/
1455
Jeff Johnsone7245742012-09-05 17:12:55 -07001456#ifdef FEATURE_OEM_DATA_SUPPORT
1457
1458void limSendHalOemDataReq(tpAniSirGlobal pMac)
1459{
1460 tSirMsgQ msg;
1461 tpStartOemDataReq pStartOemDataReq = NULL;
1462 tSirRetStatus rc = eSIR_SUCCESS;
1463 tpLimMlmOemDataRsp pMlmOemDataRsp;
1464 tANI_U32 reqLen = 0;
1465 if(NULL == pMac->lim.gpLimMlmOemDataReq)
1466 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001467 PELOGE(limLog(pMac, LOGE, FL("Null pointer"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001468 goto error;
1469 }
1470
1471 reqLen = sizeof(tStartOemDataReq);
1472
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301473 pStartOemDataReq = vos_mem_malloc(reqLen);
1474 if ( NULL == pStartOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001475 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001476 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Could not allocate memory for pStartOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001477 goto error;
1478 }
1479
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301480 vos_mem_set((tANI_U8*)(pStartOemDataReq), reqLen, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001481
1482 //Now copy over the information to the OEM DATA REQ to HAL
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301483 vos_mem_copy(pStartOemDataReq->selfMacAddr,
1484 pMac->lim.gpLimMlmOemDataReq->selfMacAddr,
1485 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07001486
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301487 vos_mem_copy(pStartOemDataReq->oemDataReq,
1488 pMac->lim.gpLimMlmOemDataReq->oemDataReq,
1489 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001490
1491 //Create the message to be passed to HAL
1492 msg.type = WDA_START_OEM_DATA_REQ;
1493 msg.bodyptr = pStartOemDataReq;
1494 msg.bodyval = 0;
1495
1496 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1497 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1498
1499 rc = wdaPostCtrlMsg(pMac, &msg);
1500 if(rc == eSIR_SUCCESS)
1501 {
1502 return;
1503 }
1504
1505 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301506 vos_mem_free(pStartOemDataReq);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001507 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: posting WDA_START_OEM_DATA_REQ to HAL failed"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001508
1509error:
1510 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001511 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001512
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301513 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1514 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001515 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001516 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001517 return;
1518 }
1519
1520 if(NULL != pMac->lim.gpLimMlmOemDataReq)
1521 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301522 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001523 pMac->lim.gpLimMlmOemDataReq = NULL;
1524 }
1525
1526 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1527
1528 return;
1529}
1530/**
1531 * limSetOemDataReqModeFailed()
1532 *
1533 * FUNCTION:
1534 * This function is used as callback to resume link after the suspend fails while
1535 * starting oem data req mode.
1536 * LOGIC:
1537 * NA
1538 *
1539 * ASSUMPTIONS:
1540 * NA
1541 *
1542 * NOTE:
1543 *
1544 * @param pMac - Pointer to Global MAC structure
1545 * @return None
1546 */
1547
1548void limSetOemDataReqModeFailed(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1549{
1550 tpLimMlmOemDataRsp pMlmOemDataRsp;
1551
1552 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001553 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001554
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301555 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1556 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001558 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001559 return;
1560 }
1561
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301562 if (NULL != pMac->lim.gpLimMlmOemDataReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301564 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001565 pMac->lim.gpLimMlmOemDataReq = NULL;
1566 }
1567
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301568 vos_mem_set(pMlmOemDataRsp, sizeof(tLimMlmOemDataRsp), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001569
1570 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1571
1572 return;
1573}
1574
1575/**
1576 * limSetOemDataReqMode()
1577 *
1578 *FUNCTION:
1579 * This function is called to setup system into OEM DATA REQ mode
1580 *
1581 *LOGIC:
1582 * NA
1583 *
1584 *ASSUMPTIONS:
1585 * NA
1586 *
1587 *NOTE:
1588 *
1589 * @param pMac - Pointer to Global MAC structure
1590 * @return None
1591 */
1592
1593void limSetOemDataReqMode(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1594{
1595 if(status != eHAL_STATUS_SUCCESS)
1596 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001597 limLog(pMac, LOGE, FL("OEM_DATA: failed in suspend link"));
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301598 /* If failed to suspend the link, there is no need
1599 * to resume link. Return failure.
1600 */
1601 limSetOemDataReqModeFailed(pMac, status, data);
Jeff Johnsone7245742012-09-05 17:12:55 -07001602 }
1603 else
1604 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001605 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Calling limSendHalOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001606 limSendHalOemDataReq(pMac);
Jeff Johnsone7245742012-09-05 17:12:55 -07001607 }
1608
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301609 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001610} /*** end limSendHalOemDataReq() ***/
1611
1612#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
1614static void
1615mlm_add_sta(
1616 tpAniSirGlobal pMac,
1617 tpAddStaParams pSta,
1618 tANI_U8 *pBssid,
1619 tANI_U8 htCapable,
1620 tpPESession psessionEntry) //psessionEntry may required in future
1621{
1622 tANI_U32 val;
1623 int i;
1624
1625
1626 pSta->staType = STA_ENTRY_SELF; // Identifying self
1627
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301628 vos_mem_copy(pSta->bssId, pBssid, sizeof( tSirMacAddr ));
1629 vos_mem_copy(pSta->staMac, psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001630
1631 /* Configuration related parameters to be changed to support BT-AMP */
1632
1633 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_LISTEN_INTERVAL, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001634 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001635
1636 pSta->listenInterval = (tANI_U16) val;
1637
1638 if (eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) )
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001639 limLog(pMac, LOGP, FL("Couldn't get SHORT_PREAMBLE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 pSta->shortPreambleSupported = (tANI_U8)val;
1641
1642 pSta->assocId = 0; // Is SMAC OK with this?
1643 pSta->wmmEnabled = 0;
1644 pSta->uAPSD = 0;
1645 pSta->maxSPLen = 0;
1646 pSta->us32MaxAmpduDuration = 0;
1647 pSta->maxAmpduSize = 0; // 0: 8k, 1: 16k,2: 32k,3: 64k
1648
1649
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001650 /* For Self STA get the LDPC capability from config.ini*/
1651 pSta->htLdpcCapable =
1652 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
1653 pSta->vhtLdpcCapable =
1654 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
1655
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1657 {
1658 pSta->htCapable = htCapable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 pSta->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
1660 pSta->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry );
1661 pSta->mimoPS = (tSirMacHTMIMOPowerSaveState)limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
1662 pSta->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
1663 pSta->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
1664 pSta->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
1665 pSta->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
1666 pSta->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
1667 pSta->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
1668 pSta->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
1669 pSta->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001671#ifdef WLAN_FEATURE_11AC
1672 if (psessionEntry->vhtCapability)
1673 {
1674 pSta->vhtCapable = VOS_TRUE;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001675 pSta->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001676 }
1677#endif
1678#ifdef WLAN_FEATURE_11AC
1679 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry,NULL);
1680#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001682#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 limFillSupportedRatesInfo(pMac, NULL, &pSta->supportedRates,psessionEntry);
1684
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001685 limLog( pMac, LOGE, FL( "GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d, SGI20: %d, SGI40%d") ,
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 pSta->greenFieldCapable, pSta->txChannelWidthSet, pSta->mimoPS, pSta->lsigTxopProtection,
1687 pSta->fDsssCckMode40Mhz,pSta->fShortGI20Mhz, pSta->fShortGI40Mhz);
1688
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 if (VOS_P2P_GO_MODE == psessionEntry->pePersona)
1690 {
1691 pSta->p2pCapableSta = 1;
1692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001693
1694 //Disable BA. It will be set as part of ADDBA negotiation.
1695 for( i = 0; i < STACFG_MAX_TC; i++ )
1696 {
1697 pSta->staTCParams[i].txUseBA = eBA_DISABLE;
1698 pSta->staTCParams[i].rxUseBA = eBA_DISABLE;
1699 }
1700
1701}
1702
1703//
1704// New HAL interface - WDA_ADD_BSS_REQ
1705// Package WDA_ADD_BSS_REQ to HAL, in order to start a BSS
1706//
1707tSirResultCodes
1708limMlmAddBss (
1709 tpAniSirGlobal pMac,
1710 tLimMlmStartReq *pMlmStartReq,
1711 tpPESession psessionEntry)
1712{
1713 tSirMsgQ msgQ;
1714 tpAddBssParams pAddBssParams = NULL;
1715 tANI_U32 retCode;
1716
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 // Package WDA_ADD_BSS_REQ message parameters
1718
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301719 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
1720 if ( NULL == pAddBssParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301722 limLog( pMac, LOGE, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 // Respond to SME with LIM_MLM_START_CNF
1724 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1725 }
1726
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301727 vos_mem_set(pAddBssParams, sizeof(tAddBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728
1729 // Fill in tAddBssParams members
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301730 vos_mem_copy(pAddBssParams->bssId, pMlmStartReq->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 sizeof( tSirMacAddr ));
1732
1733 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301734 vos_mem_copy (pAddBssParams->selfMacAddr,
1735 psessionEntry->selfMacAddr,
1736 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001737
1738 pAddBssParams->bssType = pMlmStartReq->bssType;
1739 if ((pMlmStartReq->bssType == eSIR_IBSS_MODE) ||
1740 (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE)||
1741 (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE)) {
1742 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
1743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 else if (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE){
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_AP;
1746 }
1747
Jeff Johnsone7245742012-09-05 17:12:55 -07001748 pAddBssParams->shortSlotTimeSupported = psessionEntry->shortSlotTimeSupported;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 pAddBssParams->beaconInterval = pMlmStartReq->beaconPeriod;
1751 pAddBssParams->dtimPeriod = pMlmStartReq->dtimPeriod;
1752 pAddBssParams->cfParamSet.cfpCount = pMlmStartReq->cfParamSet.cfpCount;
1753 pAddBssParams->cfParamSet.cfpPeriod = pMlmStartReq->cfParamSet.cfpPeriod;
1754 pAddBssParams->cfParamSet.cfpMaxDuration = pMlmStartReq->cfParamSet.cfpMaxDuration;
1755 pAddBssParams->cfParamSet.cfpDurRemaining = pMlmStartReq->cfParamSet.cfpDurRemaining;
1756
1757 pAddBssParams->rateSet.numRates = pMlmStartReq->rateSet.numRates;
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301758 vos_mem_copy(pAddBssParams->rateSet.rate,
1759 pMlmStartReq->rateSet.rate, pMlmStartReq->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760
1761 pAddBssParams->nwType = pMlmStartReq->nwType;
1762
1763 pAddBssParams->htCapable = pMlmStartReq->htCapable;
Jeff Johnsone7245742012-09-05 17:12:55 -07001764#ifdef WLAN_FEATURE_11AC
1765 pAddBssParams->vhtCapable = psessionEntry->vhtCapability;
1766 pAddBssParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
1767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 pAddBssParams->htOperMode = pMlmStartReq->htOperMode;
1769 pAddBssParams->dualCTSProtection = pMlmStartReq->dualCTSProtection;
1770 pAddBssParams->txChannelWidthSet = pMlmStartReq->txChannelWidthSet;
1771
1772 pAddBssParams->currentOperChannel = pMlmStartReq->channelNumber;
Jeff Johnsone7245742012-09-05 17:12:55 -07001773 pAddBssParams->currentExtChannel = pMlmStartReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001774
Chet Lanctot8cecea22014-02-11 19:09:36 -08001775#ifdef WLAN_FEATURE_11W
1776 pAddBssParams->rmfEnabled = psessionEntry->limRmfEnabled;
1777#endif
1778
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 /* Update PE sessionId*/
1780 pAddBssParams->sessionId = pMlmStartReq->sessionId;
1781
1782 //Send the SSID to HAL to enable SSID matching for IBSS
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301783 vos_mem_copy(&(pAddBssParams->ssId.ssId),
1784 pMlmStartReq->ssId.ssId,
1785 pMlmStartReq->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 pAddBssParams->ssId.length = pMlmStartReq->ssId.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pAddBssParams->bHiddenSSIDEn = pMlmStartReq->ssidHidden;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001788 limLog( pMac, LOGE, FL( "TRYING TO HIDE SSID %d" ),pAddBssParams->bHiddenSSIDEn);
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 // CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed.
1790 pAddBssParams->bProxyProbeRespEn = 0;
1791 pAddBssParams->obssProtEnabled = pMlmStartReq->obssProtEnabled;
1792
Jeff Johnson295189b2012-06-20 16:38:30 -07001793#if defined WLAN_FEATURE_VOWIFI
1794 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
1795#endif
1796 mlm_add_sta(pMac, &pAddBssParams->staContext,
1797 pAddBssParams->bssId, pAddBssParams->htCapable,psessionEntry);
1798
1799 pAddBssParams->status = eHAL_STATUS_SUCCESS;
1800 pAddBssParams->respReqd = 1;
1801
1802 // Set a new state for MLME
1803 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001804 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001805
1806 pAddBssParams->halPersona=psessionEntry->pePersona; //pass on the session persona to hal
1807
1808 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
1809
1810#if defined WLAN_FEATURE_VOWIFI_11R
1811 pAddBssParams->extSetStaKeyParamValid = 0;
1812#endif
1813
1814 //
1815 // FIXME_GEN4
1816 // A global counter (dialog token) is required to keep track of
1817 // all PE <-> HAL communication(s)
1818 //
1819 msgQ.type = WDA_ADD_BSS_REQ;
1820 msgQ.reserved = 0;
1821 msgQ.bodyptr = pAddBssParams;
1822 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001823 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001824
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001825 limLog( pMac, LOGW, FL( "Sending WDA_ADD_BSS_REQ..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1827 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001828 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301829 vos_mem_free(pAddBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1831 }
1832
1833 return eSIR_SME_SUCCESS;
1834}
1835
1836
1837/**
1838 * limProcessMlmStartReq()
1839 *
1840 *FUNCTION:
1841 * This function is called to process MLM_START_REQ message
1842 * from SME
1843 *
1844 *LOGIC:
1845 * 1) MLME receives LIM_MLM_START_REQ from LIM
1846 * 2) MLME sends WDA_ADD_BSS_REQ to HAL
1847 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
1848 * MLME now waits for HAL to send WDA_ADD_BSS_RSP
1849 *
1850 *ASSUMPTIONS:
1851 *
1852 *NOTE:
1853 *
1854 * @param pMac Pointer to Global MAC structure
1855 * @param *pMsgBuf A pointer to the MLM message buffer
1856 * @return None
1857 */
1858
1859static void
1860limProcessMlmStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1861{
1862 tLimMlmStartReq *pMlmStartReq;
1863 tLimMlmStartCnf mlmStartCnf;
1864 tpPESession psessionEntry = NULL;
1865
1866 if(pMsgBuf == NULL)
1867 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001868 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 return;
1870 }
1871
1872 pMlmStartReq = (tLimMlmStartReq *) pMsgBuf;
1873 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmStartReq->sessionId))==NULL)
1874 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001875 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 mlmStartCnf.resultCode = eSIR_SME_REFUSED;
1877 goto end;
1878 }
1879
1880 if (psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE)
1881 {
1882 /**
1883 * Should not have received Start req in states other than idle.
1884 * Return Start confirm with failure code.
1885 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001886 PELOGE(limLog(pMac, LOGE, FL("received unexpected MLM_START_REQ in state %X"),psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
1888 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1889 goto end;
1890 }
1891
1892 #if 0
1893 if (cfgSetInt(pMac, WNI_CFG_CURRENT_CHANNEL, pMlmStartReq->channelNumber)!= eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001894 limLog(pMac, LOGP, FL("could not set CURRENT_CHANNEL at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001895
1896 pMac->lim.gLimCurrentChannelId = pMlmStartReq->channelNumber;
1897 #endif //TO SUPPORT BT-AMP
1898
1899
1900 // Update BSSID & SSID at CFG database
1901 #if 0 //We are not using the BSSID and SSID from the config file, instead we are reading form the session table
1902 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pMlmStartReq->bssId, sizeof(tSirMacAddr))
1903 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001904 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001905
1906
1907
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301908 vos_mem_copy( pMac->lim.gLimCurrentBssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 pMlmStartReq->bssId,
1910 sizeof(tSirMacAddr));
1911 #endif //TO SUPPORT BT-AMP
1912
1913 #if 0
1914 if (cfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *) &pMlmStartReq->ssId.ssId, pMlmStartReq->ssId.length)
1915 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001916 limLog(pMac, LOGP, FL("could not update SSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 #endif //To SUPPORT BT-AMP
1918
1919
1920 // pMac->lim.gLimCurrentSSID.length = pMlmStartReq->ssId.length;
1921
1922 #if 0
1923 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
1924 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
1925 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
1926 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001927 limLog(pMac, LOGP, FL("could not update Operational Rateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 #endif //TO SUPPORT BT-AMP
1929
1930
Jeff Johnson295189b2012-06-20 16:38:30 -07001931
Jeff Johnson295189b2012-06-20 16:38:30 -07001932#if 0 // Periodic timer for remove WPS PBC proble response entry in PE is disbaled now.
1933 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1934 {
1935 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_FALSE)
1936 {
1937 if (tx_timer_create(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer,
1938 "PS OVERLAP Timer",
1939 limWPSOverlapTimerHandler,
1940 SIR_LIM_WPS_OVERLAP_TIMEOUT, // expiration_input
1941 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // initial_ticks
1942 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // reschedule_ticks
1943 TX_AUTO_ACTIVATE /* TX_NO_ACTIVATE*/) != TX_SUCCESS)
1944 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001945 limLog(pMac, LOGP, FL("failed to create WPS overlap Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 }
1947
1948 pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId = pMlmStartReq->sessionId;
1949 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001950 limLog(pMac, LOGE, FL("Create WPS overlap Timer, session=%d"), pMlmStartReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
1952 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
1953 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001954 limLog(pMac, LOGP, FL("tx_timer_activate failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
1956 }
1957 }
1958#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001959
1960
1961
1962 mlmStartCnf.resultCode = limMlmAddBss(pMac, pMlmStartReq,psessionEntry);
1963
1964end:
1965 /* Update PE session Id */
1966 mlmStartCnf.sessionId = pMlmStartReq->sessionId;
1967
1968 /// Free up buffer allocated for LimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301969 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
1971 //
1972 // Respond immediately to LIM, only if MLME has not been
1973 // successfully able to send WDA_ADD_BSS_REQ to HAL.
1974 // Else, LIM_MLM_START_CNF will be sent after receiving
1975 // WDA_ADD_BSS_RSP from HAL
1976 //
1977 if( eSIR_SME_SUCCESS != mlmStartCnf.resultCode )
1978 limPostSmeMessage(pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf);
1979} /*** limProcessMlmStartReq() ***/
1980
1981
1982/*
1983* This function checks if Scan is allowed or not.
1984* It checks each session and if any session is not in the normal state,
1985* it will return false.
1986* Note: BTAMP_STA can be in LINK_EST as well as BSS_STARTED State, so
1987* both cases are handled below.
1988*/
1989
1990static tANI_U8 __limMlmScanAllowed(tpAniSirGlobal pMac)
1991{
1992 int i;
1993
Jeff Johnson43971f52012-07-17 12:26:56 -07001994 if(pMac->lim.gLimMlmState != eLIM_MLM_IDLE_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 {
1996 return FALSE;
1997 }
1998 for(i =0; i < pMac->lim.maxBssId; i++)
1999 {
2000 if(pMac->lim.gpSession[i].valid == TRUE)
2001 {
2002 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
2003 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
2004 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) )||
2005
2006 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
2007 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
2008 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2009 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
2011 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
2012 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
2013 && (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 ))
2015 {
2016 return FALSE;
2017
2018 }
2019 }
2020 }
2021
2022 return TRUE;
2023}
2024
2025
2026
2027/**
2028 * limProcessMlmScanReq()
2029 *
2030 *FUNCTION:
2031 * This function is called to process MLM_SCAN_REQ message
2032 * from SME
2033 *
2034 *LOGIC:
2035 *
2036 *ASSUMPTIONS:
2037 *
2038 *NOTE:
2039 *
2040 * @param pMac Pointer to Global MAC structure
2041 * @param *pMsgBuf A pointer to the MLM message buffer
2042 * @return None
2043 */
2044
2045static void
2046limProcessMlmScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2047{
2048 tLimMlmScanCnf mlmScanCnf;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002049 tANI_U8 i = 0;
2050 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002051
2052 if (pMac->lim.gLimSystemInScanLearnMode)
2053 {
2054 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002055 FL("Sending START_SCAN from LIM while one req is pending"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302056 vos_mem_free(pMsgBuf);
Madan Mohan Koyyalamudid4b301b2012-10-11 14:15:54 -07002057 /*Send back a failure*/
2058 mlmScanCnf.resultCode = eSIR_SME_SCAN_FAILED;
2059 mlmScanCnf.scanResultLength = 0;
2060 limPostSmeMessage(pMac,
2061 LIM_MLM_SCAN_CNF,
2062 (tANI_U32 *) &mlmScanCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 return;
2064 }
2065
2066 if(__limMlmScanAllowed(pMac) &&
2067 (((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels != 0))
2068
2069 {
2070 /// Hold onto SCAN REQ criteria
2071 pMac->lim.gpLimMlmScanReq = (tLimMlmScanReq *) pMsgBuf;
2072
Abhishek Singh127a8442014-12-15 17:31:27 +05302073 limLog(pMac, LOG1, FL("Number of channels to scan are %d "),
2074 pMac->lim.gpLimMlmScanReq->channelList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
2076 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2077
2078 if (pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
2079 pMac->lim.gLimMlmState = eLIM_MLM_WT_PROBE_RESP_STATE;
2080 else // eSIR_PASSIVE_SCAN
2081 pMac->lim.gLimMlmState = eLIM_MLM_PASSIVE_SCAN_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002082 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002083
2084 pMac->lim.gLimSystemInScanLearnMode = 1;
2085
Maleka Vinayd500cd42012-12-10 12:37:09 -08002086 /* temporary fix to handle case where NOA duration calculation is incorrect
2087 * for scanning on DFS channels */
2088
2089 pMac->lim.gTotalScanDuration = 0;
2090
2091 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
2092 {
2093 /*
2094 * Could not get max channel value
2095 * from CFG. Log error.
2096 */
Abhishek Singh95f7b252015-10-14 14:15:35 +05302097 limLog(pMac, LOGP,
2098 FL("could not retrieve passive max channel value use def"));
2099 /* use a default value */
2100 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002101 }
2102
2103 for (i = 0; i < pMac->lim.gpLimMlmScanReq->channelList.numChannels; i++) {
2104 tANI_U8 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[i];
2105
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05302106 if (pMac->miracast_mode) {
2107 pMac->lim.gTotalScanDuration += (DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
2108 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST);
2109 } else if (limActiveScanAllowed(pMac, channelNum)) {
Maleka Vinayd500cd42012-12-10 12:37:09 -08002110 /* Use min + max channel time to calculate the total duration of scan */
2111 pMac->lim.gTotalScanDuration += pMac->lim.gpLimMlmScanReq->minChannelTime + pMac->lim.gpLimMlmScanReq->maxChannelTime;
2112 } else {
2113 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
2114 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
2115 */
2116 pMac->lim.gTotalScanDuration += val;
2117 }
2118 }
2119
2120 /* Adding an overhead of 5ms to account for the scan messaging delays */
2121 pMac->lim.gTotalScanDuration += 5;
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 limSetScanMode(pMac);
2123 }
2124 else
2125 {
2126 /**
2127 * Should not have received SCAN req in other states
2128 * OR should not have received LIM_MLM_SCAN_REQ with
2129 * zero number of channels
2130 * Log error
2131 */
2132 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302133 FL("received unexpected MLM_SCAN_REQ in state %d OR zero number of channels: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 pMac->lim.gLimMlmState, ((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels);
2135 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2136
2137 /// Free up buffer allocated for
2138 /// pMac->lim.gLimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302139 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002140
2141 /// Return Scan confirm with INVALID_PARAMETERS
2142
2143 mlmScanCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2144 mlmScanCnf.scanResultLength = 0;
2145 limPostSmeMessage(pMac,
2146 LIM_MLM_SCAN_CNF,
2147 (tANI_U32 *) &mlmScanCnf);
2148 }
2149} /*** limProcessMlmScanReq() ***/
2150
Jeff Johnsone7245742012-09-05 17:12:55 -07002151#ifdef FEATURE_OEM_DATA_SUPPORT
2152static void limProcessMlmOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2153{
2154 tLimMlmOemDataRsp* pMlmOemDataRsp;
2155
2156 if (((pMac->lim.gLimMlmState == eLIM_MLM_IDLE_STATE) ||
2157 (pMac->lim.gLimMlmState == eLIM_MLM_JOINED_STATE) ||
2158 (pMac->lim.gLimMlmState == eLIM_MLM_AUTHENTICATED_STATE) ||
2159 (pMac->lim.gLimMlmState == eLIM_MLM_BSS_STARTED_STATE) ||
2160 (pMac->lim.gLimMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)))
2161 {
2162 //Hold onto the oem data request criteria
2163 pMac->lim.gpLimMlmOemDataReq = (tLimMlmOemDataReq*)pMsgBuf;
2164
2165 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2166
2167 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
2168
2169 //Now request for link suspension
2170 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, limSetOemDataReqMode, NULL);
2171 }
2172 else
2173 {
2174 /**
2175 * Should not have received oem data req in other states
2176 * Log error
2177 */
2178
Sushant Kaushik1b645382014-10-13 16:39:36 +05302179 PELOGW(limLog(pMac, LOGW, FL("OEM_DATA: unexpected LIM_MLM_OEM_DATA_REQ in invalid state %d"),pMac->lim.gLimMlmState);)
Jeff Johnsone7245742012-09-05 17:12:55 -07002180
2181 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2182
2183 /// Free up buffer allocated
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302184 vos_mem_free(pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07002185
2186 /// Return Meas confirm with INVALID_PARAMETERS
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302187 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
2188 if ( pMlmOemDataRsp != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002189 {
2190 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302191 vos_mem_free(pMlmOemDataRsp);
Jeff Johnsone7245742012-09-05 17:12:55 -07002192 }
2193 else
2194 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002195 limLog(pMac, LOGP, FL("Could not allocate memory for pMlmOemDataRsp"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002196 return;
2197 }
2198 }
2199
2200 return;
2201}
2202#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07002203
2204
2205/**
2206 * limProcessMlmPostJoinSuspendLink()
2207 *
2208 *FUNCTION:
2209 * This function is called after the suspend link while joining
2210 * off channel.
2211 *
2212 *LOGIC:
2213 * Check for suspend state.
2214 * If success, proceed with setting link state to recieve the
2215 * probe response/beacon from intended AP.
2216 * Switch to the APs channel.
2217 * On an error case, send the MLM_JOIN_CNF with error status.
2218 *
2219 *ASSUMPTIONS:
2220 *
2221 *NOTE:
2222 *
2223 * @param pMac Pointer to Global MAC structure
2224 * @param status status of suspend link.
2225 * @param ctx passed while calling suspend link(psessionEntry)
2226 * @return None
2227 */
2228static void
2229limProcessMlmPostJoinSuspendLink(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *ctx)
2230{
Jeff Johnsone7245742012-09-05 17:12:55 -07002231 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 tLimMlmJoinCnf mlmJoinCnf;
2233 tpPESession psessionEntry = (tpPESession)ctx;
2234 tSirLinkState linkState;
2235
2236 if( eHAL_STATUS_SUCCESS != status )
2237 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302238 limLog(pMac, LOGE, FL("Sessionid %d Suspend link(NOTIFY_BSS) failed. "
2239 "still proceeding with join"),psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 }
2241 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2242 psessionEntry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002243 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002244
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302245 limLog(pMac, LOG1, FL("Sessionid %d prev lim state %d new lim state %d "
2246 "systemrole = %d"), psessionEntry->peSessionId,
2247 psessionEntry->limPrevMlmState,
2248 psessionEntry->limMlmState,psessionEntry->limSystemRole);
2249
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
2251
2252 //assign appropriate sessionId to the timer object
2253 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId = psessionEntry->peSessionId;
2254
2255 linkState = ((psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) ? eSIR_LINK_BTAMP_PREASSOC_STATE : eSIR_LINK_PREASSOC_STATE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002256 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: linkState:%d"),linkState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 if (limSetLinkState(pMac, linkState,
2259 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,
2260 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2261 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302262 limLog(pMac, LOGE,
2263 FL("SessionId:%d limSetLinkState to eSIR_LINK_PREASSOC_STATE"
2264 " Failed!!"),psessionEntry->peSessionId);
2265 limPrintMacAddr(pMac,
2266 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002268 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
2269 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 goto error;
2271 }
2272
2273 /** Derive channel from BSS description and store it in the CFG */
2274 // chanNum = pMac->lim.gpLimMlmJoinReq->bssDescription.channelId;
2275
2276 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07002277 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 //store the channel switch sessionEntry in the lim global var
2279 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_JOIN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002280#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002281 psessionEntry->pLimMlmReassocRetryReq = NULL;
2282#endif
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302283
2284#ifdef FEATURE_WLAN_DIAG_SUPPORT
2285 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2286 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_JOIN);
2287#endif
2288
Dino Myclea7f18452014-04-24 08:55:31 +05302289 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: suspend link success(%d) "
2290 "on sessionid: %d setting channel to: %d with secChanOffset:%d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302291 "and maxtxPower: %d"), status, psessionEntry->peSessionId,
2292 chanNum, secChanOffset, psessionEntry->maxTxPower);
Jeff Johnsone7245742012-09-05 17:12:55 -07002293 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
2295 return;
2296error:
2297 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2298 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
2299 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2300 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2301
2302}
2303
2304
2305
2306/**
2307 * limProcessMlmJoinReq()
2308 *
2309 *FUNCTION:
2310 * This function is called to process MLM_JOIN_REQ message
2311 * from SME
2312 *
2313 *LOGIC:
2314 * 1) Initialize LIM, HAL, DPH
2315 * 2) Configure the BSS for which the JOIN REQ was received
2316 * a) Send WDA_ADD_BSS_REQ to HAL -
2317 * This will identify the BSS that we are interested in
2318 * --AND--
2319 * Add a STA entry for the AP (in a STA context)
2320 * b) Wait for WDA_ADD_BSS_RSP
2321 * c) Send WDA_ADD_STA_REQ to HAL
2322 * This will add the "local STA" entry to the STA table
2323 * 3) Continue as before, i.e,
2324 * a) Send a PROBE REQ
2325 * b) Wait for PROBE RSP/BEACON containing the SSID that
2326 * we are interested in
2327 * c) Then start an AUTH seq
2328 * d) Followed by the ASSOC seq
2329 *
2330 *ASSUMPTIONS:
2331 *
2332 *NOTE:
2333 *
2334 * @param pMac Pointer to Global MAC structure
2335 * @param *pMsgBuf A pointer to the MLM message buffer
2336 * @return None
2337 */
2338
2339static void
2340limProcessMlmJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2341{
2342 tLimMlmJoinCnf mlmJoinCnf;
2343 tANI_U8 sessionId;
2344 tpPESession psessionEntry;
2345
2346 sessionId = ((tpLimMlmJoinReq)pMsgBuf)->sessionId;
2347
2348 if((psessionEntry = peFindSessionBySessionId(pMac,sessionId))== NULL)
2349 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302350 limLog(pMac, LOGE, FL("SessionId:%d session does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 goto error;
2352 }
2353
2354 if (( (psessionEntry->limSystemRole != eLIM_AP_ROLE ) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE )) &&
2355 ( (psessionEntry->limMlmState == eLIM_MLM_IDLE_STATE) ||
2356 (psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE)) &&
2357 (SIR_MAC_GET_ESS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo) !=
2358 SIR_MAC_GET_IBSS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo)))
2359 {
2360 #if 0
2361 if (pMac->lim.gpLimMlmJoinReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302362 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 #endif //TO SUPPORT BT-AMP , review 23sep
2364
2365 /// Hold onto Join request parameters
2366
2367 psessionEntry->pLimMlmJoinReq =(tpLimMlmJoinReq) pMsgBuf;
2368
2369 if( isLimSessionOffChannel(pMac, sessionId) )
2370 {
2371 //suspend link
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302372 limLog(pMac, LOG1, FL("Suspend link as LimSession on sessionid %d"
2373 "is off channel"),sessionId);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302374 if (limIsLinkSuspended(pMac))
2375 {
2376 limLog(pMac, LOGE, FL("Link is already suspended for some other"
2377 " reason. Return failure on sessionId:%d"), sessionId);
2378 goto error;
2379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
2381 limProcessMlmPostJoinSuspendLink, (tANI_U32*)psessionEntry );
2382 }
2383 else
2384 {
2385 //No need to suspend link.
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302386 limLog(pMac,LOG1,"SessionId:%d Join request on current channel",
2387 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 limProcessMlmPostJoinSuspendLink( pMac, eHAL_STATUS_SUCCESS,
2389 (tANI_U32*) psessionEntry );
2390 }
2391
2392 return;
2393 }
2394 else
2395 {
2396 /**
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302397 * Should not have received JOIN req in states other than
2398 * Idle state or on AP.
2399 * Return join confirm with invalid parameters code.
2400 */
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302401 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302402 FL("SessionId:%d Unexpected Join request for role %d state %d "),
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302403 psessionEntry->peSessionId,psessionEntry->limSystemRole,
2404 psessionEntry->limMlmState);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302405 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 }
2407
2408error:
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302409 vos_mem_free(pMsgBuf);
2410 if (psessionEntry != NULL)
2411 psessionEntry->pLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002412
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302413 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2414 mlmJoinCnf.sessionId = sessionId;
2415 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2416 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417} /*** limProcessMlmJoinReq() ***/
2418
2419
2420
2421/**
2422 * limProcessMlmAuthReq()
2423 *
2424 *FUNCTION:
2425 * This function is called to process MLM_AUTH_REQ message
2426 * from SME
2427 *
2428 *LOGIC:
2429 *
2430 *ASSUMPTIONS:
2431 *
2432 *NOTE:
2433 *
2434 * @param pMac Pointer to Global MAC structure
2435 * @param *pMsgBuf A pointer to the MLM message buffer
2436 * @return None
2437 */
2438
2439static void
2440limProcessMlmAuthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2441{
2442 tANI_U32 numPreAuthContexts;
2443 tSirMacAddr currentBssId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 tLimMlmAuthCnf mlmAuthCnf;
2445 struct tLimPreAuthNode *preAuthNode;
2446 tpDphHashNode pStaDs;
2447 tANI_U8 sessionId;
2448 tpPESession psessionEntry;
2449
2450 if(pMsgBuf == NULL)
2451 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002452 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 return;
2454 }
2455
2456 pMac->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) pMsgBuf;
2457 sessionId = pMac->lim.gpLimMlmAuthReq->sessionId;
2458 if((psessionEntry= peFindSessionBySessionId(pMac,sessionId) )== NULL)
2459 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302460 limLog(pMac, LOGP, FL("SessionId:%d Session Does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 return;
2462 }
2463
Abhishek Singhcd09b562013-12-24 16:02:20 +05302464 limLog(pMac, LOG1,FL("Process Auth Req on sessionID %d Systemrole %d"
2465 "mlmstate %d from: "MAC_ADDRESS_STR" with authtype %d"), sessionId,
2466 psessionEntry->limSystemRole,psessionEntry->limMlmState,
2467 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr),
2468 pMac->lim.gpLimMlmAuthReq->authType);
2469
2470
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 /**
2472 * Expect Auth request only when:
2473 * 1. STA joined/associated with a BSS or
2474 * 2. STA is in IBSS mode
2475 * and STA is going to authenticate with a unicast
2476 * adress and requested authentication algorithm is
2477 * supported.
2478 */
2479 #if 0
2480 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2481 eSIR_SUCCESS)
2482 {
2483 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002484 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 }
2486 #endif //To SuppoRT BT-AMP
2487
2488 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2489
2490 if (((((psessionEntry->limSystemRole== eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2491 ((psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) ||
2492 (psessionEntry->limMlmState ==
2493 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
2494 ((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) &&
2495 (psessionEntry->limMlmState == eLIM_MLM_BSS_STARTED_STATE))) &&
2496 (limIsGroupAddr(pMac->lim.gpLimMlmAuthReq->peerMacAddr)
2497 == false) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 (limIsAuthAlgoSupported(
2499 pMac,
2500 pMac->lim.gpLimMlmAuthReq->authType,
2501 psessionEntry) == true)
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 )
2503 {
2504 /**
2505 * This is a request for pre-authentication.
2506 * Check if there exists context already for
Jeff Johnson1250df42012-12-10 14:31:52 -08002507 * the requested peer OR
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 * if this request is for the AP we're currently
2509 * associated with.
2510 * If yes, return auth confirm immediately when
2511 * requested auth type is same as the one used before.
2512 */
2513 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2514 (psessionEntry->limMlmState ==
2515 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2516 (((pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) != NULL) &&
2517 (pMac->lim.gpLimMlmAuthReq->authType ==
2518 pStaDs->mlmStaContext.authType)) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302519 (vos_mem_compare(pMac->lim.gpLimMlmAuthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 currentBssId,
2521 sizeof(tSirMacAddr)) )) ||
2522 (((preAuthNode =
2523 limSearchPreAuthList(
2524 pMac,
2525 pMac->lim.gpLimMlmAuthReq->peerMacAddr)) != NULL) &&
2526 (preAuthNode->authType ==
2527 pMac->lim.gpLimMlmAuthReq->authType)))
2528 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302529 limLog(pMac, LOG2,
2530 FL("Already have pre-auth context with peer: "MAC_ADDRESS_STR),
2531 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002532
2533 mlmAuthCnf.resultCode = (tSirResultCodes)
2534 eSIR_MAC_SUCCESS_STATUS;
2535
2536
2537 goto end;
2538 }
2539 else
2540 {
2541 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
2542 (tANI_U32 *) &numPreAuthContexts) != eSIR_SUCCESS)
2543 {
2544 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002545 FL("Could not retrieve NumPreAuthLimit from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
2548 if (pMac->lim.gLimNumPreAuthContexts == numPreAuthContexts)
2549 {
2550 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002551 FL("Number of pre-auth reached max limit"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
2553 /// Return Auth confirm with reject code
2554 mlmAuthCnf.resultCode =
2555 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
2556
2557 goto end;
2558 }
2559 }
2560
2561 // Delete pre-auth node if exists
2562 if (preAuthNode)
2563 limDeletePreAuthNode(pMac,
2564 pMac->lim.gpLimMlmAuthReq->peerMacAddr);
2565
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2567 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002568 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
Jeff Johnsone7245742012-09-05 17:12:55 -07002570 //assign appropriate sessionId to the timer object
2571 pMac->lim.limTimers.gLimAuthFailureTimer.sessionId = sessionId;
Sushant Kaushik9e923872015-04-02 17:09:31 +05302572 /* assign appropriate sessionId to the timer object */
2573 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId = sessionId;
2574 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07002575 // Activate Auth failure timer
2576 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_AUTH_FAIL_TIMER));
Paul Zhang83289792017-02-28 18:58:52 +08002577
2578 limDoSendAuthMgmtFrame(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 return;
2580 }
2581 else
2582 {
2583 /**
2584 * Unexpected auth request.
2585 * Return Auth confirm with Invalid parameters code.
2586 */
2587 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2588
2589 goto end;
2590 }
2591
2592end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302593 vos_mem_copy((tANI_U8 *) &mlmAuthCnf.peerMacAddr,
2594 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2595 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002596
2597 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
2598 mlmAuthCnf.sessionId = sessionId;
2599
2600 /// Free up buffer allocated
2601 /// for pMac->lim.gLimMlmAuthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302602 vos_mem_free( pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 pMac->lim.gpLimMlmAuthReq = NULL;
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302604 limLog(pMac,LOG1,"SessionId:%d LimPostSme LIM_MLM_AUTH_CNF ",sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 limPostSmeMessage(pMac, LIM_MLM_AUTH_CNF, (tANI_U32 *) &mlmAuthCnf);
2606} /*** limProcessMlmAuthReq() ***/
2607
2608
2609
2610/**
2611 * limProcessMlmAssocReq()
2612 *
2613 *FUNCTION:
2614 * This function is called to process MLM_ASSOC_REQ message
2615 * from SME
2616 *
2617 *LOGIC:
2618 *
2619 *ASSUMPTIONS:
2620 *
2621 *NOTE:
2622 *
2623 * @param pMac Pointer to Global MAC structure
2624 * @param *pMsgBuf A pointer to the MLM message buffer
2625 * @return None
2626 */
2627
2628static void
2629limProcessMlmAssocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2630{
2631 tSirMacAddr currentBssId;
2632 tLimMlmAssocReq *pMlmAssocReq;
2633 tLimMlmAssocCnf mlmAssocCnf;
2634 tpPESession psessionEntry;
2635 // tANI_U8 sessionId;
2636
2637 if(pMsgBuf == NULL)
2638 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002639 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return;
2641 }
2642 pMlmAssocReq = (tLimMlmAssocReq *) pMsgBuf;
2643
2644 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmAssocReq->sessionId) )== NULL)
2645 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302646 limLog(pMac, LOGP,FL("SessionId:%d Session Does not exist"),
2647 pMlmAssocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302648 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 return;
2650 }
2651
Abhishek Singhcd09b562013-12-24 16:02:20 +05302652 limLog(pMac, LOG1,FL("Process Assoc Req on sessionID %d Systemrole %d"
2653 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmAssocReq->sessionId,
2654 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2655 MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));
2656
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 #if 0
2658 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2659 eSIR_SUCCESS)
2660 {
2661 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002662 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 }
2664 #endif //TO SUPPORT BT-AMP
2665 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2666
2667 if ( (psessionEntry->limSystemRole != eLIM_AP_ROLE && psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE) &&
2668 (psessionEntry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302669 (vos_mem_compare(pMlmAssocReq->peerMacAddr, currentBssId, sizeof(tSirMacAddr))) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002671
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 /// map the session entry pointer to the AssocFailureTimer
2673 pMac->lim.limTimers.gLimAssocFailureTimer.sessionId = pMlmAssocReq->sessionId;
2674
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2676 psessionEntry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002677 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302678 limLog(pMac,LOG1,"SessionId:%d Sending Assoc_Req Frame",
2679 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680
2681 /// Prepare and send Association request frame
2682 limSendAssocReqMgmtFrame(pMac, pMlmAssocReq,psessionEntry);
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302683#ifdef FEATURE_WLAN_DIAG_SUPPORT
2684 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_REQ_EVENT, psessionEntry,
2685 eSIR_SUCCESS, eSIR_SUCCESS);
2686#endif
2687
Jeff Johnson295189b2012-06-20 16:38:30 -07002688
2689 //Set the link state to postAssoc, so HW can start receiving frames from AP.
2690 if ((psessionEntry->bssType == eSIR_BTAMP_STA_MODE)||
2691 ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE) && (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
2692 {
2693 if(limSetLinkState(pMac, eSIR_LINK_BTAMP_POSTASSOC_STATE, currentBssId,
2694 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002695 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002697 /// Start association failure timer
2698 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
2699 if (tx_timer_activate(&pMac->lim.limTimers.gLimAssocFailureTimer)
2700 != TX_SUCCESS)
2701 {
2702 /// Could not start Assoc failure timer.
2703 // Log error
2704 limLog(pMac, LOGP,
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302705 FL("SessionId:%d could not start Association failure timer"),
2706 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002707 // Cleanup as if assoc timer expired
2708 limProcessAssocFailureTimeout(pMac,LIM_ASSOC );
2709
2710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002711
2712 return;
2713 }
2714 else
2715 {
2716 /**
2717 * Received Association request either in invalid state
2718 * or to a peer MAC entity whose address is different
2719 * from one that STA is currently joined with or on AP.
2720 * Return Assoc confirm with Invalid parameters code.
2721 */
2722
2723 // Log error
2724 PELOGW(limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302725 FL("received unexpected MLM_ASSOC_CNF in state %d for role=%d, MAC addr= "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302726 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2727 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2729
2730 mlmAssocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2731 mlmAssocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2732
2733 goto end;
2734 }
2735
2736end:
2737 /* Update PE session Id*/
2738 mlmAssocCnf.sessionId = pMlmAssocReq->sessionId;
2739
2740 /// Free up buffer allocated for assocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302741 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002742
2743 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
2744} /*** limProcessMlmAssocReq() ***/
2745
2746
2747
2748/**
2749 * limProcessMlmReassocReq()
2750 *
2751 *FUNCTION:
2752 * This function is called to process MLM_REASSOC_REQ message
2753 * from SME
2754 *
2755 *LOGIC:
2756 *
2757 *ASSUMPTIONS:
2758 *
2759 *NOTE:
2760 *
2761 * @param pMac Pointer to Global MAC structure
2762 * @param *pMsgBuf A pointer to the MLM message buffer
2763 * @return None
2764 */
2765
2766static void
2767limProcessMlmReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2768{
Jeff Johnsone7245742012-09-05 17:12:55 -07002769 tANI_U8 chanNum, secChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 struct tLimPreAuthNode *pAuthNode;
2771 tLimMlmReassocReq *pMlmReassocReq;
2772 tLimMlmReassocCnf mlmReassocCnf;
2773 tpPESession psessionEntry;
2774
2775 if(pMsgBuf == NULL)
2776 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002777 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 return;
2779 }
2780
2781 pMlmReassocReq = (tLimMlmReassocReq *) pMsgBuf;
Abhishek Singhcd09b562013-12-24 16:02:20 +05302782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmReassocReq->sessionId)) == NULL)
2784 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302785 limLog(pMac, LOGE,FL("Session Does not exist for given sessionId %d"),
2786 pMlmReassocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302787 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 return;
2789 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302790
2791 limLog(pMac, LOG1,FL("Process ReAssoc Req on sessionID %d Systemrole %d"
2792 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmReassocReq->sessionId,
2793 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2794 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 if (((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) &&
2797 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
2798 {
2799 if (psessionEntry->pLimMlmReassocReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302800 vos_mem_free(psessionEntry->pLimMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002801
2802 /* Hold Re-Assoc request as part of Session, knock-out pMac */
2803 /// Hold onto Reassoc request parameters
2804 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
2805
2806 // See if we have pre-auth context with new AP
2807 pAuthNode = limSearchPreAuthList(pMac, psessionEntry->limReAssocbssId);
2808
2809 if (!pAuthNode &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302810 (!vos_mem_compare(pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 psessionEntry->bssId,
2812 sizeof(tSirMacAddr)) ))
2813 {
2814 // Either pre-auth context does not exist AND
2815 // we are not reassociating with currently
2816 // associated AP.
2817 // Return Reassoc confirm with not authenticated
2818 mlmReassocCnf.resultCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2819 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2820
2821 goto end;
2822 }
2823
2824 //assign the sessionId to the timer object
2825 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = pMlmReassocReq->sessionId;
2826
2827 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2828 psessionEntry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002830
2831#if 0
2832 // Update BSSID at CFG database
2833 if (wlan_cfgSetStr(pMac, WNI_CFG_BSSID,
2834 pMac->lim.gLimReassocBssId,
2835 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
2836 {
2837 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002838 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 }
2840#endif //TO SUPPORT BT-AMP
2841
2842 /* Copy Global Reassoc ID*/
2843 // sirCopyMacAddr(psessionEntry->reassocbssId,pMac->lim.gLimReAssocBssId);
2844
2845 /**
2846 * Derive channel from BSS description and
2847 * store it at CFG.
2848 */
2849
2850 chanNum = psessionEntry->limReassocChannelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07002851 secChannelOffset = psessionEntry->reAssocHtSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002852
2853 /* To Support BT-AMP .. read channel number from psessionEntry*/
2854 //chanNum = psessionEntry->currentOperChannel;
2855
2856 // Apply previously set configuration at HW
2857 limApplyConfiguration(pMac,psessionEntry);
2858
2859 //store the channel switch sessionEntry in the lim global var
2860 /* We have already saved the ReAssocreq Pointer abobe */
2861 //psessionEntry->pLimReAssocReq = (void *)pMlmReassocReq;
2862 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_REASSOC;
2863
Jeff Johnsone7245742012-09-05 17:12:55 -07002864 /** Switch channel to the new Operating channel for Reassoc*/
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302865
2866#ifdef FEATURE_WLAN_DIAG_SUPPORT
2867 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2868 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_REASSOC);
2869#endif
2870
Jeff Johnsone7245742012-09-05 17:12:55 -07002871 limSetChannel(pMac, chanNum, secChannelOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002872
2873 return;
2874 }
2875 else
2876 {
2877 /**
2878 * Received Reassoc request in invalid state or
2879 * in AP role.Return Reassoc confirm with Invalid
2880 * parameters code.
2881 */
2882
2883 // Log error
Abhishek Singhcd09b562013-12-24 16:02:20 +05302884 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302885 FL("received unexpected MLM_REASSOC_CNF in state %d for role=%d, "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302886 "MAC addr= "
2887 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2888 psessionEntry->limSystemRole,
2889 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2891
2892 mlmReassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2893 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2894
2895 goto end;
2896 }
2897
2898end:
2899 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2900 /* Update PE sessio Id*/
2901 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
2902 /// Free up buffer allocated for reassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302903 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 psessionEntry->pLimReAssocReq = NULL;
2905
2906 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2907} /*** limProcessMlmReassocReq() ***/
2908
2909
2910static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08002911limProcessMlmDisassocReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07002912{
2913 tANI_U16 aid;
2914 tSirMacAddr currentBssId;
2915 tpDphHashNode pStaDs;
2916 tLimMlmDisassocReq *pMlmDisassocReq;
2917 tLimMlmDisassocCnf mlmDisassocCnf;
2918 tpPESession psessionEntry;
2919 extern tANI_BOOLEAN sendDisassocFrame;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302920 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
2921 tANI_U32 *pMsg;
2922 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07002923
2924 if(eHAL_STATUS_SUCCESS != suspendStatus)
2925 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002926 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002927#if 0
2928 //It can ignore the status and proceed with the disassoc processing.
2929 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
2930 goto end;
2931#endif
2932 }
2933
2934 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
2935
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
2937 {
2938
Abhishek Singhcd09b562013-12-24 16:02:20 +05302939 limLog(pMac, LOGE,
2940 FL("session does not exist for given sessionId %d"),
2941 pMlmDisassocReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2943 goto end;
2944 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302945 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d Systemrole %d"
2946 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
2947 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2948 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
2949
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 #if 0
2951 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2952 eSIR_SUCCESS)
2953 {
2954 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002955 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 }
2957 #endif //BT-AMP Support
2958 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2959
2960 switch (psessionEntry->limSystemRole)
2961 {
2962 case eLIM_STA_ROLE:
2963 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302964 if ( !vos_mem_compare(pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 currentBssId,
2966 sizeof(tSirMacAddr)) )
2967 {
2968 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05302969 FL("received MLM_DISASSOC_REQ with invalid BSS id from: "
2970 MAC_ADDRESS_STR),
2971 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002972
2973 /// Prepare and Send LIM_MLM_DISASSOC_CNF
2974
2975 mlmDisassocCnf.resultCode =
2976 eSIR_SME_INVALID_PARAMETERS;
2977
2978 goto end;
2979 }
2980
2981 break;
2982
2983 case eLIM_STA_IN_IBSS_ROLE:
2984
2985 break;
2986
2987 default: // eLIM_AP_ROLE
2988
2989 // Fall through
2990 break;
2991
2992 } // end switch (psessionEntry->limSystemRole)
2993
2994 /**
2995 * Check if there exists a context for the peer entity
2996 * to be disassociated with.
2997 */
2998 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2999 if ((pStaDs == NULL) ||
3000 (pStaDs &&
3001 ((pStaDs->mlmStaContext.mlmState !=
3002 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3003 (pStaDs->mlmStaContext.mlmState !=
3004 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
3005 (pStaDs->mlmStaContext.mlmState !=
3006 eLIM_MLM_ASSOCIATED_STATE))))
3007 {
3008 /**
3009 * Received LIM_MLM_DISASSOC_REQ for STA that does not
3010 * have context or in some transit state.
3011 * Log error
3012 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303013 limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303014 FL("received MLM_DISASSOC_REQ for STA that either has no context "
3015 "or in some transit state, Addr= "
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303016 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3017 if (pStaDs != NULL)
3018 limLog(pMac, LOGE, FL("Sta MlmState : %d"),
3019 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303021 /*
3022 * Disassociation response due to
3023 * host triggered disassociation
3024 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303026 pSirSmeDisassocRsp = vos_mem_malloc(sizeof(tSirSmeDisassocRsp));
3027 if ( NULL == pSirSmeDisassocRsp )
3028 {
3029 // Log error
3030 limLog(pMac, LOGP,
3031 FL("call to AllocateMemory failed for eWNI_SME_DISASSOC_RSP"));
3032 return;
3033 }
3034 limLog(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
3035 "retCode: %d for "MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3036 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3037 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
3038 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
3039 pSirSmeDisassocRsp->sessionId = pMlmDisassocReq->sessionId;
3040 pSirSmeDisassocRsp->transactionId = 0;
3041 pSirSmeDisassocRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003042
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303043 pBuf = (tANI_U8 *) pSirSmeDisassocRsp->peerMacAddr;
3044 vos_mem_copy( pBuf, pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr));
3045
3046 pMsg = (tANI_U32*) pSirSmeDisassocRsp;
3047
3048 limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
3049 (tANI_U32*) pMsg );
3050 return;
3051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 }
3053
3054 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3055 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3056 pMlmDisassocReq->reasonCode;
3057 pStaDs->mlmStaContext.cleanupTrigger = pMlmDisassocReq->disassocTrigger;
Mukul Sharma91947a22014-06-09 11:07:51 +05303058 /** Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3059 * This is to address the issue of race condition between
3060 * disconnect request from the HDD and deauth from AP
3061 */
3062 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003063
3064 /// Send Disassociate frame to peer entity
Jeff Johnsone7245742012-09-05 17:12:55 -07003065 if (sendDisassocFrame && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003067 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = pMlmDisassocReq;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303068 if (IS_FW_IN_TX_PATH_FEATURE_ENABLE)
Sandeep Puligilla25728282013-12-01 19:44:14 +05303069 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303070 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Sandeep Puligilla25728282013-12-01 19:44:14 +05303071 pMlmDisassocReq->peerMacAddr,
3072 psessionEntry, FALSE);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303073 /* Send Disassoc CNF and receive path cleanup */
3074 limSendDisassocCnf(pMac);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303075 }
3076 else
3077 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303078 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003079 pMlmDisassocReq->peerMacAddr,
3080 psessionEntry, TRUE);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
3083 else
3084 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003085 /* Disassoc frame is not sent OTA */
3086 sendDisassocFrame = 1;
3087 // Receive path cleanup with dummy packet
3088 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs,psessionEntry))
3089 {
3090 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3091 goto end;
3092 }
3093 // Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303094 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 }
3096
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 return;
3098
3099end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303100 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3101 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3102 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3104 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3105
3106 /* Update PE session ID*/
3107 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3108
3109 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303110 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003111
3112 limPostSmeMessage(pMac,
3113 LIM_MLM_DISASSOC_CNF,
3114 (tANI_U32 *) &mlmDisassocCnf);
3115}
3116
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003117tANI_BOOLEAN limCheckDisassocDeauthAckPending(tpAniSirGlobal pMac,
3118 tANI_U8 *staMac
3119 )
3120{
3121 tLimMlmDisassocReq *pMlmDisassocReq;
3122 tLimMlmDeauthReq *pMlmDeauthReq;
3123 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3124 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3125 if (
3126 (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303127 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003128 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3129 sizeof(tSirMacAddr))))
3130 ||
3131 (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303132 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003133 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303134 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003135 )
3136 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003137 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth ack pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003138 return eANI_BOOLEAN_TRUE;
3139 }
3140 else
3141 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003142 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth Ack not pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003143 return eANI_BOOLEAN_FALSE;
3144 }
3145}
3146
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003147void limCleanUpDisassocDeauthReq(tpAniSirGlobal pMac,
3148 tANI_U8 *staMac,
3149 tANI_BOOLEAN cleanRxPath)
3150{
3151 tLimMlmDisassocReq *pMlmDisassocReq;
3152 tLimMlmDeauthReq *pMlmDeauthReq;
3153 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3154 if (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303155 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003156 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3157 sizeof(tSirMacAddr))))
3158 {
3159 if (cleanRxPath)
3160 {
3161 limProcessDisassocAckTimeout(pMac);
3162 }
3163 else
3164 {
3165 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3166 {
3167 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3168 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303169 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003170 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3171 }
3172 }
3173
3174 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3175 if (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303176 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003177 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
3178 sizeof(tSirMacAddr))))
3179 {
3180 if (cleanRxPath)
3181 {
3182 limProcessDeauthAckTimeout(pMac);
3183 }
3184 else
3185 {
3186 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3187 {
3188 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3189 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303190 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003191 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3192 }
3193 }
3194}
3195
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003196void limProcessDisassocAckTimeout(tpAniSirGlobal pMac)
3197{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303198 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003199 limSendDisassocCnf(pMac);
3200}
3201
Jeff Johnson295189b2012-06-20 16:38:30 -07003202/**
3203 * limProcessMlmDisassocReq()
3204 *
3205 *FUNCTION:
3206 * This function is called to process MLM_DISASSOC_REQ message
3207 * from SME
3208 *
3209 *LOGIC:
3210 *
3211 *ASSUMPTIONS:
3212 *
3213 *NOTE:
3214 *
3215 * @param pMac Pointer to Global MAC structure
3216 * @param *pMsgBuf A pointer to the MLM message buffer
3217 * @return None
3218 */
3219
3220static void
3221limProcessMlmDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3222{
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 tLimMlmDisassocReq *pMlmDisassocReq;
Jeff Johnson295189b2012-06-20 16:38:30 -07003224
3225 if(pMsgBuf == NULL)
3226 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003227 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 return;
3229 }
3230
3231 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05303232
Abhishek Singhcd09b562013-12-24 16:02:20 +05303233 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d "
3234 "from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3235 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003236
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003237 limProcessMlmDisassocReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003238
Jeff Johnson295189b2012-06-20 16:38:30 -07003239} /*** limProcessMlmDisassocReq() ***/
3240
3241static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003242limProcessMlmDeauthReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003243{
3244 tANI_U16 aid;
3245 tSirMacAddr currentBssId;
3246 tpDphHashNode pStaDs;
3247 struct tLimPreAuthNode *pAuthNode;
3248 tLimMlmDeauthReq *pMlmDeauthReq;
3249 tLimMlmDeauthCnf mlmDeauthCnf;
3250 tpPESession psessionEntry;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303251 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
3252 tANI_U8 *pBuf;
3253 tANI_U32 *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003254
3255
3256 if(eHAL_STATUS_SUCCESS != suspendStatus)
3257 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003258 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003259#if 0
3260 //It can ignore the status and proceed with the disassoc processing.
3261 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3262 goto end;
3263#endif
3264 }
3265
3266 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3267
3268 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3269 {
3270
Abhishek Singhcd09b562013-12-24 16:02:20 +05303271 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3272 pMlmDeauthReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303273 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 return;
3275 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303276 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d Systemrole %d"
3277 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3278 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3279 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 #if 0
3281 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3282 eSIR_SUCCESS)
3283 {
3284 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003285 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 }
3287 #endif //SUPPORT BT-AMP
3288 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3289
3290 switch (psessionEntry->limSystemRole)
3291 {
3292 case eLIM_STA_ROLE:
3293 case eLIM_BT_AMP_STA_ROLE:
3294 switch (psessionEntry->limMlmState)
3295 {
3296 case eLIM_MLM_IDLE_STATE:
3297 // Attempting to Deauthenticate
3298 // with a pre-authenticated peer.
3299 // Deauthetiate with peer if there
3300 // exists a pre-auth context below.
3301 break;
3302
3303 case eLIM_MLM_AUTHENTICATED_STATE:
3304 case eLIM_MLM_WT_ASSOC_RSP_STATE:
3305 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303306 if (!vos_mem_compare(pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 currentBssId,
3308 sizeof(tSirMacAddr)) )
3309 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05303310 limLog(pMac, LOGE,
3311 FL("received MLM_DEAUTH_REQ with invalid BSS id "
3312 "Peer MAC: "MAC_ADDRESS_STR " CFG BSSID Addr : "
3313 MAC_ADDRESS_STR),
3314 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr),
3315 MAC_ADDR_ARRAY(currentBssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003316
3317 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3318
3319 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3320
3321 goto end;
3322 }
3323
3324 if ((psessionEntry->limMlmState ==
3325 eLIM_MLM_AUTHENTICATED_STATE) ||
3326 (psessionEntry->limMlmState ==
3327 eLIM_MLM_WT_ASSOC_RSP_STATE))
3328 {
3329 // Send Deauthentication frame
3330 // to peer entity
3331 limSendDeauthMgmtFrame(
3332 pMac,
3333 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003334 pMlmDeauthReq->peerMacAddr,
3335 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003336
3337 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3338 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3339 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003340 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 goto end;
3342 }
3343 else
3344 {
3345 // LINK_ESTABLISED_STATE
3346 // Cleanup RX & TX paths
3347 // below
3348 }
3349
3350 break;
3351
3352 default:
3353
3354 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303355 FL("received MLM_DEAUTH_REQ with in state %d for peer "MAC_ADDRESS_STR),
3356 psessionEntry->limMlmState,MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3358
3359 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3360 mlmDeauthCnf.resultCode =
3361 eSIR_SME_STA_NOT_AUTHENTICATED;
3362
3363 goto end;
3364 }
3365
3366 break;
3367
3368 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303369 limLog(pMac, LOGE,
3370 FL("received MLM_DEAUTH_REQ IBSS Mode "));
3371 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3372 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 default: // eLIM_AP_ROLE
3374 break;
3375
3376 } // end switch (psessionEntry->limSystemRole)
3377
3378 /**
3379 * Check if there exists a context for the peer entity
3380 * to be deauthenticated with.
3381 */
3382 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3383
3384 if (pStaDs == NULL)
3385 {
3386 /// Check if there exists pre-auth context for this STA
3387 pAuthNode = limSearchPreAuthList(pMac,
3388 pMlmDeauthReq->peerMacAddr);
3389
3390 if (pAuthNode == NULL)
3391 {
3392 /**
3393 * Received DEAUTH REQ for a STA that is neither
3394 * Associated nor Pre-authenticated. Log error,
3395 * Prepare and Send LIM_MLM_DEAUTH_CNF
3396 */
3397 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303398 FL("received MLM_DEAUTH_REQ in mlme state %d for STA that "
3399 "does not have context, Addr="MAC_ADDRESS_STR),
3400 psessionEntry->limMlmState,
3401 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003402
3403 mlmDeauthCnf.resultCode =
3404 eSIR_SME_STA_NOT_AUTHENTICATED;
3405 }
3406 else
3407 {
3408 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3409
3410 /// Delete STA from pre-auth STA list
3411 limDeletePreAuthNode(pMac, pMlmDeauthReq->peerMacAddr);
3412
3413 /// Send Deauthentication frame to peer entity
3414 limSendDeauthMgmtFrame(pMac,
3415 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003416 pMlmDeauthReq->peerMacAddr,
3417 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 }
3419
3420 goto end;
3421 }
3422 else if ((pStaDs->mlmStaContext.mlmState !=
3423 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3424 (pStaDs->mlmStaContext.mlmState !=
3425 eLIM_MLM_WT_ASSOC_CNF_STATE))
3426 {
3427 /**
3428 * Received LIM_MLM_DEAUTH_REQ for STA that is n
3429 * some transit state. Log error.
3430 */
3431 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303432 FL("received MLM_DEAUTH_REQ for STA that either has no context or in some transit state, Addr="
3433 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003434
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303435 /*
3436 * Deauthentication response to host triggered
3437 * deauthentication.
3438 */
3439 pSirSmeDeauthRsp = vos_mem_malloc(sizeof(tSirSmeDeauthRsp));
3440 if ( NULL == pSirSmeDeauthRsp )
3441 {
3442 // Log error
3443 limLog(pMac, LOGP,
3444 FL("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003445
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303446 return;
3447 }
3448 limLog(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
3449 "retCode: %d for"MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3450 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3451 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
3452 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
3453 pSirSmeDeauthRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
3454 pSirSmeDeauthRsp->sessionId = pMlmDeauthReq->sessionId;
3455 pSirSmeDeauthRsp->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003456
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303457 pBuf = (tANI_U8 *) pSirSmeDeauthRsp->peerMacAddr;
3458 vos_mem_copy( pBuf, pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr));
3459
3460 pMsg = (tANI_U32*)pSirSmeDeauthRsp;
3461
3462 limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
3463 (tANI_U32*) pMsg );
3464
3465 return;
3466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }
3468
3469 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3470 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3471 pMlmDeauthReq->reasonCode;
3472 pStaDs->mlmStaContext.cleanupTrigger = pMlmDeauthReq->deauthTrigger;
3473
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003474 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = pMlmDeauthReq;
Abhishek Singh94152932014-01-16 19:04:51 +05303475
3476 /* Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3477 * This is to address the issue of race condition between
3478 * disconnect request from the HDD and disassoc from
3479 * inactivity timer. This will make sure that we will not
3480 * process disassoc if deauth is in progress for the station
3481 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
3482 */
3483 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
3484
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 /// Send Deauthentication frame to peer entity
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303486 /* If FW_IN_TX_PATH feature is enabled
3487 do not wait for ACK */
3488 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3489 {
3490 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3491 pMlmDeauthReq->peerMacAddr,
3492 psessionEntry, FALSE);
3493
3494 /* Send Deauth CNF and receive path cleanup */
3495 limSendDeauthCnf(pMac);
3496 }
3497 else
3498 {
3499 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3500 pMlmDeauthReq->peerMacAddr,
3501 psessionEntry, TRUE);
3502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003503
3504 return;
3505
3506end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303507 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3508 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3509 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3511 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3512 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3513
3514 // Free up buffer allocated
3515 // for mlmDeauthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303516 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003517
3518 limPostSmeMessage(pMac,
3519 LIM_MLM_DEAUTH_CNF,
3520 (tANI_U32 *) &mlmDeauthCnf);
3521
3522}
3523
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003524
3525void limProcessDeauthAckTimeout(tpAniSirGlobal pMac)
3526{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303527 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003528 limSendDeauthCnf(pMac);
3529}
3530
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303531void lim_process_ap_ecsa_timeout(tpAniSirGlobal mac_ctx)
3532{
3533 tSirMsgQ msg = {0};
3534 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
3535 tpPESession session;
3536
3537 session = peFindSessionBySessionId(mac_ctx,
3538 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3539
3540 if(!session)
3541 {
3542 limLog(mac_ctx, LOGE, FL("session does not exist for given sessionId %d"),
3543 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3544 return;
3545 }
3546 limLog(mac_ctx, LOG1, FL("session id %d switch count %d"),
3547 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId,
3548 session->gLimChannelSwitch.switchCount);
3549 /*
3550 * For each beacon interval decrement switch count to use proper value
3551 * in probe resp sent by host. Once it becomes 0 send tx complete
3552 * indication to SME.
3553 */
3554 if (session->gLimChannelSwitch.switchCount > 0) {
3555 session->gLimChannelSwitch.switchCount--;
Abhishek Singh449c5372017-12-19 17:21:20 +05303556 lim_send_chan_switch_action_frame(mac_ctx,
3557 session->gLimChannelSwitch.primaryChannel, session);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303558 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
3559 session->peSessionId;
3560 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
3561
3562 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
3563 TX_SUCCESS)
3564 {
3565 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
3566 lim_process_ap_ecsa_timeout(mac_ctx);
3567 }
3568 return;
3569 }
3570
3571 session->include_ecsa_ie = false;
3572 session->include_wide_ch_bw_ie = false;
3573
3574 ecsa_ie_cmp_ind = vos_mem_malloc(sizeof(*ecsa_ie_cmp_ind));
3575 if(!ecsa_ie_cmp_ind)
3576 {
3577 limLog(mac_ctx, LOGE, FL("failed to allocate ecsa_ie_cmp_ind"));
3578 return;
3579 }
3580 ecsa_ie_cmp_ind->session_id = session->smeSessionId;
3581
3582 msg.type = eWNI_SME_ECSA_IE_BEACON_COMP_IND;
3583 msg.bodyptr = ecsa_ie_cmp_ind;
3584 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3585 return;
3586}
3587
3588void lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal mac_ctx,
3589 tpPESession session, tpSwitchChannelParams chan_params)
3590{
3591 tSirMsgQ msg = {0};
3592 struct sir_channel_chanege_rsp *params;
3593
3594 params = vos_mem_malloc(sizeof(*params));
3595 if (!params) {
3596 limLog(mac_ctx, LOGE, FL("AllocateMemory failed for pSmeSwithChnlParams"));
3597 return;
3598 }
3599
3600 params->sme_session_id = session->smeSessionId;
3601 params->new_channel = chan_params->channelNumber;
3602 params->status = chan_params->status;
3603
3604 msg.type = eWNI_SME_ECSA_CHAN_CHANGE_RSP;
3605 msg.bodyptr = params;
3606 msg.bodyval = 0;
3607 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3608
3609 if (chan_params->channelNumber == session->currentOperChannel) {
3610 limApplyConfiguration(mac_ctx, session);
3611 limSendBeaconInd(mac_ctx, session);
3612 } else {
3613 limLog(mac_ctx, LOGE, FL("channel switch resp chan %d and session channel doesnt match %d"),
3614 chan_params->channelNumber, session->currentOperChannel);
3615 }
3616
3617 return;
3618}
3619
3620
Jeff Johnson295189b2012-06-20 16:38:30 -07003621/**
3622 * limProcessMlmDeauthReq()
3623 *
3624 *FUNCTION:
3625 * This function is called to process MLM_DEAUTH_REQ message
3626 * from SME
3627 *
3628 *LOGIC:
3629 *
3630 *ASSUMPTIONS:
3631 *
3632 *NOTE:
3633 *
3634 * @param pMac Pointer to Global MAC structure
3635 * @param *pMsgBuf A pointer to the MLM message buffer
3636 * @return None
3637 */
3638
3639static void
3640limProcessMlmDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3641{
3642// tANI_U16 aid;
3643// tSirMacAddr currentBssId;
3644// tpDphHashNode pStaDs;
3645// struct tLimPreAuthNode *pAuthNode;
3646 tLimMlmDeauthReq *pMlmDeauthReq;
3647// tLimMlmDeauthCnf mlmDeauthCnf;
3648 tpPESession psessionEntry;
3649
3650 if(pMsgBuf == NULL)
3651 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003652 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 return;
3654 }
3655
3656 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3657
Abhishek Singhcd09b562013-12-24 16:02:20 +05303658 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d "
3659 "from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3660 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3663 {
3664
Abhishek Singhcd09b562013-12-24 16:02:20 +05303665 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3666 pMlmDeauthReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 return;
3668 }
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003669 limProcessMlmDeauthReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
3670
Jeff Johnson295189b2012-06-20 16:38:30 -07003671} /*** limProcessMlmDeauthReq() ***/
3672
3673
3674
3675/**
3676 * @function : limProcessMlmSetKeysReq()
3677 *
3678 * @brief : This function is called to process MLM_SETKEYS_REQ message
3679 * from SME
3680 *
3681 *LOGIC:
3682 *
3683 *ASSUMPTIONS:
3684 *
3685 *NOTE:
3686 *
3687 * @param pMac Pointer to Global MAC structure
3688 * @param *pMsgBuf A pointer to the MLM message buffer
3689 * @return None
3690 */
3691
3692static void
3693limProcessMlmSetKeysReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3694{
3695tANI_U16 aid;
3696tANI_U16 staIdx = 0;
3697tANI_U32 defaultKeyId = 0;
3698tSirMacAddr currentBssId;
3699tpDphHashNode pStaDs;
3700tLimMlmSetKeysReq *pMlmSetKeysReq;
3701tLimMlmSetKeysCnf mlmSetKeysCnf;
3702tpPESession psessionEntry;
3703
3704 if(pMsgBuf == NULL)
3705 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003706 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 return;
3708 }
3709
3710
3711 pMlmSetKeysReq = (tLimMlmSetKeysReq *) pMsgBuf;
3712 // Hold onto the SetKeys request parameters
3713 pMac->lim.gpLimMlmSetKeysReq = (void *) pMlmSetKeysReq;
3714
3715 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmSetKeysReq->sessionId))== NULL)
3716 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003717 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 return;
3719 }
3720
3721 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003722 FL( "Received MLM_SETKEYS_REQ with parameters:"
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "),
3724 pMlmSetKeysReq->aid,
3725 pMlmSetKeysReq->edType,
3726 pMlmSetKeysReq->numKeys );
3727 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3728
3729 #if 0
3730 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, currentBssId, &cfg )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003731 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 return;
3733 }
3734 #endif //TO SUPPORT BT-AMP
3735 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3736
3737 switch( psessionEntry->limSystemRole ) {
3738 case eLIM_STA_ROLE:
3739 case eLIM_BT_AMP_STA_ROLE:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003740 //In case of TDLS, peerMac address need not be BssId. Skip this check
3741 //if TDLS is enabled.
3742#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 if((!limIsAddrBC( pMlmSetKeysReq->peerMacAddr ) ) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303744 (!vos_mem_compare(pMlmSetKeysReq->peerMacAddr,
3745 currentBssId, sizeof(tSirMacAddr))) ){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003746 limLog( pMac, LOGW, FL("Received MLM_SETKEYS_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3748
3749 // Prepare and Send LIM_MLM_SETKEYS_CNF with error code
3750 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3751 goto end;
3752 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003753#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 // Fall thru' & 'Plumb' keys below
3755 break;
3756 case eLIM_STA_IN_IBSS_ROLE:
3757 default: // others
3758 // Fall thru...
3759 break;
3760 }
3761
3762 /**
3763 * Use the "unicast" parameter to determine if the "Group Keys"
3764 * are being set.
3765 * pMlmSetKeysReq->key.unicast = 0 -> Multicast/broadcast
3766 * pMlmSetKeysReq->key.unicast - 1 -> Unicast keys are being set
3767 */
3768 if( limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003769 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "), pMlmSetKeysReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 /** When trying to set Group Keys for any
3771 * security mode other than WEP, use the
3772 * STA Index corresponding to the AP...
3773 */
3774 switch( pMlmSetKeysReq->edType ) {
3775 case eSIR_ED_CCMP:
3776
3777#ifdef WLAN_FEATURE_11W
3778 case eSIR_ED_AES_128_CMAC:
3779#endif
3780 staIdx = psessionEntry->staId;
3781 break;
3782
3783 default:
3784 break;
3785 }
3786 }else {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003787 limLog( pMac, LOG1, FL("Trying to set Unicast Keys..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 /**
3789 * Check if there exists a context for the
3790 * peer entity for which keys need to be set.
3791 */
3792
3793
3794 pStaDs = dphLookupHashEntry( pMac, pMlmSetKeysReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
3795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 if ((pStaDs == NULL) ||
3797 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) && (psessionEntry->limSystemRole != eLIM_AP_ROLE))) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 /**
3799 * Received LIM_MLM_SETKEYS_REQ for STA
3800 * that does not have context or in some
3801 * transit state. Log error.
3802 */
3803 limLog( pMac, LOG1,
3804 FL("Received MLM_SETKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3805 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3806
3807 // Prepare and Send LIM_MLM_SETKEYS_CNF
3808 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3809 goto end;
3810 } else
3811 staIdx = pStaDs->staIndex;
3812 }
3813
3814 if ((pMlmSetKeysReq->numKeys == 0) && (pMlmSetKeysReq->edType != eSIR_ED_NONE)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003815 //
3816 // Broadcast/Multicast Keys (for WEP!!) are NOT sent
3817 // via this interface!!
3818 //
3819 // This indicates to HAL that the WEP Keys need to be
3820 // extracted from the CFG and applied to hardware
3821 defaultKeyId = 0xff;
3822 }else if(pMlmSetKeysReq->key[0].keyId &&
3823 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
3824 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))){
3825 /* If the Key Id is non zero and encryption mode is WEP,
3826 * the key index is coming from the upper layers so that key only
3827 * need to be used as the default tx key, This is being used only
3828 * in case of WEP mode in HAL */
3829 defaultKeyId = pMlmSetKeysReq->key[0].keyId;
3830 }else
3831 defaultKeyId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003832
3833 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003834 FL( "Trying to set keys for STA Index [%d], using defaultKeyId [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 staIdx,
3836 defaultKeyId );
3837
3838 if(limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
3839 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3840 psessionEntry->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003841 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003842 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 psessionEntry->peSessionId);
3844
3845 // Package WDA_SET_BSSKEY_REQ message parameters
3846 limSendSetBssKeyReq(pMac, pMlmSetKeysReq,psessionEntry);
3847 return;
3848 }else {
3849 // Package WDA_SET_STAKEY_REQ / WDA_SET_STA_BCASTKEY_REQ message parameters
3850 limSendSetStaKeyReq(pMac, pMlmSetKeysReq, staIdx, (tANI_U8) defaultKeyId,psessionEntry);
3851 return;
3852 }
3853
3854end:
3855 mlmSetKeysCnf.sessionId= pMlmSetKeysReq->sessionId;
3856 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
3857
3858} /*** limProcessMlmSetKeysReq() ***/
3859
3860/**
3861 * limProcessMlmRemoveKeyReq()
3862 *
3863 *FUNCTION:
3864 * This function is called to process MLM_REMOVEKEY_REQ message
3865 * from SME
3866 *
3867 *LOGIC:
3868 *
3869 *ASSUMPTIONS:
3870 *
3871 *NOTE:
3872 *
3873 * @param pMac Pointer to Global MAC structure
3874 * @param *pMsgBuf A pointer to the MLM message buffer
3875 * @return None
3876 */
3877
3878static void
3879limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3880{
3881tANI_U16 aid;
3882tANI_U16 staIdx = 0;
3883tSirMacAddr currentBssId;
3884tpDphHashNode pStaDs;
3885tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3886tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
3887 tpPESession psessionEntry;
3888
3889 if(pMsgBuf == NULL)
3890 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003891 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 return;
3893 }
3894
3895 pMlmRemoveKeyReq = (tLimMlmRemoveKeyReq *) pMsgBuf;
3896
3897
3898 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyReq->sessionId))== NULL)
3899 {
3900 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003901 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303902 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 return;
3904 }
3905
3906
3907 if( pMac->lim.gpLimMlmRemoveKeyReq != NULL )
3908 {
3909 // Free any previous requests.
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303910 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
3912 }
3913 // Hold onto the RemoveKeys request parameters
3914 pMac->lim.gpLimMlmRemoveKeyReq = (void *) pMlmRemoveKeyReq;
3915
3916 #if 0
3917 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
3918 WNI_CFG_BSSID,
3919 currentBssId,
3920 &cfg ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003921 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 #endif //TO-SUPPORT BT-AMP
3923 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3924
3925 switch( psessionEntry->limSystemRole )
3926 {
3927 case eLIM_STA_ROLE:
3928 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303929 if (( limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr ) != true ) &&
3930 (!vos_mem_compare(pMlmRemoveKeyReq->peerMacAddr,
3931 currentBssId,
3932 sizeof(tSirMacAddr))))
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 {
3934 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003935 FL("Received MLM_REMOVEKEY_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
3937
3938 // Prepare and Send LIM_MLM_REMOVEKEY_CNF with error code
3939 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3940 goto end;
3941 }
3942 break;
3943
3944 case eLIM_STA_IN_IBSS_ROLE:
3945 default: // eLIM_AP_ROLE
3946 // Fall thru...
3947 break;
3948 }
3949
3950
3951 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3952 if(limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr )) //Second condition for IBSS or AP role.
3953 {
3954 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003955 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 // Package WDA_REMOVE_BSSKEY_REQ message parameters
3957 limSendRemoveBssKeyReq( pMac,pMlmRemoveKeyReq,psessionEntry);
3958 return;
3959 }
3960
3961 /**
3962 * Check if there exists a context for the
3963 * peer entity for which keys need to be removed.
3964 */
3965 pStaDs = dphLookupHashEntry( pMac, pMlmRemoveKeyReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
3966 if ((pStaDs == NULL) ||
3967 (pStaDs &&
3968 (pStaDs->mlmStaContext.mlmState !=
3969 eLIM_MLM_LINK_ESTABLISHED_STATE)))
3970 {
3971 /**
3972 * Received LIM_MLM_REMOVEKEY_REQ for STA
3973 * that does not have context or in some
3974 * transit state. Log error.
3975 */
3976 limLog( pMac, LOGW,
3977 FL("Received MLM_REMOVEKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3978 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
3979
3980 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
3981 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3982 mlmRemoveKeyCnf.sessionId = pMlmRemoveKeyReq->sessionId;
3983
3984
3985 goto end;
3986 }
3987 else
3988 staIdx = pStaDs->staIndex;
3989
3990
3991
3992 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003993 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003994
3995 // Package WDA_REMOVE_STAKEY_REQ message parameters
3996 limSendRemoveStaKeyReq( pMac,pMlmRemoveKeyReq,staIdx,psessionEntry);
3997 return;
3998
3999end:
4000 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07004001 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 pMlmRemoveKeyReq,
4003 &mlmRemoveKeyCnf );
4004
4005} /*** limProcessMlmRemoveKeyReq() ***/
4006
4007
4008/**
4009 * limProcessMinChannelTimeout()
4010 *
4011 *FUNCTION:
4012 * This function is called to process Min Channel Timeout
4013 * during channel scan.
4014 *
4015 *LOGIC:
4016 *
4017 *ASSUMPTIONS:
4018 *
4019 *NOTE:
4020 *
4021 * @param pMac Pointer to Global MAC structure
4022 * @return None
4023 */
4024
4025static void
4026limProcessMinChannelTimeout(tpAniSirGlobal pMac)
4027{
4028 tANI_U8 channelNum;
4029
4030#ifdef GEN6_TODO
4031 //if the min Channel is maintained per session, then use the below seesionEntry
4032 //priority - LOW/might not be needed
4033
4034 //TBD-RAJESH HOW TO GET sessionEntry?????
4035 tpPESession psessionEntry;
4036
4037 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimMinChannelTimer.sessionId))== NULL)
4038 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004039 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 return;
4041 }
4042#endif
4043
Abhishek Singh89e1d672013-11-28 15:13:42 +05304044 /*do not process if we are in finish scan wait state i.e.
4045 scan is aborted or finished*/
4046 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE &&
4047 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 /// Min channel timer timed out
4050 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
4051 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
4052 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05304053 /*
4054 * Deactivate Max Channel timer as well since no probe resp/beacons
4055 * are received.
4056 */
4057 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004058 pMac->lim.probeCounter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 if (pMac->lim.gLimCurrentScanChannelId <=
4060 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4061 {
4062 channelNum = (tANI_U8)limGetCurrentScanChannel(pMac);
4063 }
4064 else
4065 {
4066 // This shouldn't be the case, but when this happens, this timeout should be for the last channelId.
4067 // Get the channelNum as close to correct as possible.
4068 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4069 {
4070 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4071 }
4072 else
4073 {
4074 channelNum = 1;
4075 }
4076 }
4077
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004078 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304079 FL("Sending End Scan req from MIN_CH_TIMEOUT in state %d ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004080 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4082 }
4083 else
4084 {
4085 /**
4086 * MIN channel timer should not have timed out
4087 * in states other than wait_probe_response.
4088 * Log error.
4089 */
4090 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304091 FL("received unexpected MIN channel timeout in mlme state %d and hal scan State %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304092 pMac->lim.gLimMlmState,pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 limPrintMlmState(pMac, LOGE, pMac->lim.gLimMlmState);
4094 }
4095} /*** limProcessMinChannelTimeout() ***/
4096
4097
4098
4099/**
4100 * limProcessMaxChannelTimeout()
4101 *
4102 *FUNCTION:
4103 * This function is called to process Max Channel Timeout
4104 * during channel scan.
4105 *
4106 *LOGIC:
4107 *
4108 *ASSUMPTIONS:
4109 *
4110 *NOTE:
4111 *
4112 * @param pMac Pointer to Global MAC structure
4113 * @return None
4114 */
4115
4116static void
4117limProcessMaxChannelTimeout(tpAniSirGlobal pMac)
4118{
4119 tANI_U8 channelNum;
4120
Abhishek Singh89e1d672013-11-28 15:13:42 +05304121 /*do not process if we are in finish scan wait state i.e.
4122 scan is aborted or finished*/
4123 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE ||
4124 pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE) &&
4125 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304127 limLog(pMac, LOG1, FL("Scanning : Max channel timed out"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 /**
4129 * MAX channel timer timed out
4130 * Continue channel scan.
4131 */
4132 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
4133 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
4134 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004135 pMac->lim.probeCounter = 0;
4136
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004137 if (pMac->lim.gLimCurrentScanChannelId <=
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4139 {
4140 channelNum = limGetCurrentScanChannel(pMac);
4141 }
4142 else
4143 {
4144 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4145 {
4146 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4147 }
4148 else
4149 {
4150 channelNum = 1;
4151 }
4152 }
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004153 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304154 FL("Sending End Scan req from MAX_CH_TIMEOUT in state %d on ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004155 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4157 }
4158 else
4159 {
4160 /**
4161 * MAX channel timer should not have timed out
4162 * in states other than wait_scan.
4163 * Log error.
4164 */
4165 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304166 FL("received unexpected MAX channel timeout in mlme state %d and hal scan state %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304167 pMac->lim.gLimMlmState, pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
4169 }
4170} /*** limProcessMaxChannelTimeout() ***/
4171
4172/**
4173 * limProcessPeriodicProbeReqTimer()
4174 *
4175 *FUNCTION:
4176 * This function is called to process periodic probe request
4177 * to send during scan.
4178 *
4179 *LOGIC:
4180 *
4181 *ASSUMPTIONS:
4182 *
4183 *NOTE:
4184 *
4185 * @param pMac Pointer to Global MAC structure
4186 * @return None
4187 */
4188
4189static void
4190limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac)
4191{
4192 tANI_U8 channelNum;
4193 tANI_U8 i = 0;
4194 tSirRetStatus status = eSIR_SUCCESS;
4195 TX_TIMER *pPeriodicProbeReqTimer;
4196 pPeriodicProbeReqTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
4197
4198 if(vos_timer_getCurrentState(&pPeriodicProbeReqTimer->vosTimer)
4199 != VOS_TIMER_STATE_STOPPED)
4200 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304201 limLog(pMac, LOG1, FL("Invalid state of timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 return;
4203 }
4204
4205 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004206 (pPeriodicProbeReqTimer->sessionId != 0xff) && (pMac->lim.probeCounter < pMac->lim.maxProbe))
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 {
4208 tLimMlmScanReq *pLimMlmScanReq = pMac->lim.gpLimMlmScanReq;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004209 pMac->lim.probeCounter++;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 /**
4211 * Periodic channel timer timed out
4212 * to send probe request.
4213 */
4214 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +05304215 /* Prepare and send Probe Request frame for all the SSIDs
4216 * present in the saved MLM
4217 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 do
4219 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304220 tSirMacAddr gSelfMacAddr;
4221
Abhishek Singh795e1b82015-09-25 15:35:03 +05304222 /* Send self MAC as src address if
4223 * MAC spoof is not enabled OR
4224 * spoofMacAddr is all 0 OR
4225 * disableP2PMacSpoof is enabled and scan is P2P scan
4226 * else use the spoofMac as src address
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 */
Abhishek Singh795e1b82015-09-25 15:35:03 +05304228 if ((pMac->lim.isSpoofingEnabled != TRUE) ||
4229 (TRUE ==
4230 vos_is_macaddr_zero((v_MACADDR_t *)&pMac->lim.spoofMacAddr)) ||
4231 (pMac->roam.configParam.disableP2PMacSpoofing &&
4232 pMac->lim.gpLimMlmScanReq->p2pSearch)) {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304233 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr, VOS_MAC_ADDRESS_LEN);
4234 } else {
4235 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr, VOS_MAC_ADDRESS_LEN);
4236 }
4237 limLog( pMac, LOG1, FL("Mac Addr used in Probe Req is :"MAC_ADDRESS_STR),
4238 MAC_ADDR_ARRAY(gSelfMacAddr));
4239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 /*
4241 * PELOGE(limLog(pMac, LOGW, FL("sending ProbeReq number %d,"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004242 * " for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 * i, pLimMlmScanReq->ssId[i].ssId,
4244 * channelNum);)
4245 */
4246 status = limSendProbeReqMgmtFrame( pMac, &pLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304247 pLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 pLimMlmScanReq->dot11mode, pLimMlmScanReq->uIEFieldLen,
4249 (tANI_U8 *)(pLimMlmScanReq) + pLimMlmScanReq->uIEFieldOffset);
4250
4251
4252 if ( status != eSIR_SUCCESS)
4253 {
4254 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004255 "%s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 pLimMlmScanReq->ssId[i].ssId,
4257 channelNum);)
4258 return;
4259 }
4260 i++;
4261 } while (i < pLimMlmScanReq->numSsid);
4262
4263 /* Activate timer again */
4264 if (tx_timer_activate(pPeriodicProbeReqTimer) != TX_SUCCESS)
4265 {
4266 limLog(pMac, LOGP, FL("could not start periodic probe"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004267 " req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 return;
4269 }
4270 }
4271 else
4272 {
4273 /**
4274 * Periodic scan is timeout is happening in
4275 * in states other than wait_scan.
4276 * Log error.
4277 */
Mohit Khanna23863762012-09-11 17:40:09 -07004278 limLog(pMac, LOG1,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304279 FL("received unexpected Periodic scan timeout in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 pMac->lim.gLimMlmState);
4281 }
4282} /*** limProcessPeriodicProbeReqTimer() ***/
4283
4284/**
4285 * limProcessJoinFailureTimeout()
4286 *
4287 *FUNCTION:
4288 * This function is called to process JoinFailureTimeout
4289 *
4290 *LOGIC:
4291 *
4292 *ASSUMPTIONS:
4293 *
4294 *NOTE:
4295 *
4296 * @param pMac Pointer to Global MAC structure
4297 * @return None
4298 */
4299
4300static void
4301limProcessJoinFailureTimeout(tpAniSirGlobal pMac)
4302{
4303 tLimMlmJoinCnf mlmJoinCnf;
4304 tSirMacAddr bssid;
4305 tANI_U32 len;
krunal soni8d13b092013-07-19 13:23:29 -07004306#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4307 vos_log_rssi_pkt_type *pRssiLog = NULL;
4308#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004309
4310 //fetch the sessionEntry based on the sessionId
4311 tpPESession psessionEntry;
4312
4313 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimJoinFailureTimer.sessionId))== NULL)
4314 {
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07004315 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 return;
4317 }
krunal soni8d13b092013-07-19 13:23:29 -07004318
4319#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4320 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4321 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4322 if (pRssiLog)
4323 {
4324 pRssiLog->rssi = psessionEntry->rssi;
4325 }
4326 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4327#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4328
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
4330 {
4331 len = sizeof(tSirMacAddr);
4332
4333 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, bssid, &len) !=
4334 eSIR_SUCCESS)
4335 {
4336 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004337 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 return;
4339 }
4340
4341 // 'Change' timer for future activations
4342 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004343 // Change Periodic probe req timer for future activation
4344 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 /**
4346 * Issue MLM join confirm with timeout reason code
4347 */
Kiet Lam82004c62013-11-11 13:24:28 +05304348 PELOGE(limLog(pMac, LOGE, FL(" In state eLIM_MLM_WT_JOIN_BEACON_STATE."));)
4349 PELOGE(limLog(pMac, LOGE, FL(" Join Failure Timeout occurred for session %d with BSS "),
4350 psessionEntry->peSessionId);
4351 limPrintMacAddr(pMac, psessionEntry->bssId, LOGE);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004352
4353 mlmJoinCnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
4354 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4355
4356 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004357 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
4359 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004360 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 /* Update PE session Id */
4362 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
4363
4364
4365 // Freeup buffer allocated to join request
4366 if (psessionEntry->pLimMlmJoinReq)
4367 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304368 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 psessionEntry->pLimMlmJoinReq = NULL;
4370 }
4371
4372 limPostSmeMessage(pMac,
4373 LIM_MLM_JOIN_CNF,
4374 (tANI_U32 *) &mlmJoinCnf);
4375
4376 return;
4377 }
4378 else
4379 {
4380 /**
4381 * Join failure timer should not have timed out
4382 * in states other than wait_join_beacon state.
4383 * Log error.
4384 */
4385 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304386 FL("received unexpected JOIN failure timeout in state %d"),psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4388 }
4389} /*** limProcessJoinFailureTimeout() ***/
4390
4391
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004392/**
4393 * limProcessPeriodicJoinProbeReqTimer()
4394 *
4395 *FUNCTION:
4396 * This function is called to process periodic probe request
4397 * send during joining process.
4398 *
4399 *LOGIC:
4400 *
4401 *ASSUMPTIONS:
4402 *
4403 *NOTE:
4404 *
4405 * @param pMac Pointer to Global MAC structure
4406 * @return None
4407 */
4408
4409static void limProcessPeriodicJoinProbeReqTimer(tpAniSirGlobal pMac)
4410{
4411 tpPESession psessionEntry;
4412 tSirMacSSid ssId;
4413
4414 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId))== NULL)
4415 {
Kiet Lam82004c62013-11-11 13:24:28 +05304416 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4417 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004418 return;
4419 }
4420
4421 if((VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)) &&
4422 (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE))
4423 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304424 vos_mem_copy(ssId.ssId,
4425 psessionEntry->ssId.ssId,
4426 psessionEntry->ssId.length);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004427 ssId.length = psessionEntry->ssId.length;
4428
4429 limSendProbeReqMgmtFrame( pMac, &ssId,
4430 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
4431 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
4432 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
4433
4434 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
4435
4436 // Activate Join Periodic Probe Req timer
4437 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
4438 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004439 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer"));
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004440 return;
4441 }
4442 }
4443 return;
4444} /*** limProcessPeriodicJoinProbeReqTimer() ***/
4445
Sushant Kaushik9e923872015-04-02 17:09:31 +05304446/**
4447 * limProcessAuthRetryTimer()
4448 *
4449 *FUNCTION:
4450 * This function is called to process Auth Retry request
4451 * send during joining process.
4452 *
4453 *LOGIC:
4454 *
4455 *ASSUMPTIONS:
4456 *
4457 *NOTE:
4458 *
4459 * @param pMac Pointer to Global MAC structure
4460 * @return None
4461 */
4462
4463static void limProcessAuthRetryTimer(tpAniSirGlobal pMac)
4464{
4465 tpPESession psessionEntry;
4466 limLog(pMac, LOG1, FL(" ENTER "));
4467 if ((psessionEntry =
4468 peFindSessionBySessionId(pMac,
4469 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId)) == NULL)
4470 {
4471 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4472 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId);
4473 return;
4474 }
4475
4476 if ((VOS_TRUE ==
4477 tx_timer_running(&pMac->lim.limTimers.gLimAuthFailureTimer)) &&
4478 (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
4479 (LIM_AUTH_ACK_RCD_SUCCESS != pMac->authAckStatus))
4480 {
4481 tSirMacAuthFrameBody authFrameBody;
4482
4483 /* Send the auth retry only in case we have received ack failure
4484 * else just restart the retry timer.
4485 */
4486 if (LIM_AUTH_ACK_RCD_FAILURE == pMac->authAckStatus)
4487 {
4488 /// Prepare & send Authentication frame
4489 authFrameBody.authAlgoNumber =
4490 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
4491 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
4492 authFrameBody.authStatusCode = 0;
4493 limLog(pMac, LOGW, FL("Retry Auth "));
4494 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
4495 limSendAuthMgmtFrame(pMac,
4496 &authFrameBody,
4497 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
4498 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
4499 }
4500
4501 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
4502
4503 // Activate Auth Retry timer
4504 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
4505 != TX_SUCCESS)
4506 {
4507 limLog(pMac, LOGE,
4508 FL("could not activate Auth Retry failure timer"));
4509 return;
4510 }
4511 }
4512 return;
4513} /*** limProcessAuthRetryTimer() ***/
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515
4516/**
4517 * limProcessAuthFailureTimeout()
4518 *
4519 *FUNCTION:
4520 * This function is called to process Min Channel Timeout
4521 * during channel scan.
4522 *
4523 *LOGIC:
4524 *
4525 *ASSUMPTIONS:
4526 *
4527 *NOTE:
4528 *
4529 * @param pMac Pointer to Global MAC structure
4530 * @return None
4531 */
4532
4533static void
4534limProcessAuthFailureTimeout(tpAniSirGlobal pMac)
4535{
4536 //fetch the sessionEntry based on the sessionId
4537 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004538#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4539 vos_log_rssi_pkt_type *pRssiLog = NULL;
4540#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAuthFailureTimer.sessionId))== NULL)
4542 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004543 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 return;
4545 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304546 limLog(pMac, LOGE, FL("received AUTH failure timeout in sessionid %d "
Sushant Kaushik1b645382014-10-13 16:39:36 +05304547 "limMlmstate %d limSmeState %d"), psessionEntry->peSessionId,
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304548 psessionEntry->limMlmState, psessionEntry->limSmeState);
krunal soni8d13b092013-07-19 13:23:29 -07004549#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4550 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4551 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4552 if (pRssiLog)
4553 {
4554 pRssiLog->rssi = psessionEntry->rssi;
4555 }
4556 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4557#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4558
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 switch (psessionEntry->limMlmState)
4560 {
4561 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
4562 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
4563 /**
4564 * Requesting STA did not receive next auth frame
4565 * before Auth Failure timeout.
4566 * Issue MLM auth confirm with timeout reason code
4567 */
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08004568 //Restore default failure timeout
4569 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
4570 {
4571 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
4572 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
4573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 limRestoreFromAuthState(pMac,eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
4575 break;
4576
4577 default:
4578 /**
4579 * Auth failure timer should not have timed out
4580 * in states other than wt_auth_frame2/4
4581 * Log error.
4582 */
Sushant Kaushik1b645382014-10-13 16:39:36 +05304583 PELOGE(limLog(pMac, LOGE, FL("received unexpected AUTH failure timeout in state %d"), psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
4585
4586 break;
4587 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304588 /* Reinit scan results to remove the unreachable BSS */
4589 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004590} /*** limProcessAuthFailureTimeout() ***/
4591
4592
4593
4594/**
4595 * limProcessAuthRspTimeout()
4596 *
4597 *FUNCTION:
4598 * This function is called to process Min Channel Timeout
4599 * during channel scan.
4600 *
4601 *LOGIC:
4602 *
4603 *ASSUMPTIONS:
4604 *
4605 *NOTE:
4606 *
4607 * @param pMac Pointer to Global MAC structure
4608 * @return None
4609 */
4610
4611static void
4612limProcessAuthRspTimeout(tpAniSirGlobal pMac, tANI_U32 authIndex)
4613{
4614 struct tLimPreAuthNode *pAuthNode;
4615 tpPESession psessionEntry;
4616 tANI_U8 sessionId;
4617
4618 pAuthNode = limGetPreAuthNodeFromIndex(pMac, &pMac->lim.gLimPreAuthTimerTable, authIndex);
4619
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304620 if (NULL == pAuthNode)
4621 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004622 limLog(pMac, LOGW, FL("Invalid auth node"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304623 return;
4624 }
4625
4626 if ((psessionEntry = peFindSessionByBssid(pMac, pAuthNode->peerMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004628 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 return;
4630 }
4631
4632 if (psessionEntry->limSystemRole == eLIM_AP_ROLE ||
4633 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
4634 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304635 if (pAuthNode->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 {
4637 /**
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304638 * Authentication response timer timedout
4639 * in unexpected state. Log error
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 */
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304641 PELOGE(limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304642 FL("received AUTH rsp timeout in unexpected state "
4643 "for MAC address: "MAC_ADDRESS_STR),
4644 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 }
4646 else
4647 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304648 // Authentication response timer
4649 // timedout for an STA.
4650 pAuthNode->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
4651 pAuthNode->fTimerStarted = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304652 limLog(pMac, LOG1,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304653 FL("AUTH rsp timedout for MAC address "MAC_ADDRESS_STR),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304654 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004655
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304656 // Change timer to reactivate it in future
4657 limDeactivateAndChangePerStaIdTimer(pMac,
4658 eLIM_AUTH_RSP_TIMER,
4659 pAuthNode->authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004660
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304661 limDeletePreAuthNode(pMac, pAuthNode->peerMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 }
4663 }
4664} /*** limProcessAuthRspTimeout() ***/
4665
4666
4667/**
4668 * limProcessAssocFailureTimeout()
4669 *
4670 *FUNCTION:
4671 * This function is called to process Min Channel Timeout
4672 * during channel scan.
4673 *
4674 *LOGIC:
4675 *
4676 *ASSUMPTIONS:
4677 *
4678 *NOTE:
4679 *
4680 * @param pMac Pointer to Global MAC structure
4681 * @return None
4682 */
4683
4684static void
4685limProcessAssocFailureTimeout(tpAniSirGlobal pMac, tANI_U32 MsgType)
4686{
4687
4688 tLimMlmAssocCnf mlmAssocCnf;
4689 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004690#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4691 vos_log_rssi_pkt_type *pRssiLog = NULL;
4692#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004693
4694 //to fetch the lim/mlm state based on the sessionId, use the below sessionEntry
4695 tANI_U8 sessionId;
4696
4697 if(MsgType == LIM_ASSOC)
4698 {
4699 sessionId = pMac->lim.limTimers.gLimAssocFailureTimer.sessionId;
4700 }
4701 else
4702 {
4703 sessionId = pMac->lim.limTimers.gLimReassocFailureTimer.sessionId;
4704 }
4705
4706 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
4707 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004708 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 return;
4710 }
krunal soni8d13b092013-07-19 13:23:29 -07004711#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4712 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4713 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4714 if (pRssiLog)
4715 {
4716 pRssiLog->rssi = psessionEntry->rssi;
4717 }
4718 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4719#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4720
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 /**
4722 * Expected Re/Association Response frame
4723 * not received within Re/Association Failure Timeout.
4724 */
4725
4726
4727
4728
Abhishek Singh70af9c72016-03-09 17:23:30 +05304729 /*
4730 * CR: vos packet memory is leaked when assoc rsp timeouted/failed.
4731 * notify TL that association is failed so that TL can flush the
4732 * cached frame
4733 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 WLANTL_AssocFailed (psessionEntry->staId);
4735
Abhishek Singh70af9c72016-03-09 17:23:30 +05304736 /* Log error */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304737 limLog(pMac, LOG1,
4738 FL("Re/Association Response not received before timeout "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004739
Abhishek Singh70af9c72016-03-09 17:23:30 +05304740 /*
4741 * Send Deauth to handle the scenareo where association timeout happened
4742 * when device has missed the assoc resp sent by peer.
4743 * By sending deauth try to clear the session created on peer device.
4744 */
4745 limLog(pMac, LOGE,
4746 FL("Sessionid: %d try sending Send deauth on channel %d to BSSID: "
4747 MAC_ADDRESS_STR ), psessionEntry->peSessionId,
4748 psessionEntry->currentOperChannel,
4749 MAC_ADDR_ARRAY(psessionEntry->bssId));
4750
4751 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
4752 psessionEntry->bssId,
4753 psessionEntry, FALSE);
4754
4755 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4756 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )||
4757 ((psessionEntry->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
4758 (psessionEntry->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 (psessionEntry->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4760 {
4761 /**
4762 * Re/Assoc failure timer should not have timedout on AP
4763 * or in a state other than wt_re/assoc_response.
4764 */
4765
4766 // Log error
4767 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304768 FL("received unexpected REASSOC failure timeout in state %d for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 psessionEntry->limMlmState, psessionEntry->limSystemRole);
4770 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4771 }
4772 else
4773 {
4774
4775 if ((MsgType == LIM_ASSOC) ||
4776 ((MsgType == LIM_REASSOC) && (psessionEntry->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4777 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004778 PELOGE(limLog(pMac, LOGE, FL("(Re)Assoc Failure Timeout occurred."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004779
4780 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004781 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 // 'Change' timer for future activations
4784 limDeactivateAndChangeTimer(pMac, eLIM_ASSOC_FAIL_TIMER);
4785
4786 // Free up buffer allocated for JoinReq held by
4787 // MLM state machine
4788 if (psessionEntry->pLimMlmJoinReq)
4789 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304790 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 psessionEntry->pLimMlmJoinReq = NULL;
4792 }
4793
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 //To remove the preauth node in case of fail to associate
4795 if (limSearchPreAuthList(pMac, psessionEntry->bssId))
4796 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304797 limLog(pMac, LOG1, FL(" delete pre auth node for "
4798 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 limDeletePreAuthNode(pMac, psessionEntry->bssId);
4800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004801
4802 mlmAssocCnf.resultCode =
4803 eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
4804 mlmAssocCnf.protStatusCode =
4805 eSIR_MAC_UNSPEC_FAILURE_STATUS;
4806
4807 /* Update PE session Id*/
4808 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
4809 if (MsgType == LIM_ASSOC)
4810 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4811 else
4812 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004813 /* Will come here only in case of 11r, ESE, FT when reassoc rsp
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 is not received and we receive a reassoc - timesout */
4815 mlmAssocCnf.resultCode = eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
4816 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4817 }
4818 }
4819 else
4820 {
4821 /**
4822 * Restore pre-reassoc req state.
4823 * Set BSSID to currently associated AP address.
4824 */
4825 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004826 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004827
4828 limRestorePreReassocState(pMac,
4829 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry);
4830 }
4831 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304832 /* Reinit scan results to remove the unreachable BSS */
4833 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004834} /*** limProcessAssocFailureTimeout() ***/
4835
4836
4837
4838/**
4839 * limCompleteMlmScan()
4840 *
4841 *FUNCTION:
4842 * This function is called to send MLM_SCAN_CNF message
4843 * to SME state machine.
4844 *
4845 *LOGIC:
4846 *
4847 *ASSUMPTIONS:
4848 *
4849 *NOTE:
4850 *
4851 * @param pMac Pointer to Global MAC structure
4852 * @param retCode Result code to be sent
4853 * @return None
4854 */
4855
4856void
4857limCompleteMlmScan(tpAniSirGlobal pMac, tSirResultCodes retCode)
4858{
4859 tLimMlmScanCnf mlmScanCnf;
4860
4861 /// Restore previous MLM state
4862 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004863 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 limRestorePreScanState(pMac);
4865
4866 // Free up pMac->lim.gLimMlmScanReq
4867 if( NULL != pMac->lim.gpLimMlmScanReq )
4868 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304869 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 pMac->lim.gpLimMlmScanReq = NULL;
4871 }
4872
4873 mlmScanCnf.resultCode = retCode;
4874 mlmScanCnf.scanResultLength = pMac->lim.gLimMlmScanResultLength;
4875
4876 limPostSmeMessage(pMac, LIM_MLM_SCAN_CNF, (tANI_U32 *) &mlmScanCnf);
4877
4878} /*** limCompleteMlmScan() ***/
4879
4880/**
4881 * \brief Setup an A-MPDU/BA session
4882 *
4883 * \sa limProcessMlmAddBAReq
4884 *
4885 * \param pMac The global tpAniSirGlobal object
4886 *
4887 * \param pMsgBuf The MLME ADDBA Req message buffer
4888 *
4889 * \return none
4890 */
4891void limProcessMlmAddBAReq( tpAniSirGlobal pMac,
4892 tANI_U32 *pMsgBuf )
4893{
4894tSirRetStatus status = eSIR_SUCCESS;
4895tpLimMlmAddBAReq pMlmAddBAReq;
4896tpLimMlmAddBACnf pMlmAddBACnf;
4897 tpPESession psessionEntry;
4898
4899 if(pMsgBuf == NULL)
4900 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004901 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 return;
4903 }
4904
4905 pMlmAddBAReq = (tpLimMlmAddBAReq) pMsgBuf;
4906 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBAReq->sessionId))== NULL)
4907 {
4908 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004909 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304910 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 return;
4912 }
4913
4914
4915 // Send ADDBA Req over the air
4916 status = limSendAddBAReq( pMac, pMlmAddBAReq,psessionEntry);
4917
4918 //
4919 // Respond immediately to LIM, only if MLME has not been
4920 // successfully able to send WDA_ADDBA_REQ to HAL.
4921 // Else, LIM_MLM_ADDBA_CNF will be sent after receiving
4922 // ADDBA Rsp from peer entity
4923 //
4924 if( eSIR_SUCCESS != status )
4925 {
4926 // Allocate for LIM_MLM_ADDBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304927
4928 pMlmAddBACnf = vos_mem_malloc(sizeof( tLimMlmAddBACnf ));
4929 if ( NULL == pMlmAddBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 {
4931 limLog( pMac, LOGP,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004932 FL("AllocateMemory failed"));
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304933 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 return;
4935 }
4936 else
4937 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304938 vos_mem_set((void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ), 0);
4939 vos_mem_copy((void *) pMlmAddBACnf->peerMacAddr,
4940 (void *) pMlmAddBAReq->peerMacAddr,
4941 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004942
4943 pMlmAddBACnf->baDialogToken = pMlmAddBAReq->baDialogToken;
4944 pMlmAddBACnf->baTID = pMlmAddBAReq->baTID;
4945 pMlmAddBACnf->baPolicy = pMlmAddBAReq->baPolicy;
4946 pMlmAddBACnf->baBufferSize = pMlmAddBAReq->baBufferSize;
4947 pMlmAddBACnf->baTimeout = pMlmAddBAReq->baTimeout;
4948 pMlmAddBACnf->sessionId = pMlmAddBAReq->sessionId;
4949
4950 // Update the result code
4951 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4952
4953 limPostSmeMessage( pMac,
4954 LIM_MLM_ADDBA_CNF,
4955 (tANI_U32 *) pMlmAddBACnf );
4956 }
4957
4958 // Restore MLME state
4959 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004960 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004961
4962 }
4963
4964 // Free the buffer allocated for tLimMlmAddBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304965 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004966
4967}
4968
4969/**
4970 * \brief Send an ADDBA Rsp to peer STA in response
4971 * to an ADDBA Req received earlier
4972 *
4973 * \sa limProcessMlmAddBARsp
4974 *
4975 * \param pMac The global tpAniSirGlobal object
4976 *
4977 * \param pMsgBuf The MLME ADDBA Rsp message buffer
4978 *
4979 * \return none
4980 */
4981void limProcessMlmAddBARsp( tpAniSirGlobal pMac,
4982 tANI_U32 *pMsgBuf )
4983{
4984tpLimMlmAddBARsp pMlmAddBARsp;
4985 tANI_U16 aid;
4986 tpDphHashNode pSta;
4987 tpPESession psessionEntry;
4988
4989
4990 if(pMsgBuf == NULL)
4991 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004992 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 return;
4994 }
4995
4996 pMlmAddBARsp = (tpLimMlmAddBARsp) pMsgBuf;
4997
4998 if(( psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBARsp->sessionId))== NULL)
4999 {
5000 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005001 FL("session does not exist for given session ID"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305002 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 return;
5004 }
5005
5006
5007 // Send ADDBA Rsp over the air
5008 if( eSIR_SUCCESS != limSendAddBARsp( pMac,pMlmAddBARsp,psessionEntry))
5009 {
5010 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005011 FL("Failed to send ADDBA Rsp to peer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGE );
5013 /* Clean the BA context maintained by HAL and TL on failure */
5014 pSta = dphLookupHashEntry( pMac, pMlmAddBARsp->peerMacAddr, &aid,
5015 &psessionEntry->dph.dphHashTable);
5016 if( NULL != pSta )
5017 {
5018 limPostMsgDelBAInd( pMac, pSta, pMlmAddBARsp->baTID, eBA_RECIPIENT,
5019 psessionEntry);
5020 }
5021 }
5022
5023 // Time to post a WDA_DELBA_IND to HAL in order
5024 // to cleanup the HAL and SoftMAC entries
5025
5026
5027 // Free the buffer allocated for tLimMlmAddBARsp
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305028 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005029
5030}
5031
5032/**
5033 * \brief Setup an A-MPDU/BA session
5034 *
5035 * \sa limProcessMlmDelBAReq
5036 *
5037 * \param pMac The global tpAniSirGlobal object
5038 *
5039 * \param pMsgBuf The MLME DELBA Req message buffer
5040 *
5041 * \return none
5042 */
5043void limProcessMlmDelBAReq( tpAniSirGlobal pMac,
5044 tANI_U32 *pMsgBuf )
5045{
5046 tSirRetStatus status = eSIR_SUCCESS;
5047 tpLimMlmDelBAReq pMlmDelBAReq;
5048 tpLimMlmDelBACnf pMlmDelBACnf;
5049 tpPESession psessionEntry;
5050
5051
5052 if(pMsgBuf == NULL)
5053 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005054 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 return;
5056 }
5057
5058 // TODO - Need to validate MLME state
5059 pMlmDelBAReq = (tpLimMlmDelBAReq) pMsgBuf;
5060
5061 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDelBAReq->sessionId))== NULL)
5062 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005063 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305064 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 return;
5066 }
5067
5068 // Send DELBA Ind over the air
5069 if( eSIR_SUCCESS !=
5070 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
5071 status = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
5072 else
5073 {
5074 tANI_U16 aid;
5075 tpDphHashNode pSta;
5076
5077 // Time to post a WDA_DELBA_IND to HAL in order
5078 // to cleanup the HAL and SoftMAC entries
5079 pSta = dphLookupHashEntry( pMac, pMlmDelBAReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
5080 if( NULL != pSta )
5081 {
5082 status = limPostMsgDelBAInd( pMac,
5083 pSta,
5084 pMlmDelBAReq->baTID,
5085 pMlmDelBAReq->baDirection,psessionEntry);
5086
5087 }
5088 }
5089
5090 //
5091 // Respond immediately to SME with DELBA CNF using
5092 // LIM_MLM_DELBA_CNF with appropriate status
5093 //
5094
5095 // Allocate for LIM_MLM_DELBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305096
5097 pMlmDelBACnf = vos_mem_malloc(sizeof( tLimMlmDelBACnf ));
5098 if ( NULL == pMlmDelBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305100 limLog( pMac, LOGP, FL("AllocateMemory failed"));
5101 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 return;
5103 }
5104 else
5105 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305106 vos_mem_set((void *) pMlmDelBACnf, sizeof( tLimMlmDelBACnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305108 vos_mem_copy((void *) pMlmDelBACnf,
5109 (void *) pMlmDelBAReq,
5110 sizeof( tLimMlmDelBAReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005111
5112 // Update DELBA result code
5113 pMlmDelBACnf->delBAReasonCode = pMlmDelBAReq->delBAReasonCode;
5114
5115 /* Update PE session Id*/
5116 pMlmDelBACnf->sessionId = pMlmDelBAReq->sessionId;
5117
5118 limPostSmeMessage( pMac,
5119 LIM_MLM_DELBA_CNF,
5120 (tANI_U32 *) pMlmDelBACnf );
5121 }
5122
5123 // Free the buffer allocated for tLimMlmDelBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305124 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125
5126}
5127
5128/**
5129 * @function : limSMPowerSaveStateInd( )
5130 *
5131 * @brief : This function is called upon receiving the PMC Indication to update the STA's MimoPs State.
5132 *
5133 * LOGIC:
5134 *
5135 * ASSUMPTIONS:
5136 * NA
5137 *
5138 * NOTE:
5139 * NA
5140 *
5141 * @param pMac - Pointer to Global MAC structure
5142 * @param limMsg - Lim Message structure object with the MimoPSparam in body
5143 * @return None
5144 */
5145
5146tSirRetStatus
5147limSMPowerSaveStateInd(tpAniSirGlobal pMac, tSirMacHTMIMOPowerSaveState state)
5148{
5149#if 0
5150 tSirRetStatus retStatus = eSIR_SUCCESS;
5151#if 0
5152 tANI_U32 cfgVal1;
5153 tANI_U16 cfgVal2;
5154 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
5155 tpDphHashNode pSta = NULL;
5156
5157 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5158 /** Verify the Mode of operation */
5159 if (pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005160 PELOGE(limLog(pMac, LOGE, FL("Got PMC indication when System not in the STA Role"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 return eSIR_FAILURE;
5162 }
5163
5164 if ((pMac->lim.gHTMIMOPSState == state) || (state == eSIR_HT_MIMO_PS_NA )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005165 PELOGE(limLog(pMac, LOGE, FL("Got Indication when already in the same mode or State passed is NA:%d "), state);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 return eSIR_FAILURE;
5167 }
5168
5169 if (!pMac->lim.htCapability){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005170 PELOGW(limLog(pMac, LOGW, FL(" Not in 11n or HT capable mode"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 return eSIR_FAILURE;
5172 }
5173
5174 /** Update the CFG about the default MimoPS State */
5175 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &cfgVal1) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005176 limLog(pMac, LOGP, FL("could not retrieve HT Cap CFG "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 return eSIR_FAILURE;
5178 }
5179
5180 cfgVal2 = (tANI_U16)cfgVal1;
5181 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &cfgVal2;
5182 pHTCapabilityInfo->mimoPowerSave = state;
5183
5184 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005185 limLog(pMac, LOGP, FL("could not update HT Cap Info CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return eSIR_FAILURE;
5187 }
5188
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005189 PELOG2(limLog(pMac, LOG2, FL(" The HT Capability for Mimo Pwr is updated to State: %u "),state);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005191 PELOG2(limLog(pMac, LOG2,FL(" The STA is not in the Connected/Link Est Sme_State: %d "), pMac->lim.gLimSmeState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 /** Update in the LIM the MIMO PS state of the SELF */
5193 pMac->lim.gHTMIMOPSState = state;
5194 return eSIR_SUCCESS;
5195 }
5196
5197 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5198 if (!pSta->mlmStaContext.htCapability) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005199 limLog( pMac, LOGE,FL( "limSendSMPowerState: Peer is not HT Capable " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 return eSIR_FAILURE;
5201 }
5202
5203 if (isEnteringMimoPS(pMac->lim.gHTMIMOPSState, state)) {
5204 tSirMacAddr macAddr;
5205 /** Obtain the AP's Mac Address */
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305206 vos_mem_copy((tANI_U8 *)macAddr, psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 /** Send Action Frame with the corresponding mode */
5208 retStatus = limSendSMPowerStateFrame(pMac, macAddr, state);
5209 if (retStatus != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005210 PELOGE(limLog(pMac, LOGE, "Update SM POWER: Sending Action Frame has failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 return retStatus;
5212 }
5213 }
5214
5215 /** Update MlmState about the SetMimoPS State */
5216 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
5217 pMac->lim.gLimMlmState = eLIM_MLM_WT_SET_MIMOPS_STATE;
5218 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
5219
5220 /** Update the HAL and s/w mac about the mode to be set */
5221 retStatus = limPostSMStateUpdate( pMac,psessionEntry->staId, state);
5222
5223 PELOG2(limLog(pMac, LOG2, " Updated the New SMPS State");)
5224 /** Update in the LIM the MIMO PS state of the SELF */
5225 pMac->lim.gHTMIMOPSState = state;
5226#endif
5227 return retStatus;
5228#endif
5229return eSIR_SUCCESS;
5230}
5231
Jeff Johnsone7245742012-09-05 17:12:55 -07005232#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005233ePhyChanBondState limGet11ACPhyCBState(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 htSecondaryChannelOffset,tANI_U8 peerCenterChan, tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07005234{
5235 ePhyChanBondState cbState = PHY_SINGLE_CHANNEL_CENTERED;
5236
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005237 if(!psessionEntry->apChanWidth)
Jeff Johnsone7245742012-09-05 17:12:55 -07005238 {
5239 return htSecondaryChannelOffset;
5240 }
5241
5242 if ( (htSecondaryChannelOffset
5243 == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
5244 )
5245 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005246 if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005247 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005248 else if ((channel + 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005249 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005250 else if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005251 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
5252 else
5253 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005254 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005255 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005256 }
5257 if ( (htSecondaryChannelOffset
5258 == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
5259 )
5260 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005261 if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005262 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005263 else if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005264 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005265 else if ((channel - 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005266 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
5267 else
5268 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005269 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005270 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005271 }
5272 return cbState;
5273}
5274
5275#endif
5276
Jeff Johnson295189b2012-06-20 16:38:30 -07005277void
Jeff Johnsone7245742012-09-05 17:12:55 -07005278limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005279{
5280#if !defined WLAN_FEATURE_VOWIFI
5281 tANI_U32 localPwrConstraint;
5282#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005283 tpPESession peSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07005284
Jeff Johnsone7245742012-09-05 17:12:55 -07005285 peSession = peFindSessionBySessionId (pMac, peSessionId);
5286
5287 if ( NULL == peSession)
5288 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005289 limLog (pMac, LOGP, FL("Invalid PE session = %d"), peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005290 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005292#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07005293#ifdef WLAN_FEATURE_11AC
5294 if ( peSession->vhtCapability )
5295 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005296 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005297 }
5298 else
5299#endif
5300 {
5301 limSendSwitchChnlParams( pMac, channel, secChannelOffset, maxTxPower, peSessionId);
5302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005303#else
5304 if (wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005305 limLog(pMac, LOGP, FL("could not read WNI_CFG_LOCAL_POWER_CONSTRAINT from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 return;
5307 }
5308 // Send WDA_CHNL_SWITCH_IND to HAL
Jeff Johnsone7245742012-09-05 17:12:55 -07005309#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005310 if ( peSession->vhtCapability && peSession->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07005311 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005312 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005313 }
5314 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005315#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005316 {
5317 limSendSwitchChnlParams( pMac, channel, secChannelOffset, (tPowerdBm)localPwrConstraint, peSessionId);
5318 }
5319#endif
5320
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 }