blob: 774812b62d2fc633b054b20c604bc9a58bf7e984 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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
Abhinav Kumar626f8652019-08-05 16:20:39 +0530103 /**
104 * lim_process_sae_auth_timeout() - This function is called to process sae
105 * auth timeout
106 * @mac_ctx: Pointer to Global MAC structure
107 *
108 * @Return: None
109 */
110static void lim_process_sae_auth_timeout(tpAniSirGlobal mac_ctx)
111{
112 tpPESession session;
113
114 session = peFindSessionBySessionId(mac_ctx,
115 mac_ctx->lim.limTimers.sae_auth_timer.sessionId);
116 if (session == NULL) {
117 limLog(mac_ctx, LOGE,
118 FL("Session does not exist for given session id"));
119 return;
120 }
121
122 limLog(mac_ctx, LOG1,
123 FL("SAE auth timeout sessionid %d mlmstate %X SmeState %X"),
124 session->peSessionId, session->limMlmState, session->limSmeState);
125
126 switch (session->limMlmState) {
127 case eLIM_MLM_WT_SAE_AUTH_STATE:
128 /*
129 * SAE authentication is not completed. Restore from
130 * auth state.
131 */
132 if (session->pePersona == VOS_STA_MODE)
133 limRestoreFromAuthState(mac_ctx, eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,
134 eSIR_MAC_UNSPEC_FAILURE_REASON, session);
135 break;
136 default:
137 /* SAE authentication is timed out in unexpected state */
138 limLog(mac_ctx, LOGE,
139 FL("received unexpected SAE auth timeout in state %X"),
140 session->limMlmState);
141 limPrintMlmState(mac_ctx, LOGE, session->limMlmState);
142 break;
143 }
144}
145
Jeff Johnson295189b2012-06-20 16:38:30 -0700146/**
147 * limProcessMlmReqMessages()
148 *
149 *FUNCTION:
150 * This function is called by limPostMlmMessage(). This
151 * function handles MLM primitives invoked by SME.
152 *
153 *LOGIC:
154 * Depending on the message type, corresponding function will be
155 * called.
156 *
157 *ASSUMPTIONS:
158 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
159 * APIs exposed by Beacon Processing module for setting parameters
160 * at MAC hardware.
161 * 2. If attempt to Reassociate with an AP fails, link with current
162 * AP is restored back.
163 *
164 *NOTE:
165 *
166 * @param pMac Pointer to Global MAC structure
167 * @param msgType Indicates the MLM primitive message type
168 * @param *pMsgBuf A pointer to the MLM message buffer
169 *
170 * @return None
171 */
172
173void
174limProcessMlmReqMessages(tpAniSirGlobal pMac, tpSirMsgQ Msg)
175{
176 switch (Msg->type)
177 {
178 case LIM_MLM_START_REQ: limProcessMlmStartReq(pMac, Msg->bodyptr); break;
179 case LIM_MLM_SCAN_REQ: limProcessMlmScanReq(pMac, Msg->bodyptr); break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700180#ifdef FEATURE_OEM_DATA_SUPPORT
181 case LIM_MLM_OEM_DATA_REQ: limProcessMlmOemDataReq(pMac, Msg->bodyptr); break;
182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 case LIM_MLM_JOIN_REQ: limProcessMlmJoinReq(pMac, Msg->bodyptr); break;
184 case LIM_MLM_AUTH_REQ: limProcessMlmAuthReq(pMac, Msg->bodyptr); break;
185 case LIM_MLM_ASSOC_REQ: limProcessMlmAssocReq(pMac, Msg->bodyptr); break;
186 case LIM_MLM_REASSOC_REQ: limProcessMlmReassocReq(pMac, Msg->bodyptr); break;
187 case LIM_MLM_DISASSOC_REQ: limProcessMlmDisassocReq(pMac, Msg->bodyptr); break;
188 case LIM_MLM_DEAUTH_REQ: limProcessMlmDeauthReq(pMac, Msg->bodyptr); break;
189 case LIM_MLM_SETKEYS_REQ: limProcessMlmSetKeysReq(pMac, Msg->bodyptr); break;
190 case LIM_MLM_REMOVEKEY_REQ: limProcessMlmRemoveKeyReq(pMac, Msg->bodyptr); break;
191 case SIR_LIM_MIN_CHANNEL_TIMEOUT: limProcessMinChannelTimeout(pMac); break;
192 case SIR_LIM_MAX_CHANNEL_TIMEOUT: limProcessMaxChannelTimeout(pMac); break;
193 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
194 limProcessPeriodicProbeReqTimer(pMac); break;
195 case SIR_LIM_JOIN_FAIL_TIMEOUT: limProcessJoinFailureTimeout(pMac); break;
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800196 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
197 limProcessPeriodicJoinProbeReqTimer(pMac); break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 case SIR_LIM_AUTH_FAIL_TIMEOUT: limProcessAuthFailureTimeout(pMac); break;
199 case SIR_LIM_AUTH_RSP_TIMEOUT: limProcessAuthRspTimeout(pMac, Msg->bodyval); break;
200 case SIR_LIM_ASSOC_FAIL_TIMEOUT: limProcessAssocFailureTimeout(pMac, Msg->bodyval); break;
201#ifdef WLAN_FEATURE_VOWIFI_11R
202 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:limProcessFTPreauthRspTimeout(pMac); break;
203#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530204#ifdef WLAN_FEATURE_LFR_MBB
205 case SIR_LIM_PREAUTH_MBB_RSP_TIMEOUT:
206 lim_process_preauth_mbb_rsp_timeout(pMac);
207 break;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530208 case SIR_LIM_REASSOC_MBB_RSP_TIMEOUT:
209 lim_process_reassoc_mbb_rsp_timeout(pMac);
210 break;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530211#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 case SIR_LIM_REMAIN_CHN_TIMEOUT: limProcessRemainOnChnTimeout(pMac); break;
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800213 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
214 limProcessInsertSingleShotNOATimeout(pMac); break;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530215 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
216 limConvertActiveChannelToPassiveChannel(pMac); break;
Sushant Kaushik9e923872015-04-02 17:09:31 +0530217 case SIR_LIM_AUTH_RETRY_TIMEOUT:
218 limProcessAuthRetryTimer(pMac);
219 break;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800220 case SIR_LIM_DISASSOC_ACK_TIMEOUT: limProcessDisassocAckTimeout(pMac); break;
221 case SIR_LIM_DEAUTH_ACK_TIMEOUT: limProcessDeauthAckTimeout(pMac); break;
Abhishek Singh550aa8c2017-10-30 17:34:53 +0530222 case SIR_LIM_SAP_ECSA_TIMEOUT: lim_process_ap_ecsa_timeout(pMac);break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700223 case LIM_MLM_ADDBA_REQ: limProcessMlmAddBAReq( pMac, Msg->bodyptr ); break;
224 case LIM_MLM_ADDBA_RSP: limProcessMlmAddBARsp( pMac, Msg->bodyptr ); break;
225 case LIM_MLM_DELBA_REQ: limProcessMlmDelBAReq( pMac, Msg->bodyptr ); break;
Abhinav Kumar626f8652019-08-05 16:20:39 +0530226 case SIR_LIM_AUTH_SAE_TIMEOUT:
227 lim_process_sae_auth_timeout(pMac);
228 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 case LIM_MLM_TSPEC_REQ:
230 default:
231 break;
232 } // switch (msgType)
233} /*** end limProcessMlmReqMessages() ***/
234
235
236/**
237 * limSetScanMode()
238 *
239 *FUNCTION:
240 * This function is called to setup system into Scan mode
241 *
242 *LOGIC:
243 * NA
244 *
245 *ASSUMPTIONS:
246 * NA
247 *
248 *NOTE:
249 *
250 * @param pMac - Pointer to Global MAC structure
251 * @return None
252 */
253
254void
255limSetScanMode(tpAniSirGlobal pMac)
256{
257 tSirLinkTrafficCheck checkTraffic;
258
259 /// Set current scan channel id to the first in the channel list
260 pMac->lim.gLimCurrentScanChannelId = 0;
261
Jeff Johnson62c27982013-02-27 17:53:55 -0800262 if ( IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) )
263 {
264 checkTraffic = eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
265 }
266 else if (IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac))
267 {
268 checkTraffic = eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
269 }
270 else
271 checkTraffic = eSIR_CHECK_ROAMING_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530273 limLog(pMac, LOG1, FL("Calling limSendHalInitScanReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_SCAN_WAIT_STATE, checkTraffic);
275
276 return ;
277} /*** end limSetScanMode() ***/
278
279//WLAN_SUSPEND_LINK Related
280
281/* limIsLinkSuspended()
282 *
283 *FUNCTION:
284 * This function returns is link is suspended or not.
285 *
286 *LOGIC:
Jeff Johnson62c27982013-02-27 17:53:55 -0800287 * Since Suspend link uses init scan, it just returns
288 * gLimSystemInScanLearnMode flag.
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 *
290 *ASSUMPTIONS:
291 * NA
292 *
293 *NOTE:
294 *
295 * @param pMac - Pointer to Global MAC structure
296 * @return None
297 */
298tANI_U8
299limIsLinkSuspended(tpAniSirGlobal pMac)
300{
301 return pMac->lim.gLimSystemInScanLearnMode;
302}
303/**
304 * limSuspendLink()
305 *
306 *FUNCTION:
307 * This function is called to suspend traffic. Internally this function uses WDA_INIT_SCAN_REQ.
308 *
309 *LOGIC:
310 * NA
311 *
312 *ASSUMPTIONS:
313 * NA
314 *
315 *NOTE:
316 *
317 * @param pMac - Pointer to Global MAC structure
Jeff Johnson62c27982013-02-27 17:53:55 -0800318 * @param trafficCheck - Takes value from enum tSirLinkTrafficCheck.
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 * @param callback - Callback function to be called after suspending the link.
320 * @param data - Pointer to any buffer that will be passed to callback.
321 * @return None
322 */
323void
324limSuspendLink(tpAniSirGlobal pMac, tSirLinkTrafficCheck trafficCheck, 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
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530332 if( pMac->lim.gpLimSuspendCallback ||
333 pMac->lim.gLimSystemInScanLearnMode )
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 {
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700335 limLog( pMac, LOGE, FL("Something is wrong, SuspendLinkCbk:%pK "
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530336 "IsSystemInScanLearnMode:%d"), pMac->lim.gpLimSuspendCallback,
337 pMac->lim.gLimSystemInScanLearnMode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 callback( pMac, eHAL_STATUS_FAILURE, data );
339 return;
340 }
341
342 pMac->lim.gLimSystemInScanLearnMode = 1;
343 pMac->lim.gpLimSuspendCallback = callback;
344 pMac->lim.gpLimSuspendData = data;
345 limSendHalInitScanReq(pMac, eLIM_HAL_SUSPEND_LINK_WAIT_STATE, trafficCheck );
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800346
347 WDA_TrafficStatsTimerActivate(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700348}
349
350/**
351 * limResumeLink()
352 *
353 *FUNCTION:
354 * This function is called to Resume traffic after a suspend. Internally this function uses WDA_FINISH_SCAN_REQ.
355 *
356 *LOGIC:
357 * NA
358 *
359 *ASSUMPTIONS:
360 * NA
361 *
362 *NOTE:
363 *
364 * @param pMac - Pointer to Global MAC structure
365 * @param callback - Callback function to be called after Resuming the link.
366 * @param data - Pointer to any buffer that will be passed to callback.
367 * @return None
368 */
369void
370limResumeLink(tpAniSirGlobal pMac, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
371{
372 if( NULL == callback )
373 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700374 limLog( pMac, LOGE, "%s:%d: Invalid parameters", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 return;
376 }
377
378 if( pMac->lim.gpLimResumeCallback )
379 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700380 limLog( pMac, LOGE, "%s:%d: gLimResumeLink callback is not NULL...something is wrong", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 callback( pMac, eHAL_STATUS_FAILURE, data );
382 return;
383 }
384
385 pMac->lim.gpLimResumeCallback = callback;
386 pMac->lim.gpLimResumeData = data;
Abhishek Singh53bfb332013-12-12 18:03:29 +0530387
388 /* eLIM_HAL_IDLE_SCAN_STATE state indicate limSendHalInitScanReq failed.
389 * In case limSendHalInitScanReq is success, Scanstate would be
390 * eLIM_HAL_SUSPEND_LINK_STATE
391 */
392 if( eLIM_HAL_IDLE_SCAN_STATE != pMac->lim.gLimHalScanState )
393 {
394 limSendHalFinishScanReq(pMac, eLIM_HAL_RESUME_LINK_WAIT_STATE );
395 }
396 else
397 {
398 limLog(pMac, LOGW, FL("Init Scan failed, we will not call finish scan."
399 " calling the callback with failure status"));
400 pMac->lim.gpLimResumeCallback( pMac, eSIR_FAILURE, pMac->lim.gpLimResumeData);
401 pMac->lim.gpLimResumeCallback = NULL;
402 pMac->lim.gpLimResumeData = NULL;
403 pMac->lim.gLimSystemInScanLearnMode = 0;
404 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800405
406 if(limIsInMCC(pMac))
407 {
408 WDA_TrafficStatsTimerActivate(TRUE);
409 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700410}
411//end WLAN_SUSPEND_LINK Related
412
413
414/**
415 *
416 * limChangeChannelWithCallback()
417 *
418 * FUNCTION:
419 * This function is called to change channel and perform off channel operation
420 * if required. The caller registers a callback to be called at the end of the
Jeff Johnson62c27982013-02-27 17:53:55 -0800421 * channel change.
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 *
423 */
424void
425limChangeChannelWithCallback(tpAniSirGlobal pMac, tANI_U8 newChannel,
426 CHANGE_CHANNEL_CALLBACK callback,
427 tANI_U32 *cbdata, tpPESession psessionEntry)
428{
429 // Sanity checks for the current and new channel
430#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700431 PELOGE(limLog( pMac, LOGE, "Switching channel to %d", newChannel);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700432#endif
433 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
434
435 pMac->lim.gpchangeChannelCallback = callback;
436 pMac->lim.gpchangeChannelData = cbdata;
437
438 limSendSwitchChnlParams(pMac, newChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -0700439 PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 psessionEntry->maxTxPower, psessionEntry->peSessionId);
441
442 return;
443}
444
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530445/**
446 * lim_is_spoofing_needed() - Check whether spoofing is needed for scan
447 * @mac: Pointer to mac
448 *
449 * Return: If spoofing is needed then return true else false.
450 */
451static bool lim_is_spoofing_needed(tpAniSirGlobal mac)
452{
453 /*
454 * If mac spoofing response from firmware is not enabled
455 * then disable spoofing.
456 */
457 if (!mac->lim.isSpoofingEnabled)
458 return false;
459
460 /*
461 * If all the octets of spoof mac-address are zero
462 * then disable spoofing.
463 */
464 if (vos_is_macaddr_zero((v_MACADDR_t *)&mac->lim.spoofMacAddr))
465 return false;
466
467 /*
468 * If disableP2PMacSpoof is enabled and scan is P2P scan
469 * then disable spoofing.
470 */
471 if (mac->roam.configParam.disableP2PMacSpoofing &&
472 mac->lim.gpLimMlmScanReq->p2pSearch)
473 return false;
474
475 /* Randomize NL (cfg80211) scan only when scan_randomize is set */
476 if (mac->lim.gpLimMlmScanReq->nl_scan)
477 return mac->lim.gpLimMlmScanReq->scan_randomize;
478
479 /* Randomize all other scans only when spoof_mac_oui is set */
480 return mac->lim.spoof_mac_oui;
481}
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
483/**
484 * limContinuePostChannelScan()
485 *
486 *FUNCTION:
487 * This function is called to scan the current channel.
488 *
489 *LOGIC:
490 *
491 *ASSUMPTIONS:
492 * NA
493 *
494 *NOTE:
495 * NA
496 *
497 * @param pMac - Pointer to Global MAC structure
498 *
499 * @return None
500 */
501
502void limContinuePostChannelScan(tpAniSirGlobal pMac)
503{
504 tANI_U8 channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 tANI_U8 i = 0;
506 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 if( pMac->lim.abortScan || (NULL == pMac->lim.gpLimMlmScanReq ) ||
509 (pMac->lim.gLimCurrentScanChannelId >
510 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)))
511 {
512 pMac->lim.abortScan = 0;
513 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
514 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
515 //Set the resume channel to Any valid channel (invalid).
516 //This will instruct HAL to set it to any previous valid channel.
517 peSetResumeChannel(pMac, 0, 0);
518
519 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
520 return;
521 }
522
523 channelNum = limGetCurrentScanChannel(pMac);
Agarwal Ashish7fed3812014-04-14 15:17:31 +0530524
525 if (channelNum == limGetCurrentOperatingChannel(pMac) &&
526 limIsconnectedOnDFSChannel(channelNum))
527 {
528 limCovertChannelScanType(pMac, channelNum, true);
529 }
530
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 if ((pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN) &&
532 (limActiveScanAllowed(pMac, channelNum)))
533 {
534 TX_TIMER *periodicScanTimer;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -0800536 pMac->lim.probeCounter++;
Abhishek Singh795e1b82015-09-25 15:35:03 +0530537 /* Prepare and send Probe Request frame for all
538 * the SSIDs present in the saved MLM
539 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 do
541 {
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530542 tSirMacAddr gSelfMacAddr;
543 bool spoof = lim_is_spoofing_needed(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +0530544
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530545 if (spoof)
546 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr,
547 VOS_MAC_ADDRESS_LEN);
548 else
549 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr,
550 VOS_MAC_ADDRESS_LEN);
551
Abhishek Singh525045c2014-12-15 17:18:45 +0530552 limLog(pMac, LOG1,
Agarwal Ashishfb3b1c82015-08-18 16:57:31 +0530553 FL(" Mac Addr "MAC_ADDRESS_STR " used in sending ProbeReq number %d, for SSID %s on channel: %d"),
554 MAC_ADDR_ARRAY(gSelfMacAddr) ,i, pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 // include additional IE if there is
556 status = limSendProbeReqMgmtFrame( pMac, &pMac->lim.gpLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +0530557 pMac->lim.gpLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 pMac->lim.gpLimMlmScanReq->dot11mode,
559 pMac->lim.gpLimMlmScanReq->uIEFieldLen,
560 (tANI_U8 *)(pMac->lim.gpLimMlmScanReq)+pMac->lim.gpLimMlmScanReq->uIEFieldOffset);
561
562 if ( status != eSIR_SUCCESS)
563 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700564 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);)
566 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
567 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
568 return;
569 }
570 i++;
571 } while (i < pMac->lim.gpLimMlmScanReq->numSsid);
572
573 {
574#if defined WLAN_FEATURE_VOWIFI
575 //If minChannelTime is set to zero, SME is requesting scan to not use min channel timer.
576 //This is used in 11k to request for beacon measurement request with a fixed duration in
577 //max channel time.
578 if( pMac->lim.gpLimMlmScanReq->minChannelTime != 0 )
579 {
580#endif
581 /// TXP has sent Probe Request
582 /// Activate minChannelTimer
583 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
584
585#ifdef GEN6_TODO
Abhishek Singh95f7b252015-10-14 14:15:35 +0530586 /* revisit this piece of code to assign the appropriate sessionId
587 * below priority - LOW/might not be needed
588 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 pMac->lim.limTimers.gLimMinChannelTimer.sessionId = sessionId;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530590#endif
591 if (tx_timer_activate(&pMac->lim.limTimers.gLimMinChannelTimer) !=
592 TX_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530594 limLog(pMac, LOGE, FL("could not start min channel timer"));
595 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
596 limSendHalEndScanReq(pMac, channelNum,
597 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 return;
599 }
600
601 // Initialize max timer too
602 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +0530603 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer) !=
604 TX_SUCCESS)
605 {
606 limLog(pMac, LOGE, FL("could not start max channel timer"));
607 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
608 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
609 limSendHalEndScanReq(pMac, channelNum,
610 eLIM_HAL_END_SCAN_WAIT_STATE);
611 return;
612 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700613#if defined WLAN_FEATURE_VOWIFI
614 }
615 else
616 {
617#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700618 PELOGE(limLog( pMac, LOGE, "Min channel time == 0, Use only max chan timer" );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700619#endif
620 //No Need to start Min channel timer. Start Max Channel timer.
621 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
622 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
623 == TX_TIMER_ERROR)
624 {
625 /// Could not activate max channel timer.
626 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530627 limLog(pMac,LOGE, FL("could not start max channel timer"));
628 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
629 limSendHalEndScanReq(pMac,
630 channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
631 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 }
633
634 }
635#endif
636 }
637 /* Start peridic timer which will trigger probe req based on min/max
638 channel timer */
639 periodicScanTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
Sachin Ahuja49dedd72014-11-24 16:35:24 +0530640 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 if (tx_timer_activate(periodicScanTimer) != TX_SUCCESS)
642 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530643 limLog(pMac, LOGE, FL("could not start periodic probe req "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700644 "timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 }
646 periodicScanTimer->sessionId = channelNum;
647 }
648 else
649 {
650 tANI_U32 val;
Abhishek Singh525045c2014-12-15 17:18:45 +0530651 limLog(pMac, LOG1, FL("START PASSIVE Scan chan %d"), channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653 /// Passive Scanning. Activate maxChannelTimer
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer)
655 != TX_SUCCESS)
656 {
657 // Could not deactivate max channel timer.
658 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530659 limLog(pMac, LOGE, FL("Unable to deactivate max channel timer"));
660 limSendHalEndScanReq(pMac, channelNum,
661 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 }
663 else
664 {
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530665 if (pMac->miracast_mode)
666 {
667 val = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
668 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
669 }
670 else if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 &val) != eSIR_SUCCESS)
672 {
673 /**
674 * Could not get max channel value
675 * from CFG. Log error.
676 */
Abhishek Singh95f7b252015-10-14 14:15:35 +0530677 limLog(pMac, LOGE,
678 FL("could not retrieve passive max chan value, Use Def val"));
679 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 }
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530681
682 val = SYS_MS_TO_TICKS(val);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530683 if (tx_timer_change(&pMac->lim.limTimers.gLimMaxChannelTimer,
684 val, 0) != TX_SUCCESS)
685 {
686 // Could not change max channel timer.
687 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530688 limLog(pMac, LOGE, FL("Unable to change max channel timer"));
689 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
690 limSendHalEndScanReq(pMac, channelNum,
691 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530692 return;
693 }
Abhishek Singh95f7b252015-10-14 14:15:35 +0530694 else if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
695 != TX_SUCCESS)
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530696 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530697
698 limLog(pMac, LOGE, FL("could not start max channel timer"));
699 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
700 limSendHalEndScanReq(pMac, channelNum,
701 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530702 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 }
704 }
705 // Wait for Beacons to arrive
706 } // if (pMac->lim.gLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
707
Abhishek Singh95f7b252015-10-14 14:15:35 +0530708 limAddScanChannelInfo(pMac, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 return;
710}
711
712
713
714
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530715
716/* limCovertChannelScanType()
717 *
718 *FUNCTION:
719 * This function is called to get the list, change the channel type and set again.
720 *
721 *LOGIC:
722 *
723 *ASSUMPTIONS:
724 * NA
725 *
726 *NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
727 * If a channel is PASSIVE, this fucntion will make it as ACTIVE
728 * NA
729 *
730 * @param pMac - Pointer to Global MAC structure
731 * channelNum - Channel which need to be convert
732 PassiveToActive - Boolean flag to convert channel
733 *
734 * @return None
735 */
736
737
738void limCovertChannelScanType(tpAniSirGlobal pMac,tANI_U8 channelNum, tANI_BOOLEAN passiveToActive)
739{
740
741 tANI_U32 i;
742 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
743 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530744
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530745 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
746 != eSIR_SUCCESS)
747 {
748 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list"));)
749 return ;
750 }
751 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
752 {
753 limLog(pMac, LOGE, FL("Invalid scan control list length:%d"), len);
754 return ;
755 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530756 if (pMac->fActiveScanOnDFSChannels)
757 {
758 limLog(pMac, LOG1, FL("DFS feature triggered,"
759 "block scan type conversion"));
760 return ;
761 }
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530762 for (i=0; (i+1) < len; i+=2)
763 {
764 if (channelPair[i] == channelNum)
765 {
766 if ((eSIR_PASSIVE_SCAN == channelPair[i+1]) && TRUE == passiveToActive)
767 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530768 limLog(pMac, LOG1, FL("Channel %d changed from Passive to Active"),
769 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530770 channelPair[i+1] = eSIR_ACTIVE_SCAN;
771 break ;
772 }
773 if ((eSIR_ACTIVE_SCAN == channelPair[i+1]) && FALSE == passiveToActive)
774 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530775 limLog(pMac, LOG1, FL("Channel %d changed from Active to Passive"),
776 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530777 channelPair[i+1] = eSIR_PASSIVE_SCAN;
778 break ;
779 }
780 }
781 }
782
783 cfgSetStrNotify(pMac, WNI_CFG_SCAN_CONTROL_LIST, (tANI_U8 *)channelPair, len, FALSE);
784 return ;
785}
786
787
788
789
790/* limSetDFSChannelList()
791 *
792 *FUNCTION:
793 * This function is called to convert DFS channel list to active channel list when any
794 * beacon is present on that channel. This function store time for passive channels
795 * which help to know that for how much time channel has been passive.
796 *
797 *LOGIC:
798 *
799 *ASSUMPTIONS:
800 * NA
801 *
802 *NOTE: If a channel is ACTIVE, it won't store any time
803 * If a channel is PAssive, it will store time as timestamp
804 * NA
805 *
806 * @param pMac - Pointer to Global MAC structure
807 * dfsChannelList - DFS channel list.
808 * @return None
809 */
810
811void limSetDFSChannelList(tpAniSirGlobal pMac,tANI_U8 channelNum, tSirDFSChannelList *dfsChannelList)
812{
813
814 tANI_BOOLEAN passiveToActive = TRUE;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530815 tANI_U32 cfgVal;
816
817 if (eSIR_SUCCESS == wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON,
818 &cfgVal))
819 {
820 limLog(pMac, LOG1, FL("WNI_CFG_ACTIVE_PASSIVE_CON: %d"), cfgVal);
821 if (!cfgVal)
822 return;
823 }
824
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530825 if ((1 <= channelNum) && (165 >= channelNum))
826 {
827 if (eANI_BOOLEAN_TRUE == limIsconnectedOnDFSChannel(channelNum))
828 {
829 if (dfsChannelList->timeStamp[channelNum] == 0)
830 {
831 //Received first beacon; Convert DFS channel to Active channel.
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530832 limLog(pMac, LOG1, FL("Received first beacon on DFS channel: %d"), channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530833 limCovertChannelScanType(pMac,channelNum, passiveToActive);
834 }
Abhishek Singh6fcdf652016-11-23 10:59:12 +0530835
836 if (!pMac->fActiveScanOnDFSChannels &&
837 dfsChannelList->timeStamp[channelNum] &&
838 !limActiveScanAllowed(pMac, channelNum))
839 limLog(pMac, LOGE,
840 FL("Received beacon on DFS channel %d with dfs time stamp %lu, but channel is still DFS"),
841 channelNum, dfsChannelList->timeStamp[channelNum]);
842
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530843 dfsChannelList->timeStamp[channelNum] = vos_timer_get_system_time();
844 }
845 else
846 {
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530847 return;
848 }
849 if (!tx_timer_running(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer))
850 {
851 tx_timer_activate(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer);
852 }
853 }
854 else
855 {
856 PELOGE(limLog(pMac, LOGE, FL("Invalid Channel: %d"), channelNum);)
857 return;
858 }
859
860 return;
861}
862
Paul Zhang83289792017-02-28 18:58:52 +0800863void limDoSendAuthMgmtFrame(tpAniSirGlobal pMac, tpPESession psessionEntry)
864{
865 tSirMacAuthFrameBody authFrameBody;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530866
Abhinav Kumar6920f5a2019-08-05 18:55:11 +0530867 /* Mark auth algo as open when auth type is SAE and PMK is cached */
868 if ((pMac->lim.gpLimMlmAuthReq->authType == eSIR_AUTH_TYPE_SAE) &&
869 psessionEntry->sae_pmk_cached) {
870 authFrameBody.authAlgoNumber = eSIR_OPEN_SYSTEM;
871 } else {
872 authFrameBody.authAlgoNumber =
873 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
874 }
Paul Zhang83289792017-02-28 18:58:52 +0800875 //Prepare & send Authentication frame
Paul Zhang83289792017-02-28 18:58:52 +0800876 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
877 authFrameBody.authStatusCode = 0;
878 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
879 limSendAuthMgmtFrame(pMac,
880 &authFrameBody,
881 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
882 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
883 if (tx_timer_activate(&pMac->lim.limTimers.gLimAuthFailureTimer)
884 != TX_SUCCESS) {
885 //Could not start Auth failure timer.
886 //Log error
887 limLog(pMac, LOGP,
888 FL("could not start Auth failure timer"));
889 //Cleanup as if auth timer expired
890 limProcessAuthFailureTimeout(pMac);
891 } else {
892 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE,
893 psessionEntry->peSessionId, eLIM_AUTH_RETRY_TIMER));
894 //Activate Auth Retry timer
895 if (tx_timer_activate
896 (&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
897 != TX_SUCCESS) {
898 limLog(pMac, LOGP,
899 FL("could not activate Auth Retry timer"));
900 }
901 }
902 return;
903}
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905/*
906* Creates a Raw frame to be sent before every Scan, if required.
907* If only infra link is active (mlmState = Link Estb), then send Data Null
908* If only BT-AMP-AP link is active(mlmState = BSS_STARTED), then send CTS2Self frame.
909* If only BT-AMP-STA link is active(mlmState = BSS_STARTED or Link Est) then send CTS2Self
910* If Only IBSS link is active, then send CTS2Self
911* for concurrent scenario: Infra+BT or Infra+IBSS, always send CTS2Self, no need to send Data Null
912*
913*/
914static void __limCreateInitScanRawFrame(tpAniSirGlobal pMac,
915 tpInitScanParams pInitScanParam)
916{
917 tANI_U8 i;
918 pInitScanParam->scanEntry.activeBSScnt = 0;
919
920 /* Don't send CTS to self as we have issue with BTQM queues where BTQM can
921 * not handle transmition of CTS2self frames. Sending CTS 2 self at this
922 * juncture also doesn't serve much purpose as probe request frames go out
923 * immediately, No need to notify BSS in IBSS case.
924 * */
925
926 for(i =0; i < pMac->lim.maxBssId; i++)
927 {
928 if(pMac->lim.gpSession[i].valid == TRUE)
929 {
930 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
931 {
932 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
933 (pInitScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
934 {
935 pInitScanParam->scanEntry.bssIdx[pInitScanParam->scanEntry.activeBSScnt]
936 = pMac->lim.gpSession[i].bssIdx;
937 pInitScanParam->scanEntry.activeBSScnt++;
938
939 }
940 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 else if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
942 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
943 )
944 {
945 pInitScanParam->useNoA = TRUE;
946 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
948 }
949 if (pInitScanParam->scanEntry.activeBSScnt)
950 {
951 pInitScanParam->notifyBss = TRUE;
952 pInitScanParam->frameType = SIR_MAC_DATA_FRAME;
953 pInitScanParam->frameLength = 0;
954 }
955}
956
957/*
958* Creates a Raw frame to be sent during finish scan, if required.
959* Send data null frame, only when there is just one session active and that session is
960* in 'link Estb' state.
961* if more than one session is active, don't send any frame.
962* for concurrent scenario: Infra+BT or Infra+IBSS, no need to send Data Null
963*
964*/
965static void __limCreateFinishScanRawFrame(tpAniSirGlobal pMac,
966 tpFinishScanParams pFinishScanParam)
967{
968 tANI_U8 i;
969 pFinishScanParam->scanEntry.activeBSScnt = 0;
970
971 for(i =0; i < pMac->lim.maxBssId; i++)
972 {
973 if(pMac->lim.gpSession[i].valid == TRUE)
974 {
975 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
976 {
977 //BT-STA can either be in LINK-ESTB state or BSS_STARTED State
978 //for BT, need to send CTS2Self
979 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
980 (pFinishScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
981 {
982 pFinishScanParam->scanEntry.bssIdx[pFinishScanParam->scanEntry.activeBSScnt]
983 = pMac->lim.gpSession[i].bssIdx;
984 pFinishScanParam->scanEntry.activeBSScnt++;
985 }
986 }
987 }
988 }
989
990 if (pFinishScanParam->scanEntry.activeBSScnt)
991 {
992 pFinishScanParam->notifyBss = TRUE;
993 pFinishScanParam->frameType = SIR_MAC_DATA_FRAME;
994 pFinishScanParam->frameLength = 0;
995 }
996}
997
998void
999limSendHalInitScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState, tSirLinkTrafficCheck trafficCheck)
1000{
1001
1002
1003 tSirMsgQ msg;
1004 tpInitScanParams pInitScanParam;
1005 tSirRetStatus rc = eSIR_SUCCESS;
1006
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301007 pInitScanParam = vos_mem_malloc(sizeof(*pInitScanParam));
1008 if ( NULL == pInitScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301010 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 goto error;
1012 }
1013
1014 /*Initialize the pInitScanParam with 0*/
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301015 vos_mem_set((tANI_U8 *)pInitScanParam, sizeof(*pInitScanParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001016
1017 msg.type = WDA_INIT_SCAN_REQ;
1018 msg.bodyptr = pInitScanParam;
1019 msg.bodyval = 0;
1020
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301021 vos_mem_set((tANI_U8 *)&pInitScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 if (nextState == eLIM_HAL_INIT_LEARN_WAIT_STATE)
1023 {
1024 pInitScanParam->notifyBss = TRUE;
1025 pInitScanParam->notifyHost = FALSE;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -07001026 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
1027 {
1028 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
1029 }
1030 else
1031 {
1032 pInitScanParam->scanMode = eHAL_SYS_MODE_LEARN;
1033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001034
Jeff Johnsone7245742012-09-05 17:12:55 -07001035 pInitScanParam->frameType = SIR_MAC_CTRL_CTS;
1036 __limCreateInitScanRawFrame(pMac, pInitScanParam);
1037 pInitScanParam->checkLinkTraffic = trafficCheck;
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 }
1039 else
1040 {
1041 if(nextState == eLIM_HAL_SUSPEND_LINK_WAIT_STATE)
1042 {
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -07001043 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
1044 {
1045 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SUSPEND_LINK;
1046 }
1047 else
1048 {
1049 pInitScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
1050 }
1051
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 }
1053 else
1054 {
Madan Mohan Koyyalamudi94d111d2012-11-19 20:11:26 -08001055 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
1056 {
1057 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
1058 }
1059 else
1060 {
1061 pInitScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 }
1064 __limCreateInitScanRawFrame(pMac, pInitScanParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 if (pInitScanParam->useNoA)
1066 {
1067 pInitScanParam->scanDuration = pMac->lim.gTotalScanDuration;
1068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 /* Inform HAL whether it should check for traffic on the link
1070 * prior to performing a background scan
1071 */
1072 pInitScanParam->checkLinkTraffic = trafficCheck;
1073 }
1074
1075 pMac->lim.gLimHalScanState = nextState;
1076 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001077 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001078
1079 rc = wdaPostCtrlMsg(pMac, &msg);
1080 if (rc == eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001081 PELOG3(limLog(pMac, LOG3, FL("wdaPostCtrlMsg() return eSIR_SUCCESS pMac=%x nextState=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 pMac, pMac->lim.gLimHalScanState);)
1083 return;
1084 }
1085
1086 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301087 vos_mem_free(pInitScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001088 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001089
1090error:
1091 switch(nextState)
1092 {
1093 case eLIM_HAL_START_SCAN_WAIT_STATE:
Padma, Santhosh Kumar9a3eea12015-02-18 14:05:03 +05301094 case eLIM_HAL_INIT_SCAN_WAIT_STATE:
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1096 break;
1097
Jeff Johnson295189b2012-06-20 16:38:30 -07001098
1099 //WLAN_SUSPEND_LINK Related
1100 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
1101 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1102 if( pMac->lim.gpLimSuspendCallback )
1103 {
1104 pMac->lim.gpLimSuspendCallback( pMac, rc, pMac->lim.gpLimSuspendData );
1105 pMac->lim.gpLimSuspendCallback = NULL;
1106 pMac->lim.gpLimSuspendData = NULL;
1107 }
1108 pMac->lim.gLimSystemInScanLearnMode = 0;
1109 break;
1110 //end WLAN_SUSPEND_LINK Related
1111 default:
1112 break;
1113 }
1114 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1115
1116 return ;
1117}
1118
1119void
1120limSendHalStartScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1121{
1122 tSirMsgQ msg;
1123 tpStartScanParams pStartScanParam;
1124 tSirRetStatus rc = eSIR_SUCCESS;
1125
1126 /**
1127 * The Start scan request to be sent only if Start Scan is not already requested
1128 */
1129 if(pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE)
1130 {
1131
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301132 pStartScanParam = vos_mem_malloc(sizeof(*pStartScanParam));
1133 if ( NULL == pStartScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301135 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 goto error;
1137 }
1138
1139 msg.type = WDA_START_SCAN_REQ;
1140 msg.bodyptr = pStartScanParam;
1141 msg.bodyval = 0;
1142 pStartScanParam->status = eHAL_STATUS_SUCCESS;
1143 pStartScanParam->scanChannel = (tANI_U8)channelNum;
1144
1145 pMac->lim.gLimHalScanState = nextState;
1146 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1147
Jeff Johnsone7245742012-09-05 17:12:55 -07001148 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001149
1150 rc = wdaPostCtrlMsg(pMac, &msg);
1151 if (rc == eSIR_SUCCESS) {
1152 return;
1153 }
1154
1155 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301156 vos_mem_free(pStartScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001157 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001158
1159error:
1160 switch(nextState)
1161 {
1162 case eLIM_HAL_START_SCAN_WAIT_STATE:
1163 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1164 break;
1165
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 default:
1168 break;
1169 }
1170 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1171
1172 }
1173 else
1174 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001175 PELOGW(limLog(pMac, LOGW, FL("Invalid state for START_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 }
1177
1178 return;
1179}
1180
1181void limSendHalEndScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1182{
1183 tSirMsgQ msg;
1184 tpEndScanParams pEndScanParam;
1185 tSirRetStatus rc = eSIR_SUCCESS;
1186
1187 /**
1188 * 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 -07001189 * Start scan is not already requestd.
1190 * after finish scan rsp from firmware host is sending endscan request so adding
1191 * check for IDLE SCAN STATE also added to avoid this issue
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 */
1193 if((pMac->lim.gLimHalScanState != eLIM_HAL_END_SCAN_WAIT_STATE) &&
Leela Venkata Kiran Kumar Reddy Chirala66639a62013-08-29 15:38:19 -07001194 (pMac->lim.gLimHalScanState != eLIM_HAL_IDLE_SCAN_STATE) &&
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07001195 (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE) &&
1196 (pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE) &&
1197 (pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE))
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301198 {
1199 pEndScanParam = vos_mem_malloc(sizeof(*pEndScanParam));
1200 if ( NULL == pEndScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301202 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 goto error;
1204 }
1205
1206 msg.type = WDA_END_SCAN_REQ;
1207 msg.bodyptr = pEndScanParam;
1208 msg.bodyval = 0;
1209 pEndScanParam->status = eHAL_STATUS_SUCCESS;
1210 pEndScanParam->scanChannel = (tANI_U8)channelNum;
1211
1212 pMac->lim.gLimHalScanState = nextState;
1213 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001214 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001215
1216 rc = wdaPostCtrlMsg(pMac, &msg);
1217 if (rc == eSIR_SUCCESS) {
1218 return;
1219 }
1220
1221 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301222 vos_mem_free(pEndScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001223 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001224
1225 error:
1226 switch(nextState)
1227 {
1228 case eLIM_HAL_END_SCAN_WAIT_STATE:
1229 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_END_FAILED);
1230 break;
1231
Jeff Johnson295189b2012-06-20 16:38:30 -07001232
1233 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001234 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg Rcvd invalid nextState %d"), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 break;
1236 }
1237 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001238 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 }
1240 else
1241 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001242 PELOGW(limLog(pMac, LOGW, FL("Invalid state for END_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001243 }
1244
1245
1246 return;
1247}
1248
Bhargav Shahe3a6ff02016-04-11 16:31:49 +05301249
1250void limSendTLPauseInd(tpAniSirGlobal pMac, uint16_t staId)
1251{
1252 tSirMsgQ msg;
1253 tSirRetStatus rc = eSIR_SUCCESS;
1254
1255 msg.type = WDA_PAUSE_TL_IND;
1256 msg.bodyval = staId;
1257
1258 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1259
1260 rc = wdaPostCtrlMsg(pMac, &msg);
1261 if (rc == eSIR_SUCCESS) {
1262 return;
1263 }
1264
1265 limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);
1266
1267 return;
1268}
1269
Jeff Johnson295189b2012-06-20 16:38:30 -07001270/**
1271 * limSendHalFinishScanReq()
1272 *
1273 *FUNCTION:
1274 * This function is called to finish scan/learn request..
1275 *
1276 *LOGIC:
1277 *
1278 *ASSUMPTIONS:
1279 * NA
1280 *
1281 *NOTE:
1282 * NA
1283 *
1284 * @param pMac - Pointer to Global MAC structure
1285 * @param nextState - this parameters determines whether this call is for scan or learn
1286 *
1287 * @return None
1288 */
1289void limSendHalFinishScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState)
1290{
1291
1292 tSirMsgQ msg;
1293 tpFinishScanParams pFinishScanParam;
1294 tSirRetStatus rc = eSIR_SUCCESS;
1295
1296 if(pMac->lim.gLimHalScanState == nextState)
1297 {
1298 /*
1299 * PE may receive multiple probe responses, while waiting for HAL to send 'FINISH_SCAN_RSP' message
1300 * PE was sending multiple finish scan req messages to HAL
1301 * this check will avoid that.
1302 * If PE is already waiting for the 'finish_scan_rsp' message from HAL, it will ignore this request.
1303 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001304 PELOGW(limLog(pMac, LOGW, FL("Next Scan State is same as the current state: %d "), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 return;
1306 }
1307
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301308 pFinishScanParam = vos_mem_malloc(sizeof(*pFinishScanParam));
1309 if ( NULL == pFinishScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301311 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 goto error;
1313 }
1314
1315 msg.type = WDA_FINISH_SCAN_REQ;
1316 msg.bodyptr = pFinishScanParam;
1317 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001318
1319 peGetResumeChannel(pMac, &pFinishScanParam->currentOperChannel, &pFinishScanParam->cbState);
1320
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301321 vos_mem_set((tANI_U8 *)&pFinishScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
1323 if (nextState == eLIM_HAL_FINISH_LEARN_WAIT_STATE)
1324 {
1325 //AP - No pkt need to be transmitted
1326 pFinishScanParam->scanMode = eHAL_SYS_MODE_LEARN;
1327 pFinishScanParam->notifyBss = FALSE;
1328 pFinishScanParam->notifyHost = FALSE;
1329 pFinishScanParam->frameType = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001330
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 pFinishScanParam->frameLength = 0;
1332 pMac->lim.gLimHalScanState = nextState;
1333 }
1334 else
1335 {
1336 /* If STA is associated with an AP (ie. STA is in
1337 * LINK_ESTABLISHED state), then STA need to inform
1338 * the AP via either DATA-NULL
1339 */
1340 if (nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE)
1341 {
1342 pFinishScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
1343 }
1344 else
1345 {
1346 pFinishScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1347 }
1348 pFinishScanParam->notifyHost = FALSE;
1349 __limCreateFinishScanRawFrame(pMac, pFinishScanParam);
1350 //WLAN_SUSPEND_LINK Related
1351 pMac->lim.gLimHalScanState = nextState;
1352 //end WLAN_SUSPEND_LINK Related
1353 }
1354
1355 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001356 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001357
1358 rc = wdaPostCtrlMsg(pMac, &msg);
1359 if (rc == eSIR_SUCCESS) {
1360 return;
1361 }
1362 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301363 vos_mem_free(pFinishScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001364 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366 error:
1367 if(nextState == eLIM_HAL_FINISH_SCAN_WAIT_STATE)
1368 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_FINISH_FAILED);
1369 //WLAN_SUSPEND_LINK Related
1370 else if ( nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE )
1371 {
1372 if( pMac->lim.gpLimResumeCallback )
1373 {
1374 pMac->lim.gpLimResumeCallback( pMac, rc, pMac->lim.gpLimResumeData );
1375 pMac->lim.gpLimResumeCallback = NULL;
1376 pMac->lim.gpLimResumeData = NULL;
1377 pMac->lim.gLimSystemInScanLearnMode = 0;
1378 }
1379 }
1380 //end WLAN_SUSPEND_LINK Related
1381 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1382 return;
1383}
1384
1385/**
1386 * limContinueChannelScan()
1387 *
1388 *FUNCTION:
1389 * This function is called by limPerformChannelScan().
1390 * This function is called to continue channel scanning when
1391 * Beacon/Probe Response frame are received.
1392 *
1393 *LOGIC:
1394 * Scan criteria stored in pMac->lim.gLimMlmScanReq is used
1395 * to perform channel scan. In this function MLM sub module
1396 * makes channel switch, sends PROBE REQUEST frame in case of
1397 * ACTIVE SCANNING, starts min/max channel timers, programs
1398 * NAV to probeDelay timer and waits for Beacon/Probe Response.
1399 * Once all required channels are scanned, LIM_MLM_SCAN_CNF
1400 * primitive is used to send Scan results to SME sub module.
1401 *
1402 *ASSUMPTIONS:
1403 * 1. In case of Active scanning, start MAX channel time iff
1404 * MIN channel timer expired and activity is observed on
1405 * the channel.
1406 *
1407 *NOTE:
1408 * NA
1409 *
1410 * @param pMac Pointer to Global MAC structure
1411 * @return None
1412 */
1413void
1414limContinueChannelScan(tpAniSirGlobal pMac)
1415{
1416 tANI_U8 channelNum;
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if (pMac->lim.gLimCurrentScanChannelId >
1419 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)
1420 || pMac->lim.abortScan)
1421 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 pMac->lim.abortScan = 0;
1423 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1424 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1425
1426 //Set the resume channel to Any valid channel (invalid).
1427 //This will instruct HAL to set it to any previous valid channel.
1428 peSetResumeChannel(pMac, 0, 0);
1429
1430 /// Done scanning all required channels
1431 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 return;
1433 }
1434
1435 /// Atleast one more channel is to be scanned
1436
1437 if ((pMac->lim.gLimReturnAfterFirstMatch & 0x40) ||
1438 (pMac->lim.gLimReturnAfterFirstMatch & 0x80))
1439 {
1440 while (pMac->lim.gLimCurrentScanChannelId <=
1441 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1442 {
1443 if (((limGetCurrentScanChannel(pMac) <= 14) &&
1444 pMac->lim.gLim24Band11dScanDone) ||
1445 ((limGetCurrentScanChannel(pMac) > 14) &&
1446 pMac->lim.gLim50Band11dScanDone))
1447 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001448 limLog(pMac, LOGW, FL("skipping chan %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 limGetCurrentScanChannel(pMac));
1450 pMac->lim.gLimCurrentScanChannelId++;
1451 }
1452 else
1453 break;
1454 }
1455
1456 if (pMac->lim.gLimCurrentScanChannelId >
1457 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1458 {
1459 pMac->lim.abortScan = 0;
1460 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1461 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1462 /// Done scanning all required channels
1463 //Set the resume channel to Any valid channel (invalid).
1464 //This will instruct HAL to set it to any previous valid channel.
1465 peSetResumeChannel(pMac, 0, 0);
1466 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
1467 return;
1468 }
1469 }
1470
1471 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh525045c2014-12-15 17:18:45 +05301472 limLog(pMac, LOG1, FL("Current Channel to be scanned is %d"),
1473 channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07001474
1475 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_SCAN_WAIT_STATE);
1476 return;
1477} /*** end limContinueChannelScan() ***/
1478
1479
1480
1481/**
1482 * limRestorePreScanState()
1483 *
1484 *FUNCTION:
1485 * This function is called by limContinueChannelScan()
1486 * to restore HW state prior to entering 'scan state'
1487 *
1488 *LOGIC
1489 *
1490 *ASSUMPTIONS:
1491 *
1492 *NOTE:
1493 * NA
1494 *
1495 * @param pMac Pointer to Global MAC structure
1496 * @return None
1497 */
1498void
1499limRestorePreScanState(tpAniSirGlobal pMac)
1500{
1501 int i;
1502
1503 /// Deactivate MIN/MAX channel timers if running
1504 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1505 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1506
1507 /* Re-activate Heartbeat timers for connected sessions as scan
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001508 * is done if the DUT is in active mode
1509 * AND it is not a ROAMING ("background") scan */
1510 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 (ePMM_STATE_READY == pMac->pmm.gPmmState))
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001512 && (pMac->lim.gLimBackgroundScanMode != eSIR_ROAMING_SCAN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 {
1514 for(i=0;i<pMac->lim.maxBssId;i++)
1515 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001516 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1517 (pMac->lim.gpSession[i].valid == TRUE) &&
Yathish9f22e662012-12-10 14:21:35 -08001518 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState) &&
1519 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 {
1521 limReactivateHeartBeatTimer(pMac, peFindSessionBySessionId(pMac,i));
1522 }
1523 }
1524 }
1525
1526 /**
1527 * clean up message queue.
1528 * If SME messages, redirect to deferred queue.
1529 * The rest will be discarded.
1530 */
1531 //limCleanupMsgQ(pMac);
1532
1533 pMac->lim.gLimSystemInScanLearnMode = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301534 limLog(pMac, LOG1, FL("Scan ended, took %ld tu"),
1535 (tx_time_get() - pMac->lim.scanStartTime));
Jeff Johnson295189b2012-06-20 16:38:30 -07001536} /*** limRestorePreScanState() ***/
1537
Jeff Johnsone7245742012-09-05 17:12:55 -07001538#ifdef FEATURE_OEM_DATA_SUPPORT
1539
1540void limSendHalOemDataReq(tpAniSirGlobal pMac)
1541{
1542 tSirMsgQ msg;
1543 tpStartOemDataReq pStartOemDataReq = NULL;
1544 tSirRetStatus rc = eSIR_SUCCESS;
1545 tpLimMlmOemDataRsp pMlmOemDataRsp;
1546 tANI_U32 reqLen = 0;
1547 if(NULL == pMac->lim.gpLimMlmOemDataReq)
1548 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001549 PELOGE(limLog(pMac, LOGE, FL("Null pointer"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001550 goto error;
1551 }
1552
1553 reqLen = sizeof(tStartOemDataReq);
1554
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301555 pStartOemDataReq = vos_mem_malloc(reqLen);
1556 if ( NULL == pStartOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001558 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Could not allocate memory for pStartOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001559 goto error;
1560 }
1561
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301562 vos_mem_set((tANI_U8*)(pStartOemDataReq), reqLen, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001563
1564 //Now copy over the information to the OEM DATA REQ to HAL
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301565 vos_mem_copy(pStartOemDataReq->selfMacAddr,
1566 pMac->lim.gpLimMlmOemDataReq->selfMacAddr,
1567 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07001568
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301569 vos_mem_copy(pStartOemDataReq->oemDataReq,
1570 pMac->lim.gpLimMlmOemDataReq->oemDataReq,
1571 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001572
1573 //Create the message to be passed to HAL
1574 msg.type = WDA_START_OEM_DATA_REQ;
1575 msg.bodyptr = pStartOemDataReq;
1576 msg.bodyval = 0;
1577
1578 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1579 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1580
1581 rc = wdaPostCtrlMsg(pMac, &msg);
1582 if(rc == eSIR_SUCCESS)
1583 {
1584 return;
1585 }
1586
1587 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301588 vos_mem_free(pStartOemDataReq);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001589 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: posting WDA_START_OEM_DATA_REQ to HAL failed"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001590
1591error:
1592 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001593 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001594
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301595 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1596 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001597 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001598 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001599 return;
1600 }
1601
1602 if(NULL != pMac->lim.gpLimMlmOemDataReq)
1603 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301604 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001605 pMac->lim.gpLimMlmOemDataReq = NULL;
1606 }
1607
1608 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1609
1610 return;
1611}
1612/**
1613 * limSetOemDataReqModeFailed()
1614 *
1615 * FUNCTION:
1616 * This function is used as callback to resume link after the suspend fails while
1617 * starting oem data req mode.
1618 * LOGIC:
1619 * NA
1620 *
1621 * ASSUMPTIONS:
1622 * NA
1623 *
1624 * NOTE:
1625 *
1626 * @param pMac - Pointer to Global MAC structure
1627 * @return None
1628 */
1629
1630void limSetOemDataReqModeFailed(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1631{
1632 tpLimMlmOemDataRsp pMlmOemDataRsp;
1633
1634 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001635 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001636
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301637 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1638 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001640 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001641 return;
1642 }
1643
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301644 if (NULL != pMac->lim.gpLimMlmOemDataReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07001645 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301646 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 pMac->lim.gpLimMlmOemDataReq = NULL;
1648 }
1649
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301650 vos_mem_set(pMlmOemDataRsp, sizeof(tLimMlmOemDataRsp), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001651
1652 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1653
1654 return;
1655}
1656
1657/**
1658 * limSetOemDataReqMode()
1659 *
1660 *FUNCTION:
1661 * This function is called to setup system into OEM DATA REQ mode
1662 *
1663 *LOGIC:
1664 * NA
1665 *
1666 *ASSUMPTIONS:
1667 * NA
1668 *
1669 *NOTE:
1670 *
1671 * @param pMac - Pointer to Global MAC structure
1672 * @return None
1673 */
1674
1675void limSetOemDataReqMode(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1676{
1677 if(status != eHAL_STATUS_SUCCESS)
1678 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001679 limLog(pMac, LOGE, FL("OEM_DATA: failed in suspend link"));
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301680 /* If failed to suspend the link, there is no need
1681 * to resume link. Return failure.
1682 */
1683 limSetOemDataReqModeFailed(pMac, status, data);
Jeff Johnsone7245742012-09-05 17:12:55 -07001684 }
1685 else
1686 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001687 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Calling limSendHalOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001688 limSendHalOemDataReq(pMac);
Jeff Johnsone7245742012-09-05 17:12:55 -07001689 }
1690
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301691 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001692} /*** end limSendHalOemDataReq() ***/
1693
1694#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001695
1696static void
1697mlm_add_sta(
1698 tpAniSirGlobal pMac,
1699 tpAddStaParams pSta,
1700 tANI_U8 *pBssid,
1701 tANI_U8 htCapable,
1702 tpPESession psessionEntry) //psessionEntry may required in future
1703{
1704 tANI_U32 val;
1705 int i;
1706
1707
1708 pSta->staType = STA_ENTRY_SELF; // Identifying self
1709
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301710 vos_mem_copy(pSta->bssId, pBssid, sizeof( tSirMacAddr ));
1711 vos_mem_copy(pSta->staMac, psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001712
1713 /* Configuration related parameters to be changed to support BT-AMP */
1714
1715 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_LISTEN_INTERVAL, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001716 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001717
1718 pSta->listenInterval = (tANI_U16) val;
1719
1720 if (eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) )
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001721 limLog(pMac, LOGP, FL("Couldn't get SHORT_PREAMBLE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 pSta->shortPreambleSupported = (tANI_U8)val;
1723
1724 pSta->assocId = 0; // Is SMAC OK with this?
1725 pSta->wmmEnabled = 0;
1726 pSta->uAPSD = 0;
1727 pSta->maxSPLen = 0;
1728 pSta->us32MaxAmpduDuration = 0;
1729 pSta->maxAmpduSize = 0; // 0: 8k, 1: 16k,2: 32k,3: 64k
1730
1731
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001732 /* For Self STA get the LDPC capability from config.ini*/
1733 pSta->htLdpcCapable =
1734 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
1735 pSta->vhtLdpcCapable =
1736 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
1737
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1739 {
1740 pSta->htCapable = htCapable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 pSta->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
1742 pSta->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry );
1743 pSta->mimoPS = (tSirMacHTMIMOPowerSaveState)limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
1744 pSta->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
1745 pSta->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
1746 pSta->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
1747 pSta->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
1748 pSta->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
1749 pSta->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
1750 pSta->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
1751 pSta->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001753#ifdef WLAN_FEATURE_11AC
1754 if (psessionEntry->vhtCapability)
1755 {
1756 pSta->vhtCapable = VOS_TRUE;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001757 pSta->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001758 }
1759#endif
1760#ifdef WLAN_FEATURE_11AC
1761 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry,NULL);
1762#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 limFillSupportedRatesInfo(pMac, NULL, &pSta->supportedRates,psessionEntry);
1766
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001767 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 -07001768 pSta->greenFieldCapable, pSta->txChannelWidthSet, pSta->mimoPS, pSta->lsigTxopProtection,
1769 pSta->fDsssCckMode40Mhz,pSta->fShortGI20Mhz, pSta->fShortGI40Mhz);
1770
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 if (VOS_P2P_GO_MODE == psessionEntry->pePersona)
1772 {
1773 pSta->p2pCapableSta = 1;
1774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001775
1776 //Disable BA. It will be set as part of ADDBA negotiation.
1777 for( i = 0; i < STACFG_MAX_TC; i++ )
1778 {
1779 pSta->staTCParams[i].txUseBA = eBA_DISABLE;
1780 pSta->staTCParams[i].rxUseBA = eBA_DISABLE;
1781 }
1782
1783}
1784
1785//
1786// New HAL interface - WDA_ADD_BSS_REQ
1787// Package WDA_ADD_BSS_REQ to HAL, in order to start a BSS
1788//
1789tSirResultCodes
1790limMlmAddBss (
1791 tpAniSirGlobal pMac,
1792 tLimMlmStartReq *pMlmStartReq,
1793 tpPESession psessionEntry)
1794{
1795 tSirMsgQ msgQ;
1796 tpAddBssParams pAddBssParams = NULL;
1797 tANI_U32 retCode;
1798
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 // Package WDA_ADD_BSS_REQ message parameters
1800
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301801 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
1802 if ( NULL == pAddBssParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301804 limLog( pMac, LOGE, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 // Respond to SME with LIM_MLM_START_CNF
1806 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1807 }
1808
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301809 vos_mem_set(pAddBssParams, sizeof(tAddBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001810
1811 // Fill in tAddBssParams members
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301812 vos_mem_copy(pAddBssParams->bssId, pMlmStartReq->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 sizeof( tSirMacAddr ));
1814
1815 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301816 vos_mem_copy (pAddBssParams->selfMacAddr,
1817 psessionEntry->selfMacAddr,
1818 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001819
1820 pAddBssParams->bssType = pMlmStartReq->bssType;
1821 if ((pMlmStartReq->bssType == eSIR_IBSS_MODE) ||
1822 (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE)||
1823 (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE)) {
1824 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
1825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 else if (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE){
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_AP;
1828 }
1829
Jeff Johnsone7245742012-09-05 17:12:55 -07001830 pAddBssParams->shortSlotTimeSupported = psessionEntry->shortSlotTimeSupported;
Jeff Johnson295189b2012-06-20 16:38:30 -07001831
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 pAddBssParams->beaconInterval = pMlmStartReq->beaconPeriod;
1833 pAddBssParams->dtimPeriod = pMlmStartReq->dtimPeriod;
1834 pAddBssParams->cfParamSet.cfpCount = pMlmStartReq->cfParamSet.cfpCount;
1835 pAddBssParams->cfParamSet.cfpPeriod = pMlmStartReq->cfParamSet.cfpPeriod;
1836 pAddBssParams->cfParamSet.cfpMaxDuration = pMlmStartReq->cfParamSet.cfpMaxDuration;
1837 pAddBssParams->cfParamSet.cfpDurRemaining = pMlmStartReq->cfParamSet.cfpDurRemaining;
1838
1839 pAddBssParams->rateSet.numRates = pMlmStartReq->rateSet.numRates;
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301840 if (pAddBssParams->rateSet.numRates > SIR_MAC_RATESET_EID_MAX) {
1841 limLog(pMac, LOGW,
1842 FL("num of sup rates %d exceeding the limit %d, resetting"),
1843 pAddBssParams->rateSet.numRates,
1844 SIR_MAC_RATESET_EID_MAX);
1845 pAddBssParams->rateSet.numRates = SIR_MAC_RATESET_EID_MAX;
1846 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301847 vos_mem_copy(pAddBssParams->rateSet.rate,
lifeng62aa8d52018-08-09 18:38:43 +08001848 pMlmStartReq->rateSet.rate, pAddBssParams->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07001849
1850 pAddBssParams->nwType = pMlmStartReq->nwType;
1851
1852 pAddBssParams->htCapable = pMlmStartReq->htCapable;
Jeff Johnsone7245742012-09-05 17:12:55 -07001853#ifdef WLAN_FEATURE_11AC
1854 pAddBssParams->vhtCapable = psessionEntry->vhtCapability;
1855 pAddBssParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
1856#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 pAddBssParams->htOperMode = pMlmStartReq->htOperMode;
1858 pAddBssParams->dualCTSProtection = pMlmStartReq->dualCTSProtection;
1859 pAddBssParams->txChannelWidthSet = pMlmStartReq->txChannelWidthSet;
1860
1861 pAddBssParams->currentOperChannel = pMlmStartReq->channelNumber;
Jeff Johnsone7245742012-09-05 17:12:55 -07001862 pAddBssParams->currentExtChannel = pMlmStartReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001863
Chet Lanctot8cecea22014-02-11 19:09:36 -08001864#ifdef WLAN_FEATURE_11W
1865 pAddBssParams->rmfEnabled = psessionEntry->limRmfEnabled;
1866#endif
1867
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 /* Update PE sessionId*/
1869 pAddBssParams->sessionId = pMlmStartReq->sessionId;
1870
1871 //Send the SSID to HAL to enable SSID matching for IBSS
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301872 pAddBssParams->ssId.length = pMlmStartReq->ssId.length;
1873 if (pAddBssParams->ssId.length > SIR_MAC_MAX_SSID_LENGTH) {
1874 limLog(pMac, LOGE,
1875 FL("Invalid ssid length %d, max length allowed %d"),
1876 pAddBssParams->ssId.length,
1877 SIR_MAC_MAX_SSID_LENGTH);
1878 vos_mem_free(pAddBssParams);
1879 return eSIR_SME_INVALID_PARAMETERS;
1880 }
1881 vos_mem_copy(pAddBssParams->ssId.ssId,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301882 pMlmStartReq->ssId.ssId,
lifeng62aa8d52018-08-09 18:38:43 +08001883 pAddBssParams->ssId.length);
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301884
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 pAddBssParams->bHiddenSSIDEn = pMlmStartReq->ssidHidden;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001886 limLog( pMac, LOGE, FL( "TRYING TO HIDE SSID %d" ),pAddBssParams->bHiddenSSIDEn);
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 // CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed.
1888 pAddBssParams->bProxyProbeRespEn = 0;
1889 pAddBssParams->obssProtEnabled = pMlmStartReq->obssProtEnabled;
1890
Jeff Johnson295189b2012-06-20 16:38:30 -07001891#if defined WLAN_FEATURE_VOWIFI
1892 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
1893#endif
1894 mlm_add_sta(pMac, &pAddBssParams->staContext,
1895 pAddBssParams->bssId, pAddBssParams->htCapable,psessionEntry);
1896
1897 pAddBssParams->status = eHAL_STATUS_SUCCESS;
1898 pAddBssParams->respReqd = 1;
1899
1900 // Set a new state for MLME
1901 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001902 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904 pAddBssParams->halPersona=psessionEntry->pePersona; //pass on the session persona to hal
1905
1906 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
1907
1908#if defined WLAN_FEATURE_VOWIFI_11R
1909 pAddBssParams->extSetStaKeyParamValid = 0;
1910#endif
1911
1912 //
1913 // FIXME_GEN4
1914 // A global counter (dialog token) is required to keep track of
1915 // all PE <-> HAL communication(s)
1916 //
1917 msgQ.type = WDA_ADD_BSS_REQ;
1918 msgQ.reserved = 0;
1919 msgQ.bodyptr = pAddBssParams;
1920 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001921 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001922
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001923 limLog( pMac, LOGW, FL( "Sending WDA_ADD_BSS_REQ..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1925 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001926 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301927 vos_mem_free(pAddBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1929 }
1930
1931 return eSIR_SME_SUCCESS;
1932}
1933
1934
1935/**
1936 * limProcessMlmStartReq()
1937 *
1938 *FUNCTION:
1939 * This function is called to process MLM_START_REQ message
1940 * from SME
1941 *
1942 *LOGIC:
1943 * 1) MLME receives LIM_MLM_START_REQ from LIM
1944 * 2) MLME sends WDA_ADD_BSS_REQ to HAL
1945 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
1946 * MLME now waits for HAL to send WDA_ADD_BSS_RSP
1947 *
1948 *ASSUMPTIONS:
1949 *
1950 *NOTE:
1951 *
1952 * @param pMac Pointer to Global MAC structure
1953 * @param *pMsgBuf A pointer to the MLM message buffer
1954 * @return None
1955 */
1956
1957static void
1958limProcessMlmStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1959{
1960 tLimMlmStartReq *pMlmStartReq;
1961 tLimMlmStartCnf mlmStartCnf;
1962 tpPESession psessionEntry = NULL;
1963
1964 if(pMsgBuf == NULL)
1965 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001966 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 return;
1968 }
1969
1970 pMlmStartReq = (tLimMlmStartReq *) pMsgBuf;
1971 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmStartReq->sessionId))==NULL)
1972 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001973 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 mlmStartCnf.resultCode = eSIR_SME_REFUSED;
1975 goto end;
1976 }
1977
1978 if (psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE)
1979 {
1980 /**
1981 * Should not have received Start req in states other than idle.
1982 * Return Start confirm with failure code.
1983 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001984 PELOGE(limLog(pMac, LOGE, FL("received unexpected MLM_START_REQ in state %X"),psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
1986 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1987 goto end;
1988 }
1989
1990 #if 0
1991 if (cfgSetInt(pMac, WNI_CFG_CURRENT_CHANNEL, pMlmStartReq->channelNumber)!= eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001992 limLog(pMac, LOGP, FL("could not set CURRENT_CHANNEL at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994 pMac->lim.gLimCurrentChannelId = pMlmStartReq->channelNumber;
1995 #endif //TO SUPPORT BT-AMP
1996
1997
1998 // Update BSSID & SSID at CFG database
1999 #if 0 //We are not using the BSSID and SSID from the config file, instead we are reading form the session table
2000 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pMlmStartReq->bssId, sizeof(tSirMacAddr))
2001 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002002 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002003
2004
2005
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302006 vos_mem_copy( pMac->lim.gLimCurrentBssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 pMlmStartReq->bssId,
2008 sizeof(tSirMacAddr));
2009 #endif //TO SUPPORT BT-AMP
2010
2011 #if 0
2012 if (cfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *) &pMlmStartReq->ssId.ssId, pMlmStartReq->ssId.length)
2013 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002014 limLog(pMac, LOGP, FL("could not update SSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 #endif //To SUPPORT BT-AMP
2016
2017
2018 // pMac->lim.gLimCurrentSSID.length = pMlmStartReq->ssId.length;
2019
2020 #if 0
2021 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2022 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
2023 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
2024 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002025 limLog(pMac, LOGP, FL("could not update Operational Rateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 #endif //TO SUPPORT BT-AMP
2027
2028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029
Jeff Johnson295189b2012-06-20 16:38:30 -07002030#if 0 // Periodic timer for remove WPS PBC proble response entry in PE is disbaled now.
2031 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
2032 {
2033 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_FALSE)
2034 {
2035 if (tx_timer_create(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer,
2036 "PS OVERLAP Timer",
2037 limWPSOverlapTimerHandler,
2038 SIR_LIM_WPS_OVERLAP_TIMEOUT, // expiration_input
2039 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // initial_ticks
2040 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // reschedule_ticks
2041 TX_AUTO_ACTIVATE /* TX_NO_ACTIVATE*/) != TX_SUCCESS)
2042 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002043 limLog(pMac, LOGP, FL("failed to create WPS overlap Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 }
2045
2046 pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId = pMlmStartReq->sessionId;
2047 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002048 limLog(pMac, LOGE, FL("Create WPS overlap Timer, session=%d"), pMlmStartReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002049
2050 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
2051 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002052 limLog(pMac, LOGP, FL("tx_timer_activate failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 }
2054 }
2055 }
2056#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002057
2058
2059
2060 mlmStartCnf.resultCode = limMlmAddBss(pMac, pMlmStartReq,psessionEntry);
2061
2062end:
2063 /* Update PE session Id */
2064 mlmStartCnf.sessionId = pMlmStartReq->sessionId;
2065
2066 /// Free up buffer allocated for LimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302067 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
2069 //
2070 // Respond immediately to LIM, only if MLME has not been
2071 // successfully able to send WDA_ADD_BSS_REQ to HAL.
2072 // Else, LIM_MLM_START_CNF will be sent after receiving
2073 // WDA_ADD_BSS_RSP from HAL
2074 //
2075 if( eSIR_SME_SUCCESS != mlmStartCnf.resultCode )
2076 limPostSmeMessage(pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf);
2077} /*** limProcessMlmStartReq() ***/
2078
2079
2080/*
2081* This function checks if Scan is allowed or not.
2082* It checks each session and if any session is not in the normal state,
2083* it will return false.
2084* Note: BTAMP_STA can be in LINK_EST as well as BSS_STARTED State, so
2085* both cases are handled below.
2086*/
2087
2088static tANI_U8 __limMlmScanAllowed(tpAniSirGlobal pMac)
2089{
2090 int i;
2091
Jeff Johnson43971f52012-07-17 12:26:56 -07002092 if(pMac->lim.gLimMlmState != eLIM_MLM_IDLE_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 {
2094 return FALSE;
2095 }
2096 for(i =0; i < pMac->lim.maxBssId; i++)
2097 {
2098 if(pMac->lim.gpSession[i].valid == TRUE)
2099 {
2100 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
2101 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
2102 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) )||
2103
2104 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
2105 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
2106 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2107 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
2109 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
2110 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
2111 && (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 ))
2113 {
2114 return FALSE;
2115
2116 }
2117 }
2118 }
2119
2120 return TRUE;
2121}
2122
2123
2124
2125/**
2126 * limProcessMlmScanReq()
2127 *
2128 *FUNCTION:
2129 * This function is called to process MLM_SCAN_REQ message
2130 * from SME
2131 *
2132 *LOGIC:
2133 *
2134 *ASSUMPTIONS:
2135 *
2136 *NOTE:
2137 *
2138 * @param pMac Pointer to Global MAC structure
2139 * @param *pMsgBuf A pointer to the MLM message buffer
2140 * @return None
2141 */
2142
2143static void
2144limProcessMlmScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2145{
2146 tLimMlmScanCnf mlmScanCnf;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002147 tANI_U8 i = 0;
2148 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149
2150 if (pMac->lim.gLimSystemInScanLearnMode)
2151 {
2152 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002153 FL("Sending START_SCAN from LIM while one req is pending"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302154 vos_mem_free(pMsgBuf);
Madan Mohan Koyyalamudid4b301b2012-10-11 14:15:54 -07002155 /*Send back a failure*/
2156 mlmScanCnf.resultCode = eSIR_SME_SCAN_FAILED;
2157 mlmScanCnf.scanResultLength = 0;
2158 limPostSmeMessage(pMac,
2159 LIM_MLM_SCAN_CNF,
2160 (tANI_U32 *) &mlmScanCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 return;
2162 }
2163
2164 if(__limMlmScanAllowed(pMac) &&
2165 (((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels != 0))
2166
2167 {
2168 /// Hold onto SCAN REQ criteria
2169 pMac->lim.gpLimMlmScanReq = (tLimMlmScanReq *) pMsgBuf;
2170
Abhishek Singh127a8442014-12-15 17:31:27 +05302171 limLog(pMac, LOG1, FL("Number of channels to scan are %d "),
2172 pMac->lim.gpLimMlmScanReq->channelList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173
2174 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2175
2176 if (pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
2177 pMac->lim.gLimMlmState = eLIM_MLM_WT_PROBE_RESP_STATE;
2178 else // eSIR_PASSIVE_SCAN
2179 pMac->lim.gLimMlmState = eLIM_MLM_PASSIVE_SCAN_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002180 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 pMac->lim.gLimSystemInScanLearnMode = 1;
2183
Maleka Vinayd500cd42012-12-10 12:37:09 -08002184 /* temporary fix to handle case where NOA duration calculation is incorrect
2185 * for scanning on DFS channels */
2186
2187 pMac->lim.gTotalScanDuration = 0;
2188
2189 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
2190 {
2191 /*
2192 * Could not get max channel value
2193 * from CFG. Log error.
2194 */
Abhishek Singh95f7b252015-10-14 14:15:35 +05302195 limLog(pMac, LOGP,
2196 FL("could not retrieve passive max channel value use def"));
2197 /* use a default value */
2198 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002199 }
2200
2201 for (i = 0; i < pMac->lim.gpLimMlmScanReq->channelList.numChannels; i++) {
2202 tANI_U8 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[i];
2203
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05302204 if (pMac->miracast_mode) {
2205 pMac->lim.gTotalScanDuration += (DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
2206 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST);
2207 } else if (limActiveScanAllowed(pMac, channelNum)) {
Maleka Vinayd500cd42012-12-10 12:37:09 -08002208 /* Use min + max channel time to calculate the total duration of scan */
2209 pMac->lim.gTotalScanDuration += pMac->lim.gpLimMlmScanReq->minChannelTime + pMac->lim.gpLimMlmScanReq->maxChannelTime;
2210 } else {
2211 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
2212 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
2213 */
2214 pMac->lim.gTotalScanDuration += val;
2215 }
2216 }
2217
2218 /* Adding an overhead of 5ms to account for the scan messaging delays */
2219 pMac->lim.gTotalScanDuration += 5;
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 limSetScanMode(pMac);
2221 }
2222 else
2223 {
2224 /**
2225 * Should not have received SCAN req in other states
2226 * OR should not have received LIM_MLM_SCAN_REQ with
2227 * zero number of channels
2228 * Log error
2229 */
2230 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302231 FL("received unexpected MLM_SCAN_REQ in state %d OR zero number of channels: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 pMac->lim.gLimMlmState, ((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels);
2233 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2234
2235 /// Free up buffer allocated for
2236 /// pMac->lim.gLimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302237 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 /// Return Scan confirm with INVALID_PARAMETERS
2240
2241 mlmScanCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2242 mlmScanCnf.scanResultLength = 0;
2243 limPostSmeMessage(pMac,
2244 LIM_MLM_SCAN_CNF,
2245 (tANI_U32 *) &mlmScanCnf);
2246 }
2247} /*** limProcessMlmScanReq() ***/
2248
Jeff Johnsone7245742012-09-05 17:12:55 -07002249#ifdef FEATURE_OEM_DATA_SUPPORT
2250static void limProcessMlmOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2251{
2252 tLimMlmOemDataRsp* pMlmOemDataRsp;
2253
2254 if (((pMac->lim.gLimMlmState == eLIM_MLM_IDLE_STATE) ||
2255 (pMac->lim.gLimMlmState == eLIM_MLM_JOINED_STATE) ||
2256 (pMac->lim.gLimMlmState == eLIM_MLM_AUTHENTICATED_STATE) ||
2257 (pMac->lim.gLimMlmState == eLIM_MLM_BSS_STARTED_STATE) ||
2258 (pMac->lim.gLimMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)))
2259 {
2260 //Hold onto the oem data request criteria
2261 pMac->lim.gpLimMlmOemDataReq = (tLimMlmOemDataReq*)pMsgBuf;
2262
2263 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2264
2265 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
2266
2267 //Now request for link suspension
2268 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, limSetOemDataReqMode, NULL);
2269 }
2270 else
2271 {
2272 /**
2273 * Should not have received oem data req in other states
2274 * Log error
2275 */
2276
Sushant Kaushik1b645382014-10-13 16:39:36 +05302277 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 -07002278
2279 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2280
2281 /// Free up buffer allocated
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302282 vos_mem_free(pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07002283
2284 /// Return Meas confirm with INVALID_PARAMETERS
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302285 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
2286 if ( pMlmOemDataRsp != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002287 {
2288 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302289 vos_mem_free(pMlmOemDataRsp);
Jeff Johnsone7245742012-09-05 17:12:55 -07002290 }
2291 else
2292 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002293 limLog(pMac, LOGP, FL("Could not allocate memory for pMlmOemDataRsp"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002294 return;
2295 }
2296 }
2297
2298 return;
2299}
2300#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07002301
2302
2303/**
2304 * limProcessMlmPostJoinSuspendLink()
2305 *
2306 *FUNCTION:
2307 * This function is called after the suspend link while joining
2308 * off channel.
2309 *
2310 *LOGIC:
2311 * Check for suspend state.
2312 * If success, proceed with setting link state to recieve the
2313 * probe response/beacon from intended AP.
2314 * Switch to the APs channel.
2315 * On an error case, send the MLM_JOIN_CNF with error status.
2316 *
2317 *ASSUMPTIONS:
2318 *
2319 *NOTE:
2320 *
2321 * @param pMac Pointer to Global MAC structure
2322 * @param status status of suspend link.
2323 * @param ctx passed while calling suspend link(psessionEntry)
2324 * @return None
2325 */
2326static void
2327limProcessMlmPostJoinSuspendLink(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *ctx)
2328{
Jeff Johnsone7245742012-09-05 17:12:55 -07002329 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 tLimMlmJoinCnf mlmJoinCnf;
2331 tpPESession psessionEntry = (tpPESession)ctx;
2332 tSirLinkState linkState;
2333
2334 if( eHAL_STATUS_SUCCESS != status )
2335 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302336 limLog(pMac, LOGE, FL("Sessionid %d Suspend link(NOTIFY_BSS) failed. "
2337 "still proceeding with join"),psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 }
2339 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2340 psessionEntry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002341 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002342
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302343 limLog(pMac, LOG1, FL("Sessionid %d prev lim state %d new lim state %d "
2344 "systemrole = %d"), psessionEntry->peSessionId,
2345 psessionEntry->limPrevMlmState,
2346 psessionEntry->limMlmState,psessionEntry->limSystemRole);
2347
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
2349
2350 //assign appropriate sessionId to the timer object
2351 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId = psessionEntry->peSessionId;
2352
2353 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 -07002354 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: linkState:%d"),linkState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
2356 if (limSetLinkState(pMac, linkState,
2357 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,
2358 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2359 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302360 limLog(pMac, LOGE,
2361 FL("SessionId:%d limSetLinkState to eSIR_LINK_PREASSOC_STATE"
2362 " Failed!!"),psessionEntry->peSessionId);
2363 limPrintMacAddr(pMac,
2364 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002366 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
2367 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 goto error;
2369 }
2370
2371 /** Derive channel from BSS description and store it in the CFG */
2372 // chanNum = pMac->lim.gpLimMlmJoinReq->bssDescription.channelId;
2373
2374 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07002375 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 //store the channel switch sessionEntry in the lim global var
2377 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_JOIN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002378#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002379 psessionEntry->pLimMlmReassocRetryReq = NULL;
2380#endif
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302381
2382#ifdef FEATURE_WLAN_DIAG_SUPPORT
2383 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2384 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_JOIN);
2385#endif
2386
Dino Myclea7f18452014-04-24 08:55:31 +05302387 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: suspend link success(%d) "
2388 "on sessionid: %d setting channel to: %d with secChanOffset:%d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302389 "and maxtxPower: %d"), status, psessionEntry->peSessionId,
2390 chanNum, secChanOffset, psessionEntry->maxTxPower);
Jeff Johnsone7245742012-09-05 17:12:55 -07002391 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002392
2393 return;
2394error:
2395 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2396 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
2397 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2398 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2399
2400}
2401
2402
2403
2404/**
2405 * limProcessMlmJoinReq()
2406 *
2407 *FUNCTION:
2408 * This function is called to process MLM_JOIN_REQ message
2409 * from SME
2410 *
2411 *LOGIC:
2412 * 1) Initialize LIM, HAL, DPH
2413 * 2) Configure the BSS for which the JOIN REQ was received
2414 * a) Send WDA_ADD_BSS_REQ to HAL -
2415 * This will identify the BSS that we are interested in
2416 * --AND--
2417 * Add a STA entry for the AP (in a STA context)
2418 * b) Wait for WDA_ADD_BSS_RSP
2419 * c) Send WDA_ADD_STA_REQ to HAL
2420 * This will add the "local STA" entry to the STA table
2421 * 3) Continue as before, i.e,
2422 * a) Send a PROBE REQ
2423 * b) Wait for PROBE RSP/BEACON containing the SSID that
2424 * we are interested in
2425 * c) Then start an AUTH seq
2426 * d) Followed by the ASSOC seq
2427 *
2428 *ASSUMPTIONS:
2429 *
2430 *NOTE:
2431 *
2432 * @param pMac Pointer to Global MAC structure
2433 * @param *pMsgBuf A pointer to the MLM message buffer
2434 * @return None
2435 */
2436
2437static void
2438limProcessMlmJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2439{
2440 tLimMlmJoinCnf mlmJoinCnf;
2441 tANI_U8 sessionId;
2442 tpPESession psessionEntry;
2443
2444 sessionId = ((tpLimMlmJoinReq)pMsgBuf)->sessionId;
2445
2446 if((psessionEntry = peFindSessionBySessionId(pMac,sessionId))== NULL)
2447 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302448 limLog(pMac, LOGE, FL("SessionId:%d session does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 goto error;
2450 }
2451
2452 if (( (psessionEntry->limSystemRole != eLIM_AP_ROLE ) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE )) &&
2453 ( (psessionEntry->limMlmState == eLIM_MLM_IDLE_STATE) ||
2454 (psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE)) &&
2455 (SIR_MAC_GET_ESS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo) !=
2456 SIR_MAC_GET_IBSS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo)))
2457 {
2458 #if 0
2459 if (pMac->lim.gpLimMlmJoinReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302460 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 #endif //TO SUPPORT BT-AMP , review 23sep
2462
2463 /// Hold onto Join request parameters
2464
2465 psessionEntry->pLimMlmJoinReq =(tpLimMlmJoinReq) pMsgBuf;
2466
2467 if( isLimSessionOffChannel(pMac, sessionId) )
2468 {
2469 //suspend link
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302470 limLog(pMac, LOG1, FL("Suspend link as LimSession on sessionid %d"
2471 "is off channel"),sessionId);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302472 if (limIsLinkSuspended(pMac))
2473 {
2474 limLog(pMac, LOGE, FL("Link is already suspended for some other"
2475 " reason. Return failure on sessionId:%d"), sessionId);
2476 goto error;
2477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
2479 limProcessMlmPostJoinSuspendLink, (tANI_U32*)psessionEntry );
2480 }
2481 else
2482 {
2483 //No need to suspend link.
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302484 limLog(pMac,LOG1,"SessionId:%d Join request on current channel",
2485 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 limProcessMlmPostJoinSuspendLink( pMac, eHAL_STATUS_SUCCESS,
2487 (tANI_U32*) psessionEntry );
2488 }
2489
2490 return;
2491 }
2492 else
2493 {
2494 /**
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302495 * Should not have received JOIN req in states other than
2496 * Idle state or on AP.
2497 * Return join confirm with invalid parameters code.
2498 */
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302499 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302500 FL("SessionId:%d Unexpected Join request for role %d state %d "),
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302501 psessionEntry->peSessionId,psessionEntry->limSystemRole,
2502 psessionEntry->limMlmState);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302503 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 }
2505
2506error:
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302507 vos_mem_free(pMsgBuf);
2508 if (psessionEntry != NULL)
2509 psessionEntry->pLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002510
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302511 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2512 mlmJoinCnf.sessionId = sessionId;
2513 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2514 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002515} /*** limProcessMlmJoinReq() ***/
2516
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302517#ifdef WLAN_FEATURE_SAE
2518/**
2519 * lim_process_mlm_auth_req_sae() - Handle SAE authentication
2520 * @mac_ctx: global MAC context
2521 * @session: PE session entry
2522 *
2523 * This function is called by lim_process_mlm_auth_req to handle SAE
2524 * authentication.
2525 *
2526 * Return: tSirRetStatus
2527 */
2528static VOS_STATUS lim_process_mlm_auth_req_sae(tpAniSirGlobal mac_ctx,
2529 tpPESession session)
2530{
2531 VOS_STATUS status = VOS_STATUS_SUCCESS;
2532 struct sir_sae_info *sae_info;
2533 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002534
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302535 sae_info = vos_mem_malloc(sizeof(*sae_info));
2536 if (sae_info == NULL) {
2537 limLog(mac_ctx, LOGP, FL("Memory allocation failed"));
2538 return VOS_STATUS_E_FAILURE;
2539 }
2540
2541 sae_info->msg_type = eWNI_SME_TRIGGER_SAE;
2542 sae_info->msg_len = sizeof(*sae_info);
2543 sae_info->vdev_id = session->smeSessionId;
2544
2545 vos_mem_copy(sae_info->peer_mac_addr.bytes, session->bssId,
2546 VOS_MAC_ADDR_SIZE);
2547
2548 sae_info->ssid.length = session->ssId.length;
2549 vos_mem_copy(sae_info->ssid.ssId, session->ssId.ssId,
2550 session->ssId.length);
2551 limLog(mac_ctx, LOG1, FL("vdev_id %d ssid %.*s "MAC_ADDRESS_STR""),
2552 sae_info->vdev_id, sae_info->ssid.length,sae_info->ssid.ssId,
2553 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
2554
2555 msg.type = eWNI_SME_TRIGGER_SAE;
2556 msg.bodyptr = sae_info;
2557 msg.bodyval = 0;
2558
2559 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
2560 {
Abhinav Kumar626f8652019-08-05 16:20:39 +05302561 limLog(mac_ctx, LOGE, FL("%s failed to post msg to self "),
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302562 __func__);
2563 vos_mem_free((void *)sae_info);
2564 status = VOS_STATUS_E_FAILURE;
2565 }
2566
2567 session->limMlmState = eLIM_MLM_WT_SAE_AUTH_STATE;
2568
2569 MTRACE(macTrace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
2570 session->limMlmState));
2571
Abhinav Kumar626f8652019-08-05 16:20:39 +05302572 mac_ctx->lim.limTimers.sae_auth_timer.sessionId = session->peSessionId;
2573 /* Activate SAE auth timer */
2574 MTRACE(macTrace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
2575 session->peSessionId, eLIM_AUTH_SAE_TIMER));
2576 if (tx_timer_activate(&mac_ctx->lim.limTimers.sae_auth_timer)
2577 != TX_SUCCESS) {
2578 limLog(mac_ctx, LOGE, FL("could not start Auth SAE timer"));
2579 }
2580
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302581 return status;
2582}
2583#else
2584static VOS_STATUS lim_process_mlm_auth_req_sae(tpAniSirGlobal mac_ctx,
2585 tpPESession session)
2586{
2587 return VOS_STATUS_E_NOSUPPORT;
2588}
2589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002590
2591/**
2592 * limProcessMlmAuthReq()
2593 *
2594 *FUNCTION:
2595 * This function is called to process MLM_AUTH_REQ message
2596 * from SME
2597 *
2598 *LOGIC:
2599 *
2600 *ASSUMPTIONS:
2601 *
2602 *NOTE:
2603 *
2604 * @param pMac Pointer to Global MAC structure
2605 * @param *pMsgBuf A pointer to the MLM message buffer
2606 * @return None
2607 */
2608
2609static void
2610limProcessMlmAuthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2611{
2612 tANI_U32 numPreAuthContexts;
2613 tSirMacAddr currentBssId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 tLimMlmAuthCnf mlmAuthCnf;
2615 struct tLimPreAuthNode *preAuthNode;
2616 tpDphHashNode pStaDs;
2617 tANI_U8 sessionId;
2618 tpPESession psessionEntry;
2619
2620 if(pMsgBuf == NULL)
2621 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002622 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 return;
2624 }
2625
2626 pMac->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) pMsgBuf;
2627 sessionId = pMac->lim.gpLimMlmAuthReq->sessionId;
2628 if((psessionEntry= peFindSessionBySessionId(pMac,sessionId) )== NULL)
2629 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302630 limLog(pMac, LOGP, FL("SessionId:%d Session Does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 return;
2632 }
2633
Abhishek Singhcd09b562013-12-24 16:02:20 +05302634 limLog(pMac, LOG1,FL("Process Auth Req on sessionID %d Systemrole %d"
2635 "mlmstate %d from: "MAC_ADDRESS_STR" with authtype %d"), sessionId,
2636 psessionEntry->limSystemRole,psessionEntry->limMlmState,
2637 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr),
2638 pMac->lim.gpLimMlmAuthReq->authType);
2639
2640
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 /**
2642 * Expect Auth request only when:
2643 * 1. STA joined/associated with a BSS or
2644 * 2. STA is in IBSS mode
2645 * and STA is going to authenticate with a unicast
2646 * adress and requested authentication algorithm is
2647 * supported.
2648 */
2649 #if 0
2650 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2651 eSIR_SUCCESS)
2652 {
2653 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002654 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 }
2656 #endif //To SuppoRT BT-AMP
2657
2658 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2659
2660 if (((((psessionEntry->limSystemRole== eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2661 ((psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) ||
2662 (psessionEntry->limMlmState ==
2663 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
2664 ((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) &&
2665 (psessionEntry->limMlmState == eLIM_MLM_BSS_STARTED_STATE))) &&
2666 (limIsGroupAddr(pMac->lim.gpLimMlmAuthReq->peerMacAddr)
2667 == false) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 (limIsAuthAlgoSupported(
2669 pMac,
2670 pMac->lim.gpLimMlmAuthReq->authType,
2671 psessionEntry) == true)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 )
2673 {
2674 /**
2675 * This is a request for pre-authentication.
2676 * Check if there exists context already for
Jeff Johnson1250df42012-12-10 14:31:52 -08002677 * the requested peer OR
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 * if this request is for the AP we're currently
2679 * associated with.
2680 * If yes, return auth confirm immediately when
2681 * requested auth type is same as the one used before.
2682 */
2683 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2684 (psessionEntry->limMlmState ==
2685 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2686 (((pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) != NULL) &&
2687 (pMac->lim.gpLimMlmAuthReq->authType ==
2688 pStaDs->mlmStaContext.authType)) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302689 (vos_mem_compare(pMac->lim.gpLimMlmAuthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 currentBssId,
2691 sizeof(tSirMacAddr)) )) ||
2692 (((preAuthNode =
2693 limSearchPreAuthList(
2694 pMac,
2695 pMac->lim.gpLimMlmAuthReq->peerMacAddr)) != NULL) &&
2696 (preAuthNode->authType ==
2697 pMac->lim.gpLimMlmAuthReq->authType)))
2698 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302699 limLog(pMac, LOG2,
2700 FL("Already have pre-auth context with peer: "MAC_ADDRESS_STR),
2701 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
2703 mlmAuthCnf.resultCode = (tSirResultCodes)
2704 eSIR_MAC_SUCCESS_STATUS;
2705
2706
2707 goto end;
2708 }
2709 else
2710 {
2711 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
2712 (tANI_U32 *) &numPreAuthContexts) != eSIR_SUCCESS)
2713 {
2714 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002715 FL("Could not retrieve NumPreAuthLimit from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
2718 if (pMac->lim.gLimNumPreAuthContexts == numPreAuthContexts)
2719 {
2720 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002721 FL("Number of pre-auth reached max limit"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002722
2723 /// Return Auth confirm with reject code
2724 mlmAuthCnf.resultCode =
2725 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
2726
2727 goto end;
2728 }
2729 }
2730
2731 // Delete pre-auth node if exists
2732 if (preAuthNode)
2733 limDeletePreAuthNode(pMac,
2734 pMac->lim.gpLimMlmAuthReq->peerMacAddr);
2735
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05302737 if ((pMac->lim.gpLimMlmAuthReq->authType == eSIR_AUTH_TYPE_SAE) &&
2738 !psessionEntry->sae_pmk_cached) {
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302739 if (lim_process_mlm_auth_req_sae(pMac, psessionEntry) !=
2740 VOS_STATUS_SUCCESS) {
2741 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2742 goto end;
2743 } else {
2744 limLog(pMac, LOG1,
2745 FL("lim_process_mlm_auth_req_sae is successful"));
2746 return;
2747 }
2748 } else {
2749 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
2750 }
2751
Jeff Johnsone7245742012-09-05 17:12:55 -07002752 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
Jeff Johnsone7245742012-09-05 17:12:55 -07002754 //assign appropriate sessionId to the timer object
2755 pMac->lim.limTimers.gLimAuthFailureTimer.sessionId = sessionId;
Sushant Kaushik9e923872015-04-02 17:09:31 +05302756 /* assign appropriate sessionId to the timer object */
2757 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId = sessionId;
2758 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07002759 // Activate Auth failure timer
2760 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_AUTH_FAIL_TIMER));
Paul Zhang83289792017-02-28 18:58:52 +08002761
2762 limDoSendAuthMgmtFrame(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002763 return;
2764 }
2765 else
2766 {
2767 /**
2768 * Unexpected auth request.
2769 * Return Auth confirm with Invalid parameters code.
2770 */
2771 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2772
2773 goto end;
2774 }
2775
2776end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302777 vos_mem_copy((tANI_U8 *) &mlmAuthCnf.peerMacAddr,
2778 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2779 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
2782 mlmAuthCnf.sessionId = sessionId;
2783
2784 /// Free up buffer allocated
2785 /// for pMac->lim.gLimMlmAuthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302786 vos_mem_free( pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 pMac->lim.gpLimMlmAuthReq = NULL;
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302788 limLog(pMac,LOG1,"SessionId:%d LimPostSme LIM_MLM_AUTH_CNF ",sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 limPostSmeMessage(pMac, LIM_MLM_AUTH_CNF, (tANI_U32 *) &mlmAuthCnf);
2790} /*** limProcessMlmAuthReq() ***/
2791
2792
2793
2794/**
2795 * limProcessMlmAssocReq()
2796 *
2797 *FUNCTION:
2798 * This function is called to process MLM_ASSOC_REQ message
2799 * from SME
2800 *
2801 *LOGIC:
2802 *
2803 *ASSUMPTIONS:
2804 *
2805 *NOTE:
2806 *
2807 * @param pMac Pointer to Global MAC structure
2808 * @param *pMsgBuf A pointer to the MLM message buffer
2809 * @return None
2810 */
2811
2812static void
2813limProcessMlmAssocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2814{
2815 tSirMacAddr currentBssId;
2816 tLimMlmAssocReq *pMlmAssocReq;
2817 tLimMlmAssocCnf mlmAssocCnf;
2818 tpPESession psessionEntry;
2819 // tANI_U8 sessionId;
2820
2821 if(pMsgBuf == NULL)
2822 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002823 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return;
2825 }
2826 pMlmAssocReq = (tLimMlmAssocReq *) pMsgBuf;
2827
2828 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmAssocReq->sessionId) )== NULL)
2829 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302830 limLog(pMac, LOGP,FL("SessionId:%d Session Does not exist"),
2831 pMlmAssocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302832 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 return;
2834 }
2835
Abhishek Singhcd09b562013-12-24 16:02:20 +05302836 limLog(pMac, LOG1,FL("Process Assoc Req on sessionID %d Systemrole %d"
2837 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmAssocReq->sessionId,
2838 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2839 MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));
2840
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 #if 0
2842 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2843 eSIR_SUCCESS)
2844 {
2845 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002846 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 }
2848 #endif //TO SUPPORT BT-AMP
2849 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2850
2851 if ( (psessionEntry->limSystemRole != eLIM_AP_ROLE && psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE) &&
2852 (psessionEntry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302853 (vos_mem_compare(pMlmAssocReq->peerMacAddr, currentBssId, sizeof(tSirMacAddr))) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002855
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 /// map the session entry pointer to the AssocFailureTimer
2857 pMac->lim.limTimers.gLimAssocFailureTimer.sessionId = pMlmAssocReq->sessionId;
2858
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2860 psessionEntry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002861 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302862 limLog(pMac,LOG1,"SessionId:%d Sending Assoc_Req Frame",
2863 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002864
2865 /// Prepare and send Association request frame
2866 limSendAssocReqMgmtFrame(pMac, pMlmAssocReq,psessionEntry);
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302867#ifdef FEATURE_WLAN_DIAG_SUPPORT
2868 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_REQ_EVENT, psessionEntry,
2869 eSIR_SUCCESS, eSIR_SUCCESS);
2870#endif
2871
Jeff Johnson295189b2012-06-20 16:38:30 -07002872
2873 //Set the link state to postAssoc, so HW can start receiving frames from AP.
2874 if ((psessionEntry->bssType == eSIR_BTAMP_STA_MODE)||
2875 ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE) && (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
2876 {
2877 if(limSetLinkState(pMac, eSIR_LINK_BTAMP_POSTASSOC_STATE, currentBssId,
2878 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002879 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002881 /// Start association failure timer
2882 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
2883 if (tx_timer_activate(&pMac->lim.limTimers.gLimAssocFailureTimer)
2884 != TX_SUCCESS)
2885 {
2886 /// Could not start Assoc failure timer.
2887 // Log error
2888 limLog(pMac, LOGP,
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302889 FL("SessionId:%d could not start Association failure timer"),
2890 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002891 // Cleanup as if assoc timer expired
2892 limProcessAssocFailureTimeout(pMac,LIM_ASSOC );
2893
2894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002895
2896 return;
2897 }
2898 else
2899 {
2900 /**
2901 * Received Association request either in invalid state
2902 * or to a peer MAC entity whose address is different
2903 * from one that STA is currently joined with or on AP.
2904 * Return Assoc confirm with Invalid parameters code.
2905 */
2906
2907 // Log error
2908 PELOGW(limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302909 FL("received unexpected MLM_ASSOC_CNF in state %d for role=%d, MAC addr= "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302910 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2911 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2913
2914 mlmAssocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2915 mlmAssocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2916
2917 goto end;
2918 }
2919
2920end:
2921 /* Update PE session Id*/
2922 mlmAssocCnf.sessionId = pMlmAssocReq->sessionId;
2923
2924 /// Free up buffer allocated for assocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302925 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
2927 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
2928} /*** limProcessMlmAssocReq() ***/
2929
2930
2931
2932/**
2933 * limProcessMlmReassocReq()
2934 *
2935 *FUNCTION:
2936 * This function is called to process MLM_REASSOC_REQ message
2937 * from SME
2938 *
2939 *LOGIC:
2940 *
2941 *ASSUMPTIONS:
2942 *
2943 *NOTE:
2944 *
2945 * @param pMac Pointer to Global MAC structure
2946 * @param *pMsgBuf A pointer to the MLM message buffer
2947 * @return None
2948 */
2949
2950static void
2951limProcessMlmReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2952{
Jeff Johnsone7245742012-09-05 17:12:55 -07002953 tANI_U8 chanNum, secChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 struct tLimPreAuthNode *pAuthNode;
2955 tLimMlmReassocReq *pMlmReassocReq;
2956 tLimMlmReassocCnf mlmReassocCnf;
2957 tpPESession psessionEntry;
2958
2959 if(pMsgBuf == NULL)
2960 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002961 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 return;
2963 }
2964
2965 pMlmReassocReq = (tLimMlmReassocReq *) pMsgBuf;
Abhishek Singhcd09b562013-12-24 16:02:20 +05302966
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmReassocReq->sessionId)) == NULL)
2968 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302969 limLog(pMac, LOGE,FL("Session Does not exist for given sessionId %d"),
2970 pMlmReassocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302971 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 return;
2973 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302974
2975 limLog(pMac, LOG1,FL("Process ReAssoc Req on sessionID %d Systemrole %d"
2976 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmReassocReq->sessionId,
2977 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2978 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
2979
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 if (((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) &&
2981 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
2982 {
2983 if (psessionEntry->pLimMlmReassocReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302984 vos_mem_free(psessionEntry->pLimMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002985
2986 /* Hold Re-Assoc request as part of Session, knock-out pMac */
2987 /// Hold onto Reassoc request parameters
2988 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
2989
2990 // See if we have pre-auth context with new AP
2991 pAuthNode = limSearchPreAuthList(pMac, psessionEntry->limReAssocbssId);
2992
2993 if (!pAuthNode &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302994 (!vos_mem_compare(pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 psessionEntry->bssId,
2996 sizeof(tSirMacAddr)) ))
2997 {
2998 // Either pre-auth context does not exist AND
2999 // we are not reassociating with currently
3000 // associated AP.
3001 // Return Reassoc confirm with not authenticated
3002 mlmReassocCnf.resultCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3003 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3004
3005 goto end;
3006 }
3007
3008 //assign the sessionId to the timer object
3009 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = pMlmReassocReq->sessionId;
3010
3011 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3012 psessionEntry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003013 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003014
3015#if 0
3016 // Update BSSID at CFG database
3017 if (wlan_cfgSetStr(pMac, WNI_CFG_BSSID,
3018 pMac->lim.gLimReassocBssId,
3019 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
3020 {
3021 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003022 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 }
3024#endif //TO SUPPORT BT-AMP
3025
3026 /* Copy Global Reassoc ID*/
3027 // sirCopyMacAddr(psessionEntry->reassocbssId,pMac->lim.gLimReAssocBssId);
3028
3029 /**
3030 * Derive channel from BSS description and
3031 * store it at CFG.
3032 */
3033
3034 chanNum = psessionEntry->limReassocChannelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07003035 secChannelOffset = psessionEntry->reAssocHtSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003036
3037 /* To Support BT-AMP .. read channel number from psessionEntry*/
3038 //chanNum = psessionEntry->currentOperChannel;
3039
3040 // Apply previously set configuration at HW
3041 limApplyConfiguration(pMac,psessionEntry);
3042
3043 //store the channel switch sessionEntry in the lim global var
3044 /* We have already saved the ReAssocreq Pointer abobe */
3045 //psessionEntry->pLimReAssocReq = (void *)pMlmReassocReq;
3046 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_REASSOC;
3047
Jeff Johnsone7245742012-09-05 17:12:55 -07003048 /** Switch channel to the new Operating channel for Reassoc*/
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303049
3050#ifdef FEATURE_WLAN_DIAG_SUPPORT
3051 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
3052 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_REASSOC);
3053#endif
3054
Jeff Johnsone7245742012-09-05 17:12:55 -07003055 limSetChannel(pMac, chanNum, secChannelOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003056
3057 return;
3058 }
3059 else
3060 {
3061 /**
3062 * Received Reassoc request in invalid state or
3063 * in AP role.Return Reassoc confirm with Invalid
3064 * parameters code.
3065 */
3066
3067 // Log error
Abhishek Singhcd09b562013-12-24 16:02:20 +05303068 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303069 FL("received unexpected MLM_REASSOC_CNF in state %d for role=%d, "
Abhishek Singhcd09b562013-12-24 16:02:20 +05303070 "MAC addr= "
3071 MAC_ADDRESS_STR), psessionEntry->limMlmState,
3072 psessionEntry->limSystemRole,
3073 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3075
3076 mlmReassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3077 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3078
3079 goto end;
3080 }
3081
3082end:
3083 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3084 /* Update PE sessio Id*/
3085 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
3086 /// Free up buffer allocated for reassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303087 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 psessionEntry->pLimReAssocReq = NULL;
3089
3090 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3091} /*** limProcessMlmReassocReq() ***/
3092
3093
3094static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003095limProcessMlmDisassocReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003096{
3097 tANI_U16 aid;
3098 tSirMacAddr currentBssId;
3099 tpDphHashNode pStaDs;
3100 tLimMlmDisassocReq *pMlmDisassocReq;
3101 tLimMlmDisassocCnf mlmDisassocCnf;
3102 tpPESession psessionEntry;
3103 extern tANI_BOOLEAN sendDisassocFrame;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303104 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303105 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303106 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
3108 if(eHAL_STATUS_SUCCESS != suspendStatus)
3109 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003110 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003111#if 0
3112 //It can ignore the status and proceed with the disassoc processing.
3113 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3114 goto end;
3115#endif
3116 }
3117
3118 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
3119
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
3121 {
3122
Abhishek Singhcd09b562013-12-24 16:02:20 +05303123 limLog(pMac, LOGE,
3124 FL("session does not exist for given sessionId %d"),
3125 pMlmDisassocReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3127 goto end;
3128 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303129 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d Systemrole %d"
3130 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3131 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3132 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3133
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 #if 0
3135 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3136 eSIR_SUCCESS)
3137 {
3138 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003139 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 }
3141 #endif //BT-AMP Support
3142 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3143
3144 switch (psessionEntry->limSystemRole)
3145 {
3146 case eLIM_STA_ROLE:
3147 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303148 if ( !vos_mem_compare(pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 currentBssId,
3150 sizeof(tSirMacAddr)) )
3151 {
3152 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303153 FL("received MLM_DISASSOC_REQ with invalid BSS id from: "
3154 MAC_ADDRESS_STR),
3155 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003156
3157 /// Prepare and Send LIM_MLM_DISASSOC_CNF
3158
3159 mlmDisassocCnf.resultCode =
3160 eSIR_SME_INVALID_PARAMETERS;
3161
3162 goto end;
3163 }
3164
3165 break;
3166
3167 case eLIM_STA_IN_IBSS_ROLE:
3168
3169 break;
3170
3171 default: // eLIM_AP_ROLE
3172
3173 // Fall through
3174 break;
3175
3176 } // end switch (psessionEntry->limSystemRole)
3177
3178 /**
3179 * Check if there exists a context for the peer entity
3180 * to be disassociated with.
3181 */
3182 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3183 if ((pStaDs == NULL) ||
3184 (pStaDs &&
3185 ((pStaDs->mlmStaContext.mlmState !=
3186 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3187 (pStaDs->mlmStaContext.mlmState !=
3188 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
3189 (pStaDs->mlmStaContext.mlmState !=
3190 eLIM_MLM_ASSOCIATED_STATE))))
3191 {
3192 /**
3193 * Received LIM_MLM_DISASSOC_REQ for STA that does not
3194 * have context or in some transit state.
3195 * Log error
3196 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303197 limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303198 FL("received MLM_DISASSOC_REQ for STA that either has no context "
3199 "or in some transit state, Addr= "
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303200 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3201 if (pStaDs != NULL)
3202 limLog(pMac, LOGE, FL("Sta MlmState : %d"),
3203 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303205 /*
3206 * Disassociation response due to
3207 * host triggered disassociation
3208 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003209
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303210 pSirSmeDisassocRsp = vos_mem_malloc(sizeof(tSirSmeDisassocRsp));
3211 if ( NULL == pSirSmeDisassocRsp )
3212 {
3213 // Log error
3214 limLog(pMac, LOGP,
3215 FL("call to AllocateMemory failed for eWNI_SME_DISASSOC_RSP"));
3216 return;
3217 }
3218 limLog(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
3219 "retCode: %d for "MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3220 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3221 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
3222 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
3223 pSirSmeDisassocRsp->sessionId = pMlmDisassocReq->sessionId;
3224 pSirSmeDisassocRsp->transactionId = 0;
3225 pSirSmeDisassocRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003226
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303227 pBuf = (tANI_U8 *) pSirSmeDisassocRsp->peerMacAddr;
3228 vos_mem_copy( pBuf, pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr));
3229
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303230 msg.type = eWNI_SME_DISASSOC_RSP;
3231 msg.bodyptr = pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303232
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303233 if (pMac->lim.sme_msg_callback)
3234 pMac->lim.sme_msg_callback(pMac, &msg);
3235 else
3236 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
3237
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303238 return;
3239
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 }
3241
3242 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3243 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3244 pMlmDisassocReq->reasonCode;
3245 pStaDs->mlmStaContext.cleanupTrigger = pMlmDisassocReq->disassocTrigger;
Mukul Sharma91947a22014-06-09 11:07:51 +05303246 /** Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3247 * This is to address the issue of race condition between
3248 * disconnect request from the HDD and deauth from AP
3249 */
3250 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003251
3252 /// Send Disassociate frame to peer entity
Jeff Johnsone7245742012-09-05 17:12:55 -07003253 if (sendDisassocFrame && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003255 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = pMlmDisassocReq;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303256 if (IS_FW_IN_TX_PATH_FEATURE_ENABLE)
Sandeep Puligilla25728282013-12-01 19:44:14 +05303257 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303258 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Sandeep Puligilla25728282013-12-01 19:44:14 +05303259 pMlmDisassocReq->peerMacAddr,
3260 psessionEntry, FALSE);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303261 /* Send Disassoc CNF and receive path cleanup */
3262 limSendDisassocCnf(pMac);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303263 }
3264 else
3265 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303266 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003267 pMlmDisassocReq->peerMacAddr,
3268 psessionEntry, TRUE);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 }
3271 else
3272 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003273 /* Disassoc frame is not sent OTA */
3274 sendDisassocFrame = 1;
3275 // Receive path cleanup with dummy packet
3276 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs,psessionEntry))
3277 {
3278 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3279 goto end;
3280 }
3281 // Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303282 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 return;
3286
3287end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303288 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3289 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3290 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3292 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3293
3294 /* Update PE session ID*/
3295 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3296
3297 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303298 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299
3300 limPostSmeMessage(pMac,
3301 LIM_MLM_DISASSOC_CNF,
3302 (tANI_U32 *) &mlmDisassocCnf);
3303}
3304
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003305tANI_BOOLEAN limCheckDisassocDeauthAckPending(tpAniSirGlobal pMac,
3306 tANI_U8 *staMac
3307 )
3308{
3309 tLimMlmDisassocReq *pMlmDisassocReq;
3310 tLimMlmDeauthReq *pMlmDeauthReq;
3311 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3312 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3313 if (
3314 (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303315 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003316 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3317 sizeof(tSirMacAddr))))
3318 ||
3319 (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303320 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003321 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303322 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003323 )
3324 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003325 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth ack pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003326 return eANI_BOOLEAN_TRUE;
3327 }
3328 else
3329 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003330 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth Ack not pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003331 return eANI_BOOLEAN_FALSE;
3332 }
3333}
3334
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003335void limCleanUpDisassocDeauthReq(tpAniSirGlobal pMac,
3336 tANI_U8 *staMac,
3337 tANI_BOOLEAN cleanRxPath)
3338{
3339 tLimMlmDisassocReq *pMlmDisassocReq;
3340 tLimMlmDeauthReq *pMlmDeauthReq;
3341 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3342 if (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303343 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003344 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3345 sizeof(tSirMacAddr))))
3346 {
3347 if (cleanRxPath)
3348 {
3349 limProcessDisassocAckTimeout(pMac);
3350 }
3351 else
3352 {
3353 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3354 {
3355 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3356 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303357 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003358 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3359 }
3360 }
3361
3362 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3363 if (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303364 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003365 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
3366 sizeof(tSirMacAddr))))
3367 {
3368 if (cleanRxPath)
3369 {
3370 limProcessDeauthAckTimeout(pMac);
3371 }
3372 else
3373 {
3374 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3375 {
3376 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3377 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303378 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003379 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3380 }
3381 }
3382}
3383
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003384void limProcessDisassocAckTimeout(tpAniSirGlobal pMac)
3385{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303386 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003387 limSendDisassocCnf(pMac);
3388}
3389
Jeff Johnson295189b2012-06-20 16:38:30 -07003390/**
3391 * limProcessMlmDisassocReq()
3392 *
3393 *FUNCTION:
3394 * This function is called to process MLM_DISASSOC_REQ message
3395 * from SME
3396 *
3397 *LOGIC:
3398 *
3399 *ASSUMPTIONS:
3400 *
3401 *NOTE:
3402 *
3403 * @param pMac Pointer to Global MAC structure
3404 * @param *pMsgBuf A pointer to the MLM message buffer
3405 * @return None
3406 */
3407
3408static void
3409limProcessMlmDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3410{
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 tLimMlmDisassocReq *pMlmDisassocReq;
Jeff Johnson295189b2012-06-20 16:38:30 -07003412
3413 if(pMsgBuf == NULL)
3414 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003415 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 return;
3417 }
3418
3419 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05303420
Abhishek Singhcd09b562013-12-24 16:02:20 +05303421 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d "
3422 "from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3423 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003424
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003425 limProcessMlmDisassocReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427} /*** limProcessMlmDisassocReq() ***/
3428
3429static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003430limProcessMlmDeauthReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003431{
3432 tANI_U16 aid;
3433 tSirMacAddr currentBssId;
3434 tpDphHashNode pStaDs;
3435 struct tLimPreAuthNode *pAuthNode;
3436 tLimMlmDeauthReq *pMlmDeauthReq;
3437 tLimMlmDeauthCnf mlmDeauthCnf;
3438 tpPESession psessionEntry;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303439 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
3440 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303441 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003442
3443 if(eHAL_STATUS_SUCCESS != suspendStatus)
3444 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003445 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003446#if 0
3447 //It can ignore the status and proceed with the disassoc processing.
3448 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3449 goto end;
3450#endif
3451 }
3452
3453 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3454
3455 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3456 {
3457
Abhishek Singhcd09b562013-12-24 16:02:20 +05303458 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3459 pMlmDeauthReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303460 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 return;
3462 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303463 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d Systemrole %d"
3464 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3465 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3466 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 #if 0
3468 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3469 eSIR_SUCCESS)
3470 {
3471 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003472 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 }
3474 #endif //SUPPORT BT-AMP
3475 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3476
3477 switch (psessionEntry->limSystemRole)
3478 {
3479 case eLIM_STA_ROLE:
3480 case eLIM_BT_AMP_STA_ROLE:
3481 switch (psessionEntry->limMlmState)
3482 {
3483 case eLIM_MLM_IDLE_STATE:
3484 // Attempting to Deauthenticate
3485 // with a pre-authenticated peer.
3486 // Deauthetiate with peer if there
3487 // exists a pre-auth context below.
3488 break;
3489
3490 case eLIM_MLM_AUTHENTICATED_STATE:
3491 case eLIM_MLM_WT_ASSOC_RSP_STATE:
3492 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303493 if (!vos_mem_compare(pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 currentBssId,
3495 sizeof(tSirMacAddr)) )
3496 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05303497 limLog(pMac, LOGE,
3498 FL("received MLM_DEAUTH_REQ with invalid BSS id "
3499 "Peer MAC: "MAC_ADDRESS_STR " CFG BSSID Addr : "
3500 MAC_ADDRESS_STR),
3501 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr),
3502 MAC_ADDR_ARRAY(currentBssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003503
3504 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3505
3506 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3507
3508 goto end;
3509 }
3510
3511 if ((psessionEntry->limMlmState ==
3512 eLIM_MLM_AUTHENTICATED_STATE) ||
3513 (psessionEntry->limMlmState ==
3514 eLIM_MLM_WT_ASSOC_RSP_STATE))
3515 {
3516 // Send Deauthentication frame
3517 // to peer entity
3518 limSendDeauthMgmtFrame(
3519 pMac,
3520 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003521 pMlmDeauthReq->peerMacAddr,
3522 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003523
3524 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3525 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3526 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003527 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 goto end;
3529 }
3530 else
3531 {
3532 // LINK_ESTABLISED_STATE
3533 // Cleanup RX & TX paths
3534 // below
3535 }
3536
3537 break;
3538
3539 default:
3540
3541 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303542 FL("received MLM_DEAUTH_REQ with in state %d for peer "MAC_ADDRESS_STR),
3543 psessionEntry->limMlmState,MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3545
3546 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3547 mlmDeauthCnf.resultCode =
3548 eSIR_SME_STA_NOT_AUTHENTICATED;
3549
3550 goto end;
3551 }
3552
3553 break;
3554
3555 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303556 limLog(pMac, LOGE,
3557 FL("received MLM_DEAUTH_REQ IBSS Mode "));
3558 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3559 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 default: // eLIM_AP_ROLE
3561 break;
3562
3563 } // end switch (psessionEntry->limSystemRole)
3564
3565 /**
3566 * Check if there exists a context for the peer entity
3567 * to be deauthenticated with.
3568 */
3569 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3570
3571 if (pStaDs == NULL)
3572 {
3573 /// Check if there exists pre-auth context for this STA
3574 pAuthNode = limSearchPreAuthList(pMac,
3575 pMlmDeauthReq->peerMacAddr);
3576
3577 if (pAuthNode == NULL)
3578 {
3579 /**
3580 * Received DEAUTH REQ for a STA that is neither
3581 * Associated nor Pre-authenticated. Log error,
3582 * Prepare and Send LIM_MLM_DEAUTH_CNF
3583 */
3584 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303585 FL("received MLM_DEAUTH_REQ in mlme state %d for STA that "
3586 "does not have context, Addr="MAC_ADDRESS_STR),
3587 psessionEntry->limMlmState,
3588 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003589
3590 mlmDeauthCnf.resultCode =
3591 eSIR_SME_STA_NOT_AUTHENTICATED;
3592 }
3593 else
3594 {
3595 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3596
3597 /// Delete STA from pre-auth STA list
3598 limDeletePreAuthNode(pMac, pMlmDeauthReq->peerMacAddr);
3599
3600 /// Send Deauthentication frame to peer entity
3601 limSendDeauthMgmtFrame(pMac,
3602 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003603 pMlmDeauthReq->peerMacAddr,
3604 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 }
3606
3607 goto end;
3608 }
3609 else if ((pStaDs->mlmStaContext.mlmState !=
3610 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3611 (pStaDs->mlmStaContext.mlmState !=
3612 eLIM_MLM_WT_ASSOC_CNF_STATE))
3613 {
3614 /**
3615 * Received LIM_MLM_DEAUTH_REQ for STA that is n
3616 * some transit state. Log error.
3617 */
3618 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303619 FL("received MLM_DEAUTH_REQ for STA that either has no context or in some transit state, Addr="
3620 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003621
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303622 /*
3623 * Deauthentication response to host triggered
3624 * deauthentication.
3625 */
3626 pSirSmeDeauthRsp = vos_mem_malloc(sizeof(tSirSmeDeauthRsp));
3627 if ( NULL == pSirSmeDeauthRsp )
3628 {
3629 // Log error
3630 limLog(pMac, LOGP,
3631 FL("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303633 return;
3634 }
3635 limLog(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
3636 "retCode: %d for"MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3637 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3638 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
3639 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
3640 pSirSmeDeauthRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
3641 pSirSmeDeauthRsp->sessionId = pMlmDeauthReq->sessionId;
3642 pSirSmeDeauthRsp->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003643
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303644 pBuf = (tANI_U8 *) pSirSmeDeauthRsp->peerMacAddr;
3645 vos_mem_copy( pBuf, pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr));
3646
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303647 msg.type = eWNI_SME_DEAUTH_RSP;
3648 msg.bodyptr = pSirSmeDeauthRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303649
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303650 if (pMac->lim.sme_msg_callback)
3651 pMac->lim.sme_msg_callback(pMac, &msg);
3652 else
3653 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303654
3655 return;
3656
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 }
3658
3659 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3660 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3661 pMlmDeauthReq->reasonCode;
3662 pStaDs->mlmStaContext.cleanupTrigger = pMlmDeauthReq->deauthTrigger;
3663
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003664 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = pMlmDeauthReq;
Abhishek Singh94152932014-01-16 19:04:51 +05303665
3666 /* Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3667 * This is to address the issue of race condition between
3668 * disconnect request from the HDD and disassoc from
3669 * inactivity timer. This will make sure that we will not
3670 * process disassoc if deauth is in progress for the station
3671 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
3672 */
3673 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
3674
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 /// Send Deauthentication frame to peer entity
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303676 /* If FW_IN_TX_PATH feature is enabled
3677 do not wait for ACK */
3678 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3679 {
3680 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3681 pMlmDeauthReq->peerMacAddr,
3682 psessionEntry, FALSE);
3683
3684 /* Send Deauth CNF and receive path cleanup */
3685 limSendDeauthCnf(pMac);
3686 }
3687 else
3688 {
3689 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3690 pMlmDeauthReq->peerMacAddr,
3691 psessionEntry, TRUE);
3692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003693
3694 return;
3695
3696end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303697 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3698 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3699 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3701 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3702 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3703
3704 // Free up buffer allocated
3705 // for mlmDeauthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303706 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003707
3708 limPostSmeMessage(pMac,
3709 LIM_MLM_DEAUTH_CNF,
3710 (tANI_U32 *) &mlmDeauthCnf);
3711
3712}
3713
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003714
3715void limProcessDeauthAckTimeout(tpAniSirGlobal pMac)
3716{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303717 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003718 limSendDeauthCnf(pMac);
3719}
3720
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303721void lim_process_ap_ecsa_timeout(tpAniSirGlobal mac_ctx)
3722{
3723 tSirMsgQ msg = {0};
3724 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
3725 tpPESession session;
3726
3727 session = peFindSessionBySessionId(mac_ctx,
3728 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3729
3730 if(!session)
3731 {
3732 limLog(mac_ctx, LOGE, FL("session does not exist for given sessionId %d"),
3733 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3734 return;
3735 }
3736 limLog(mac_ctx, LOG1, FL("session id %d switch count %d"),
3737 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId,
3738 session->gLimChannelSwitch.switchCount);
3739 /*
3740 * For each beacon interval decrement switch count to use proper value
3741 * in probe resp sent by host. Once it becomes 0 send tx complete
3742 * indication to SME.
3743 */
3744 if (session->gLimChannelSwitch.switchCount > 0) {
3745 session->gLimChannelSwitch.switchCount--;
Abhishek Singh449c5372017-12-19 17:21:20 +05303746 lim_send_chan_switch_action_frame(mac_ctx,
3747 session->gLimChannelSwitch.primaryChannel, session);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303748 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
3749 session->peSessionId;
3750 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
3751
3752 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
3753 TX_SUCCESS)
3754 {
3755 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
3756 lim_process_ap_ecsa_timeout(mac_ctx);
3757 }
3758 return;
3759 }
3760
3761 session->include_ecsa_ie = false;
3762 session->include_wide_ch_bw_ie = false;
3763
3764 ecsa_ie_cmp_ind = vos_mem_malloc(sizeof(*ecsa_ie_cmp_ind));
3765 if(!ecsa_ie_cmp_ind)
3766 {
3767 limLog(mac_ctx, LOGE, FL("failed to allocate ecsa_ie_cmp_ind"));
3768 return;
3769 }
3770 ecsa_ie_cmp_ind->session_id = session->smeSessionId;
3771
3772 msg.type = eWNI_SME_ECSA_IE_BEACON_COMP_IND;
3773 msg.bodyptr = ecsa_ie_cmp_ind;
3774 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3775 return;
3776}
3777
3778void lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal mac_ctx,
3779 tpPESession session, tpSwitchChannelParams chan_params)
3780{
3781 tSirMsgQ msg = {0};
3782 struct sir_channel_chanege_rsp *params;
3783
3784 params = vos_mem_malloc(sizeof(*params));
3785 if (!params) {
3786 limLog(mac_ctx, LOGE, FL("AllocateMemory failed for pSmeSwithChnlParams"));
3787 return;
3788 }
3789
3790 params->sme_session_id = session->smeSessionId;
3791 params->new_channel = chan_params->channelNumber;
3792 params->status = chan_params->status;
3793
3794 msg.type = eWNI_SME_ECSA_CHAN_CHANGE_RSP;
3795 msg.bodyptr = params;
3796 msg.bodyval = 0;
3797 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3798
3799 if (chan_params->channelNumber == session->currentOperChannel) {
3800 limApplyConfiguration(mac_ctx, session);
3801 limSendBeaconInd(mac_ctx, session);
3802 } else {
3803 limLog(mac_ctx, LOGE, FL("channel switch resp chan %d and session channel doesnt match %d"),
3804 chan_params->channelNumber, session->currentOperChannel);
3805 }
3806
3807 return;
3808}
3809
3810
Jeff Johnson295189b2012-06-20 16:38:30 -07003811/**
3812 * limProcessMlmDeauthReq()
3813 *
3814 *FUNCTION:
3815 * This function is called to process MLM_DEAUTH_REQ message
3816 * from SME
3817 *
3818 *LOGIC:
3819 *
3820 *ASSUMPTIONS:
3821 *
3822 *NOTE:
3823 *
3824 * @param pMac Pointer to Global MAC structure
3825 * @param *pMsgBuf A pointer to the MLM message buffer
3826 * @return None
3827 */
3828
3829static void
3830limProcessMlmDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3831{
3832// tANI_U16 aid;
3833// tSirMacAddr currentBssId;
3834// tpDphHashNode pStaDs;
3835// struct tLimPreAuthNode *pAuthNode;
3836 tLimMlmDeauthReq *pMlmDeauthReq;
3837// tLimMlmDeauthCnf mlmDeauthCnf;
3838 tpPESession psessionEntry;
3839
3840 if(pMsgBuf == NULL)
3841 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003842 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 return;
3844 }
3845
3846 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3847
Abhishek Singhcd09b562013-12-24 16:02:20 +05303848 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d "
3849 "from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3850 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3853 {
3854
Abhishek Singhcd09b562013-12-24 16:02:20 +05303855 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3856 pMlmDeauthReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 return;
3858 }
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003859 limProcessMlmDeauthReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
3860
Jeff Johnson295189b2012-06-20 16:38:30 -07003861} /*** limProcessMlmDeauthReq() ***/
3862
3863
3864
3865/**
3866 * @function : limProcessMlmSetKeysReq()
3867 *
3868 * @brief : This function is called to process MLM_SETKEYS_REQ message
3869 * from SME
3870 *
3871 *LOGIC:
3872 *
3873 *ASSUMPTIONS:
3874 *
3875 *NOTE:
3876 *
3877 * @param pMac Pointer to Global MAC structure
3878 * @param *pMsgBuf A pointer to the MLM message buffer
3879 * @return None
3880 */
3881
3882static void
3883limProcessMlmSetKeysReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3884{
3885tANI_U16 aid;
3886tANI_U16 staIdx = 0;
3887tANI_U32 defaultKeyId = 0;
3888tSirMacAddr currentBssId;
3889tpDphHashNode pStaDs;
3890tLimMlmSetKeysReq *pMlmSetKeysReq;
3891tLimMlmSetKeysCnf mlmSetKeysCnf;
3892tpPESession psessionEntry;
3893
3894 if(pMsgBuf == NULL)
3895 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003896 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 return;
3898 }
3899
3900
3901 pMlmSetKeysReq = (tLimMlmSetKeysReq *) pMsgBuf;
3902 // Hold onto the SetKeys request parameters
3903 pMac->lim.gpLimMlmSetKeysReq = (void *) pMlmSetKeysReq;
3904
3905 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmSetKeysReq->sessionId))== NULL)
3906 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003907 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 return;
3909 }
3910
3911 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003912 FL( "Received MLM_SETKEYS_REQ with parameters:"
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "),
3914 pMlmSetKeysReq->aid,
3915 pMlmSetKeysReq->edType,
3916 pMlmSetKeysReq->numKeys );
3917 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3918
3919 #if 0
3920 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, currentBssId, &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 return;
3923 }
3924 #endif //TO SUPPORT BT-AMP
3925 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3926
3927 switch( psessionEntry->limSystemRole ) {
3928 case eLIM_STA_ROLE:
3929 case eLIM_BT_AMP_STA_ROLE:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003930 //In case of TDLS, peerMac address need not be BssId. Skip this check
3931 //if TDLS is enabled.
3932#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 if((!limIsAddrBC( pMlmSetKeysReq->peerMacAddr ) ) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303934 (!vos_mem_compare(pMlmSetKeysReq->peerMacAddr,
3935 currentBssId, sizeof(tSirMacAddr))) ){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003936 limLog( pMac, LOGW, FL("Received MLM_SETKEYS_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3938
3939 // Prepare and Send LIM_MLM_SETKEYS_CNF with error code
3940 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3941 goto end;
3942 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003943#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 // Fall thru' & 'Plumb' keys below
3945 break;
3946 case eLIM_STA_IN_IBSS_ROLE:
3947 default: // others
3948 // Fall thru...
3949 break;
3950 }
3951
3952 /**
3953 * Use the "unicast" parameter to determine if the "Group Keys"
3954 * are being set.
3955 * pMlmSetKeysReq->key.unicast = 0 -> Multicast/broadcast
3956 * pMlmSetKeysReq->key.unicast - 1 -> Unicast keys are being set
3957 */
3958 if( limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003959 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "), pMlmSetKeysReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 /** When trying to set Group Keys for any
3961 * security mode other than WEP, use the
3962 * STA Index corresponding to the AP...
3963 */
3964 switch( pMlmSetKeysReq->edType ) {
3965 case eSIR_ED_CCMP:
3966
3967#ifdef WLAN_FEATURE_11W
3968 case eSIR_ED_AES_128_CMAC:
3969#endif
3970 staIdx = psessionEntry->staId;
3971 break;
3972
3973 default:
3974 break;
3975 }
3976 }else {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003977 limLog( pMac, LOG1, FL("Trying to set Unicast Keys..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 /**
3979 * Check if there exists a context for the
3980 * peer entity for which keys need to be set.
3981 */
3982
3983
3984 pStaDs = dphLookupHashEntry( pMac, pMlmSetKeysReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
3985
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 if ((pStaDs == NULL) ||
3987 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) && (psessionEntry->limSystemRole != eLIM_AP_ROLE))) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 /**
3989 * Received LIM_MLM_SETKEYS_REQ for STA
3990 * that does not have context or in some
3991 * transit state. Log error.
3992 */
3993 limLog( pMac, LOG1,
3994 FL("Received MLM_SETKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3995 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3996
3997 // Prepare and Send LIM_MLM_SETKEYS_CNF
3998 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3999 goto end;
4000 } else
4001 staIdx = pStaDs->staIndex;
4002 }
4003
4004 if ((pMlmSetKeysReq->numKeys == 0) && (pMlmSetKeysReq->edType != eSIR_ED_NONE)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004005 //
4006 // Broadcast/Multicast Keys (for WEP!!) are NOT sent
4007 // via this interface!!
4008 //
4009 // This indicates to HAL that the WEP Keys need to be
4010 // extracted from the CFG and applied to hardware
4011 defaultKeyId = 0xff;
4012 }else if(pMlmSetKeysReq->key[0].keyId &&
4013 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
4014 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))){
4015 /* If the Key Id is non zero and encryption mode is WEP,
4016 * the key index is coming from the upper layers so that key only
4017 * need to be used as the default tx key, This is being used only
4018 * in case of WEP mode in HAL */
4019 defaultKeyId = pMlmSetKeysReq->key[0].keyId;
4020 }else
4021 defaultKeyId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004022
4023 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004024 FL( "Trying to set keys for STA Index [%d], using defaultKeyId [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 staIdx,
4026 defaultKeyId );
4027
4028 if(limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
4029 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
4030 psessionEntry->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004031 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004032 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 psessionEntry->peSessionId);
4034
4035 // Package WDA_SET_BSSKEY_REQ message parameters
4036 limSendSetBssKeyReq(pMac, pMlmSetKeysReq,psessionEntry);
4037 return;
4038 }else {
4039 // Package WDA_SET_STAKEY_REQ / WDA_SET_STA_BCASTKEY_REQ message parameters
4040 limSendSetStaKeyReq(pMac, pMlmSetKeysReq, staIdx, (tANI_U8) defaultKeyId,psessionEntry);
4041 return;
4042 }
4043
4044end:
4045 mlmSetKeysCnf.sessionId= pMlmSetKeysReq->sessionId;
4046 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
4047
4048} /*** limProcessMlmSetKeysReq() ***/
4049
4050/**
4051 * limProcessMlmRemoveKeyReq()
4052 *
4053 *FUNCTION:
4054 * This function is called to process MLM_REMOVEKEY_REQ message
4055 * from SME
4056 *
4057 *LOGIC:
4058 *
4059 *ASSUMPTIONS:
4060 *
4061 *NOTE:
4062 *
4063 * @param pMac Pointer to Global MAC structure
4064 * @param *pMsgBuf A pointer to the MLM message buffer
4065 * @return None
4066 */
4067
4068static void
4069limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4070{
4071tANI_U16 aid;
4072tANI_U16 staIdx = 0;
4073tSirMacAddr currentBssId;
4074tpDphHashNode pStaDs;
4075tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
4076tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
4077 tpPESession psessionEntry;
4078
4079 if(pMsgBuf == NULL)
4080 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004081 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 return;
4083 }
4084
4085 pMlmRemoveKeyReq = (tLimMlmRemoveKeyReq *) pMsgBuf;
4086
4087
4088 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyReq->sessionId))== NULL)
4089 {
4090 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004091 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304092 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 return;
4094 }
4095
4096
4097 if( pMac->lim.gpLimMlmRemoveKeyReq != NULL )
4098 {
4099 // Free any previous requests.
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304100 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
4102 }
4103 // Hold onto the RemoveKeys request parameters
4104 pMac->lim.gpLimMlmRemoveKeyReq = (void *) pMlmRemoveKeyReq;
4105
4106 #if 0
4107 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
4108 WNI_CFG_BSSID,
4109 currentBssId,
4110 &cfg ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004111 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 #endif //TO-SUPPORT BT-AMP
4113 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
4114
4115 switch( psessionEntry->limSystemRole )
4116 {
4117 case eLIM_STA_ROLE:
4118 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304119 if (( limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr ) != true ) &&
4120 (!vos_mem_compare(pMlmRemoveKeyReq->peerMacAddr,
4121 currentBssId,
4122 sizeof(tSirMacAddr))))
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 {
4124 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004125 FL("Received MLM_REMOVEKEY_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
4127
4128 // Prepare and Send LIM_MLM_REMOVEKEY_CNF with error code
4129 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4130 goto end;
4131 }
4132 break;
4133
4134 case eLIM_STA_IN_IBSS_ROLE:
4135 default: // eLIM_AP_ROLE
4136 // Fall thru...
4137 break;
4138 }
4139
4140
4141 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
4142 if(limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr )) //Second condition for IBSS or AP role.
4143 {
4144 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004145 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 // Package WDA_REMOVE_BSSKEY_REQ message parameters
4147 limSendRemoveBssKeyReq( pMac,pMlmRemoveKeyReq,psessionEntry);
4148 return;
4149 }
4150
4151 /**
4152 * Check if there exists a context for the
4153 * peer entity for which keys need to be removed.
4154 */
4155 pStaDs = dphLookupHashEntry( pMac, pMlmRemoveKeyReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4156 if ((pStaDs == NULL) ||
4157 (pStaDs &&
4158 (pStaDs->mlmStaContext.mlmState !=
4159 eLIM_MLM_LINK_ESTABLISHED_STATE)))
4160 {
4161 /**
4162 * Received LIM_MLM_REMOVEKEY_REQ for STA
4163 * that does not have context or in some
4164 * transit state. Log error.
4165 */
4166 limLog( pMac, LOGW,
4167 FL("Received MLM_REMOVEKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
4168 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
4169
4170 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
4171 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4172 mlmRemoveKeyCnf.sessionId = pMlmRemoveKeyReq->sessionId;
4173
4174
4175 goto end;
4176 }
4177 else
4178 staIdx = pStaDs->staIndex;
4179
4180
4181
4182 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004183 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004184
4185 // Package WDA_REMOVE_STAKEY_REQ message parameters
4186 limSendRemoveStaKeyReq( pMac,pMlmRemoveKeyReq,staIdx,psessionEntry);
4187 return;
4188
4189end:
4190 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07004191 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 pMlmRemoveKeyReq,
4193 &mlmRemoveKeyCnf );
4194
4195} /*** limProcessMlmRemoveKeyReq() ***/
4196
4197
4198/**
4199 * limProcessMinChannelTimeout()
4200 *
4201 *FUNCTION:
4202 * This function is called to process Min Channel Timeout
4203 * during channel scan.
4204 *
4205 *LOGIC:
4206 *
4207 *ASSUMPTIONS:
4208 *
4209 *NOTE:
4210 *
4211 * @param pMac Pointer to Global MAC structure
4212 * @return None
4213 */
4214
4215static void
4216limProcessMinChannelTimeout(tpAniSirGlobal pMac)
4217{
4218 tANI_U8 channelNum;
4219
4220#ifdef GEN6_TODO
4221 //if the min Channel is maintained per session, then use the below seesionEntry
4222 //priority - LOW/might not be needed
4223
4224 //TBD-RAJESH HOW TO GET sessionEntry?????
4225 tpPESession psessionEntry;
4226
4227 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimMinChannelTimer.sessionId))== NULL)
4228 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004229 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 return;
4231 }
4232#endif
4233
Abhishek Singh89e1d672013-11-28 15:13:42 +05304234 /*do not process if we are in finish scan wait state i.e.
4235 scan is aborted or finished*/
4236 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE &&
4237 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 /// Min channel timer timed out
4240 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
4241 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
4242 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05304243 /*
4244 * Deactivate Max Channel timer as well since no probe resp/beacons
4245 * are received.
4246 */
4247 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004248 pMac->lim.probeCounter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 if (pMac->lim.gLimCurrentScanChannelId <=
4250 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4251 {
4252 channelNum = (tANI_U8)limGetCurrentScanChannel(pMac);
4253 }
4254 else
4255 {
4256 // This shouldn't be the case, but when this happens, this timeout should be for the last channelId.
4257 // Get the channelNum as close to correct as possible.
4258 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4259 {
4260 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4261 }
4262 else
4263 {
4264 channelNum = 1;
4265 }
4266 }
4267
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004268 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304269 FL("Sending End Scan req from MIN_CH_TIMEOUT in state %d ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004270 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4272 }
4273 else
4274 {
4275 /**
4276 * MIN channel timer should not have timed out
4277 * in states other than wait_probe_response.
4278 * Log error.
4279 */
4280 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304281 FL("received unexpected MIN channel timeout in mlme state %d and hal scan State %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304282 pMac->lim.gLimMlmState,pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 limPrintMlmState(pMac, LOGE, pMac->lim.gLimMlmState);
4284 }
4285} /*** limProcessMinChannelTimeout() ***/
4286
4287
4288
4289/**
4290 * limProcessMaxChannelTimeout()
4291 *
4292 *FUNCTION:
4293 * This function is called to process Max Channel Timeout
4294 * during channel scan.
4295 *
4296 *LOGIC:
4297 *
4298 *ASSUMPTIONS:
4299 *
4300 *NOTE:
4301 *
4302 * @param pMac Pointer to Global MAC structure
4303 * @return None
4304 */
4305
4306static void
4307limProcessMaxChannelTimeout(tpAniSirGlobal pMac)
4308{
4309 tANI_U8 channelNum;
4310
Abhishek Singh89e1d672013-11-28 15:13:42 +05304311 /*do not process if we are in finish scan wait state i.e.
4312 scan is aborted or finished*/
4313 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE ||
4314 pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE) &&
4315 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304317 limLog(pMac, LOG1, FL("Scanning : Max channel timed out"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 /**
4319 * MAX channel timer timed out
4320 * Continue channel scan.
4321 */
4322 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
4323 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
4324 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004325 pMac->lim.probeCounter = 0;
4326
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004327 if (pMac->lim.gLimCurrentScanChannelId <=
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4329 {
4330 channelNum = limGetCurrentScanChannel(pMac);
4331 }
4332 else
4333 {
4334 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4335 {
4336 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4337 }
4338 else
4339 {
4340 channelNum = 1;
4341 }
4342 }
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004343 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304344 FL("Sending End Scan req from MAX_CH_TIMEOUT in state %d on ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004345 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4347 }
4348 else
4349 {
4350 /**
4351 * MAX channel timer should not have timed out
4352 * in states other than wait_scan.
4353 * Log error.
4354 */
4355 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304356 FL("received unexpected MAX channel timeout in mlme state %d and hal scan state %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304357 pMac->lim.gLimMlmState, pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
4359 }
4360} /*** limProcessMaxChannelTimeout() ***/
4361
4362/**
4363 * limProcessPeriodicProbeReqTimer()
4364 *
4365 *FUNCTION:
4366 * This function is called to process periodic probe request
4367 * to send during scan.
4368 *
4369 *LOGIC:
4370 *
4371 *ASSUMPTIONS:
4372 *
4373 *NOTE:
4374 *
4375 * @param pMac Pointer to Global MAC structure
4376 * @return None
4377 */
4378
4379static void
4380limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac)
4381{
4382 tANI_U8 channelNum;
4383 tANI_U8 i = 0;
4384 tSirRetStatus status = eSIR_SUCCESS;
4385 TX_TIMER *pPeriodicProbeReqTimer;
4386 pPeriodicProbeReqTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
4387
4388 if(vos_timer_getCurrentState(&pPeriodicProbeReqTimer->vosTimer)
4389 != VOS_TIMER_STATE_STOPPED)
4390 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304391 limLog(pMac, LOG1, FL("Invalid state of timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 return;
4393 }
4394
4395 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004396 (pPeriodicProbeReqTimer->sessionId != 0xff) && (pMac->lim.probeCounter < pMac->lim.maxProbe))
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 {
4398 tLimMlmScanReq *pLimMlmScanReq = pMac->lim.gpLimMlmScanReq;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004399 pMac->lim.probeCounter++;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 /**
4401 * Periodic channel timer timed out
4402 * to send probe request.
4403 */
4404 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +05304405 /* Prepare and send Probe Request frame for all the SSIDs
4406 * present in the saved MLM
4407 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 do
4409 {
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304410 tSirMacAddr gSelfMacAddr;
4411 bool spoof = lim_is_spoofing_needed(pMac);
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304412
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304413 if (spoof)
4414 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr,
4415 VOS_MAC_ADDRESS_LEN);
4416 else
4417 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr,
4418 VOS_MAC_ADDRESS_LEN);
4419
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304420 limLog( pMac, LOG1, FL("Mac Addr used in Probe Req is :"MAC_ADDRESS_STR),
4421 MAC_ADDR_ARRAY(gSelfMacAddr));
4422
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 /*
4424 * PELOGE(limLog(pMac, LOGW, FL("sending ProbeReq number %d,"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004425 * " for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 * i, pLimMlmScanReq->ssId[i].ssId,
4427 * channelNum);)
4428 */
4429 status = limSendProbeReqMgmtFrame( pMac, &pLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304430 pLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 pLimMlmScanReq->dot11mode, pLimMlmScanReq->uIEFieldLen,
4432 (tANI_U8 *)(pLimMlmScanReq) + pLimMlmScanReq->uIEFieldOffset);
4433
4434
4435 if ( status != eSIR_SUCCESS)
4436 {
4437 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004438 "%s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 pLimMlmScanReq->ssId[i].ssId,
4440 channelNum);)
4441 return;
4442 }
4443 i++;
4444 } while (i < pLimMlmScanReq->numSsid);
4445
4446 /* Activate timer again */
4447 if (tx_timer_activate(pPeriodicProbeReqTimer) != TX_SUCCESS)
4448 {
4449 limLog(pMac, LOGP, FL("could not start periodic probe"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004450 " req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 return;
4452 }
4453 }
4454 else
4455 {
4456 /**
4457 * Periodic scan is timeout is happening in
4458 * in states other than wait_scan.
4459 * Log error.
4460 */
Mohit Khanna23863762012-09-11 17:40:09 -07004461 limLog(pMac, LOG1,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304462 FL("received unexpected Periodic scan timeout in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 pMac->lim.gLimMlmState);
4464 }
4465} /*** limProcessPeriodicProbeReqTimer() ***/
4466
4467/**
4468 * limProcessJoinFailureTimeout()
4469 *
4470 *FUNCTION:
4471 * This function is called to process JoinFailureTimeout
4472 *
4473 *LOGIC:
4474 *
4475 *ASSUMPTIONS:
4476 *
4477 *NOTE:
4478 *
4479 * @param pMac Pointer to Global MAC structure
4480 * @return None
4481 */
4482
4483static void
4484limProcessJoinFailureTimeout(tpAniSirGlobal pMac)
4485{
4486 tLimMlmJoinCnf mlmJoinCnf;
4487 tSirMacAddr bssid;
4488 tANI_U32 len;
krunal soni8d13b092013-07-19 13:23:29 -07004489#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4490 vos_log_rssi_pkt_type *pRssiLog = NULL;
4491#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004492
4493 //fetch the sessionEntry based on the sessionId
4494 tpPESession psessionEntry;
4495
4496 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimJoinFailureTimer.sessionId))== NULL)
4497 {
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07004498 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 return;
4500 }
krunal soni8d13b092013-07-19 13:23:29 -07004501
4502#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4503 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4504 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4505 if (pRssiLog)
4506 {
4507 pRssiLog->rssi = psessionEntry->rssi;
4508 }
4509 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4510#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4511
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
4513 {
4514 len = sizeof(tSirMacAddr);
4515
4516 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, bssid, &len) !=
4517 eSIR_SUCCESS)
4518 {
4519 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004520 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 return;
4522 }
4523
4524 // 'Change' timer for future activations
4525 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004526 // Change Periodic probe req timer for future activation
4527 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 /**
4529 * Issue MLM join confirm with timeout reason code
4530 */
Kiet Lam82004c62013-11-11 13:24:28 +05304531 PELOGE(limLog(pMac, LOGE, FL(" In state eLIM_MLM_WT_JOIN_BEACON_STATE."));)
4532 PELOGE(limLog(pMac, LOGE, FL(" Join Failure Timeout occurred for session %d with BSS "),
4533 psessionEntry->peSessionId);
4534 limPrintMacAddr(pMac, psessionEntry->bssId, LOGE);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004535
4536 mlmJoinCnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
4537 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4538
4539 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004540 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
4542 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004543 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 /* Update PE session Id */
4545 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
4546
4547
4548 // Freeup buffer allocated to join request
4549 if (psessionEntry->pLimMlmJoinReq)
4550 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304551 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 psessionEntry->pLimMlmJoinReq = NULL;
4553 }
4554
4555 limPostSmeMessage(pMac,
4556 LIM_MLM_JOIN_CNF,
4557 (tANI_U32 *) &mlmJoinCnf);
4558
4559 return;
4560 }
4561 else
4562 {
4563 /**
4564 * Join failure timer should not have timed out
4565 * in states other than wait_join_beacon state.
4566 * Log error.
4567 */
4568 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304569 FL("received unexpected JOIN failure timeout in state %d"),psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4571 }
4572} /*** limProcessJoinFailureTimeout() ***/
4573
4574
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004575/**
4576 * limProcessPeriodicJoinProbeReqTimer()
4577 *
4578 *FUNCTION:
4579 * This function is called to process periodic probe request
4580 * send during joining process.
4581 *
4582 *LOGIC:
4583 *
4584 *ASSUMPTIONS:
4585 *
4586 *NOTE:
4587 *
4588 * @param pMac Pointer to Global MAC structure
4589 * @return None
4590 */
4591
4592static void limProcessPeriodicJoinProbeReqTimer(tpAniSirGlobal pMac)
4593{
4594 tpPESession psessionEntry;
4595 tSirMacSSid ssId;
4596
4597 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId))== NULL)
4598 {
Kiet Lam82004c62013-11-11 13:24:28 +05304599 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4600 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004601 return;
4602 }
4603
4604 if((VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)) &&
4605 (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE))
4606 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304607 vos_mem_copy(ssId.ssId,
4608 psessionEntry->ssId.ssId,
4609 psessionEntry->ssId.length);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004610 ssId.length = psessionEntry->ssId.length;
4611
4612 limSendProbeReqMgmtFrame( pMac, &ssId,
4613 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
4614 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
4615 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
4616
4617 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
4618
4619 // Activate Join Periodic Probe Req timer
4620 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
4621 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004622 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer"));
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004623 return;
4624 }
4625 }
4626 return;
4627} /*** limProcessPeriodicJoinProbeReqTimer() ***/
4628
Sushant Kaushik9e923872015-04-02 17:09:31 +05304629/**
4630 * limProcessAuthRetryTimer()
4631 *
4632 *FUNCTION:
4633 * This function is called to process Auth Retry request
4634 * send during joining process.
4635 *
4636 *LOGIC:
4637 *
4638 *ASSUMPTIONS:
4639 *
4640 *NOTE:
4641 *
4642 * @param pMac Pointer to Global MAC structure
4643 * @return None
4644 */
4645
4646static void limProcessAuthRetryTimer(tpAniSirGlobal pMac)
4647{
4648 tpPESession psessionEntry;
4649 limLog(pMac, LOG1, FL(" ENTER "));
4650 if ((psessionEntry =
4651 peFindSessionBySessionId(pMac,
4652 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId)) == NULL)
4653 {
4654 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4655 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId);
4656 return;
4657 }
4658
4659 if ((VOS_TRUE ==
4660 tx_timer_running(&pMac->lim.limTimers.gLimAuthFailureTimer)) &&
4661 (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
4662 (LIM_AUTH_ACK_RCD_SUCCESS != pMac->authAckStatus))
4663 {
4664 tSirMacAuthFrameBody authFrameBody;
4665
4666 /* Send the auth retry only in case we have received ack failure
4667 * else just restart the retry timer.
4668 */
4669 if (LIM_AUTH_ACK_RCD_FAILURE == pMac->authAckStatus)
4670 {
4671 /// Prepare & send Authentication frame
4672 authFrameBody.authAlgoNumber =
4673 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
4674 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
4675 authFrameBody.authStatusCode = 0;
4676 limLog(pMac, LOGW, FL("Retry Auth "));
4677 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
4678 limSendAuthMgmtFrame(pMac,
4679 &authFrameBody,
4680 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
4681 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
4682 }
4683
4684 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
4685
4686 // Activate Auth Retry timer
4687 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
4688 != TX_SUCCESS)
4689 {
4690 limLog(pMac, LOGE,
4691 FL("could not activate Auth Retry failure timer"));
4692 return;
4693 }
4694 }
4695 return;
4696} /*** limProcessAuthRetryTimer() ***/
4697
Jeff Johnson295189b2012-06-20 16:38:30 -07004698
4699/**
4700 * limProcessAuthFailureTimeout()
4701 *
4702 *FUNCTION:
4703 * This function is called to process Min Channel Timeout
4704 * during channel scan.
4705 *
4706 *LOGIC:
4707 *
4708 *ASSUMPTIONS:
4709 *
4710 *NOTE:
4711 *
4712 * @param pMac Pointer to Global MAC structure
4713 * @return None
4714 */
4715
4716static void
4717limProcessAuthFailureTimeout(tpAniSirGlobal pMac)
4718{
4719 //fetch the sessionEntry based on the sessionId
4720 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004721#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4722 vos_log_rssi_pkt_type *pRssiLog = NULL;
4723#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAuthFailureTimer.sessionId))== NULL)
4725 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004726 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 return;
4728 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304729 limLog(pMac, LOGE, FL("received AUTH failure timeout in sessionid %d "
Sushant Kaushik1b645382014-10-13 16:39:36 +05304730 "limMlmstate %d limSmeState %d"), psessionEntry->peSessionId,
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304731 psessionEntry->limMlmState, psessionEntry->limSmeState);
krunal soni8d13b092013-07-19 13:23:29 -07004732#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4733 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4734 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4735 if (pRssiLog)
4736 {
4737 pRssiLog->rssi = psessionEntry->rssi;
4738 }
4739 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4740#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 switch (psessionEntry->limMlmState)
4743 {
4744 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
4745 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
4746 /**
4747 * Requesting STA did not receive next auth frame
4748 * before Auth Failure timeout.
4749 * Issue MLM auth confirm with timeout reason code
4750 */
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08004751 //Restore default failure timeout
4752 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
4753 {
4754 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
4755 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
4756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 limRestoreFromAuthState(pMac,eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
4758 break;
4759
4760 default:
4761 /**
4762 * Auth failure timer should not have timed out
4763 * in states other than wt_auth_frame2/4
4764 * Log error.
4765 */
Sushant Kaushik1b645382014-10-13 16:39:36 +05304766 PELOGE(limLog(pMac, LOGE, FL("received unexpected AUTH failure timeout in state %d"), psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
4768
4769 break;
4770 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304771 /* Reinit scan results to remove the unreachable BSS */
4772 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004773} /*** limProcessAuthFailureTimeout() ***/
4774
4775
4776
4777/**
4778 * limProcessAuthRspTimeout()
4779 *
4780 *FUNCTION:
4781 * This function is called to process Min Channel Timeout
4782 * during channel scan.
4783 *
4784 *LOGIC:
4785 *
4786 *ASSUMPTIONS:
4787 *
4788 *NOTE:
4789 *
4790 * @param pMac Pointer to Global MAC structure
4791 * @return None
4792 */
4793
4794static void
4795limProcessAuthRspTimeout(tpAniSirGlobal pMac, tANI_U32 authIndex)
4796{
4797 struct tLimPreAuthNode *pAuthNode;
4798 tpPESession psessionEntry;
4799 tANI_U8 sessionId;
4800
4801 pAuthNode = limGetPreAuthNodeFromIndex(pMac, &pMac->lim.gLimPreAuthTimerTable, authIndex);
4802
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304803 if (NULL == pAuthNode)
4804 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004805 limLog(pMac, LOGW, FL("Invalid auth node"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304806 return;
4807 }
4808
4809 if ((psessionEntry = peFindSessionByBssid(pMac, pAuthNode->peerMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004811 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 return;
4813 }
4814
4815 if (psessionEntry->limSystemRole == eLIM_AP_ROLE ||
4816 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
4817 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304818 if (pAuthNode->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 {
4820 /**
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304821 * Authentication response timer timedout
4822 * in unexpected state. Log error
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 */
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304824 PELOGE(limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304825 FL("received AUTH rsp timeout in unexpected state "
4826 "for MAC address: "MAC_ADDRESS_STR),
4827 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 }
4829 else
4830 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304831 // Authentication response timer
4832 // timedout for an STA.
4833 pAuthNode->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
4834 pAuthNode->fTimerStarted = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304835 limLog(pMac, LOG1,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304836 FL("AUTH rsp timedout for MAC address "MAC_ADDRESS_STR),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304837 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004838
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304839 // Change timer to reactivate it in future
4840 limDeactivateAndChangePerStaIdTimer(pMac,
4841 eLIM_AUTH_RSP_TIMER,
4842 pAuthNode->authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004843
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304844 limDeletePreAuthNode(pMac, pAuthNode->peerMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846 }
4847} /*** limProcessAuthRspTimeout() ***/
4848
4849
4850/**
4851 * limProcessAssocFailureTimeout()
4852 *
4853 *FUNCTION:
4854 * This function is called to process Min Channel Timeout
4855 * during channel scan.
4856 *
4857 *LOGIC:
4858 *
4859 *ASSUMPTIONS:
4860 *
4861 *NOTE:
4862 *
4863 * @param pMac Pointer to Global MAC structure
4864 * @return None
4865 */
4866
4867static void
4868limProcessAssocFailureTimeout(tpAniSirGlobal pMac, tANI_U32 MsgType)
4869{
4870
4871 tLimMlmAssocCnf mlmAssocCnf;
4872 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004873#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4874 vos_log_rssi_pkt_type *pRssiLog = NULL;
4875#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004876
4877 //to fetch the lim/mlm state based on the sessionId, use the below sessionEntry
4878 tANI_U8 sessionId;
4879
4880 if(MsgType == LIM_ASSOC)
4881 {
4882 sessionId = pMac->lim.limTimers.gLimAssocFailureTimer.sessionId;
4883 }
4884 else
4885 {
4886 sessionId = pMac->lim.limTimers.gLimReassocFailureTimer.sessionId;
4887 }
4888
4889 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
4890 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004891 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 return;
4893 }
krunal soni8d13b092013-07-19 13:23:29 -07004894#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4895 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4896 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4897 if (pRssiLog)
4898 {
4899 pRssiLog->rssi = psessionEntry->rssi;
4900 }
4901 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4902#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4903
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 /**
4905 * Expected Re/Association Response frame
4906 * not received within Re/Association Failure Timeout.
4907 */
4908
4909
4910
4911
Abhishek Singh70af9c72016-03-09 17:23:30 +05304912 /*
4913 * CR: vos packet memory is leaked when assoc rsp timeouted/failed.
4914 * notify TL that association is failed so that TL can flush the
4915 * cached frame
4916 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 WLANTL_AssocFailed (psessionEntry->staId);
4918
Abhishek Singh70af9c72016-03-09 17:23:30 +05304919 /* Log error */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304920 limLog(pMac, LOG1,
4921 FL("Re/Association Response not received before timeout "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
Abhishek Singh70af9c72016-03-09 17:23:30 +05304923 /*
4924 * Send Deauth to handle the scenareo where association timeout happened
4925 * when device has missed the assoc resp sent by peer.
4926 * By sending deauth try to clear the session created on peer device.
4927 */
4928 limLog(pMac, LOGE,
4929 FL("Sessionid: %d try sending Send deauth on channel %d to BSSID: "
4930 MAC_ADDRESS_STR ), psessionEntry->peSessionId,
4931 psessionEntry->currentOperChannel,
4932 MAC_ADDR_ARRAY(psessionEntry->bssId));
4933
4934 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
4935 psessionEntry->bssId,
4936 psessionEntry, FALSE);
4937
4938 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4939 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )||
4940 ((psessionEntry->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
4941 (psessionEntry->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 (psessionEntry->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4943 {
4944 /**
4945 * Re/Assoc failure timer should not have timedout on AP
4946 * or in a state other than wt_re/assoc_response.
4947 */
4948
4949 // Log error
4950 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304951 FL("received unexpected REASSOC failure timeout in state %d for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 psessionEntry->limMlmState, psessionEntry->limSystemRole);
4953 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4954 }
4955 else
4956 {
4957
4958 if ((MsgType == LIM_ASSOC) ||
4959 ((MsgType == LIM_REASSOC) && (psessionEntry->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4960 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004961 PELOGE(limLog(pMac, LOGE, FL("(Re)Assoc Failure Timeout occurred."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004962
4963 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004964 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 // 'Change' timer for future activations
4967 limDeactivateAndChangeTimer(pMac, eLIM_ASSOC_FAIL_TIMER);
4968
4969 // Free up buffer allocated for JoinReq held by
4970 // MLM state machine
4971 if (psessionEntry->pLimMlmJoinReq)
4972 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304973 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 psessionEntry->pLimMlmJoinReq = NULL;
4975 }
4976
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 //To remove the preauth node in case of fail to associate
4978 if (limSearchPreAuthList(pMac, psessionEntry->bssId))
4979 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304980 limLog(pMac, LOG1, FL(" delete pre auth node for "
4981 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 limDeletePreAuthNode(pMac, psessionEntry->bssId);
4983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004984
4985 mlmAssocCnf.resultCode =
4986 eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
4987 mlmAssocCnf.protStatusCode =
4988 eSIR_MAC_UNSPEC_FAILURE_STATUS;
4989
4990 /* Update PE session Id*/
4991 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
4992 if (MsgType == LIM_ASSOC)
4993 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4994 else
4995 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004996 /* Will come here only in case of 11r, ESE, FT when reassoc rsp
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 is not received and we receive a reassoc - timesout */
4998 mlmAssocCnf.resultCode = eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
4999 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
5000 }
5001 }
5002 else
5003 {
5004 /**
5005 * Restore pre-reassoc req state.
5006 * Set BSSID to currently associated AP address.
5007 */
5008 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07005009 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005010
5011 limRestorePreReassocState(pMac,
5012 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry);
5013 }
5014 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05305015 /* Reinit scan results to remove the unreachable BSS */
5016 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005017} /*** limProcessAssocFailureTimeout() ***/
5018
5019
5020
5021/**
5022 * limCompleteMlmScan()
5023 *
5024 *FUNCTION:
5025 * This function is called to send MLM_SCAN_CNF message
5026 * to SME state machine.
5027 *
5028 *LOGIC:
5029 *
5030 *ASSUMPTIONS:
5031 *
5032 *NOTE:
5033 *
5034 * @param pMac Pointer to Global MAC structure
5035 * @param retCode Result code to be sent
5036 * @return None
5037 */
5038
5039void
5040limCompleteMlmScan(tpAniSirGlobal pMac, tSirResultCodes retCode)
5041{
5042 tLimMlmScanCnf mlmScanCnf;
5043
5044 /// Restore previous MLM state
5045 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07005046 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 limRestorePreScanState(pMac);
5048
5049 // Free up pMac->lim.gLimMlmScanReq
5050 if( NULL != pMac->lim.gpLimMlmScanReq )
5051 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305052 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 pMac->lim.gpLimMlmScanReq = NULL;
5054 }
5055
5056 mlmScanCnf.resultCode = retCode;
5057 mlmScanCnf.scanResultLength = pMac->lim.gLimMlmScanResultLength;
5058
5059 limPostSmeMessage(pMac, LIM_MLM_SCAN_CNF, (tANI_U32 *) &mlmScanCnf);
5060
5061} /*** limCompleteMlmScan() ***/
5062
5063/**
5064 * \brief Setup an A-MPDU/BA session
5065 *
5066 * \sa limProcessMlmAddBAReq
5067 *
5068 * \param pMac The global tpAniSirGlobal object
5069 *
5070 * \param pMsgBuf The MLME ADDBA Req message buffer
5071 *
5072 * \return none
5073 */
5074void limProcessMlmAddBAReq( tpAniSirGlobal pMac,
5075 tANI_U32 *pMsgBuf )
5076{
5077tSirRetStatus status = eSIR_SUCCESS;
5078tpLimMlmAddBAReq pMlmAddBAReq;
5079tpLimMlmAddBACnf pMlmAddBACnf;
5080 tpPESession psessionEntry;
5081
5082 if(pMsgBuf == NULL)
5083 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005084 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 return;
5086 }
5087
5088 pMlmAddBAReq = (tpLimMlmAddBAReq) pMsgBuf;
5089 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBAReq->sessionId))== NULL)
5090 {
5091 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005092 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305093 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 return;
5095 }
5096
5097
5098 // Send ADDBA Req over the air
5099 status = limSendAddBAReq( pMac, pMlmAddBAReq,psessionEntry);
5100
5101 //
5102 // Respond immediately to LIM, only if MLME has not been
5103 // successfully able to send WDA_ADDBA_REQ to HAL.
5104 // Else, LIM_MLM_ADDBA_CNF will be sent after receiving
5105 // ADDBA Rsp from peer entity
5106 //
5107 if( eSIR_SUCCESS != status )
5108 {
5109 // Allocate for LIM_MLM_ADDBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305110
5111 pMlmAddBACnf = vos_mem_malloc(sizeof( tLimMlmAddBACnf ));
5112 if ( NULL == pMlmAddBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 {
5114 limLog( pMac, LOGP,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005115 FL("AllocateMemory failed"));
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305116 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 return;
5118 }
5119 else
5120 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305121 vos_mem_set((void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ), 0);
5122 vos_mem_copy((void *) pMlmAddBACnf->peerMacAddr,
5123 (void *) pMlmAddBAReq->peerMacAddr,
5124 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005125
5126 pMlmAddBACnf->baDialogToken = pMlmAddBAReq->baDialogToken;
5127 pMlmAddBACnf->baTID = pMlmAddBAReq->baTID;
5128 pMlmAddBACnf->baPolicy = pMlmAddBAReq->baPolicy;
5129 pMlmAddBACnf->baBufferSize = pMlmAddBAReq->baBufferSize;
5130 pMlmAddBACnf->baTimeout = pMlmAddBAReq->baTimeout;
5131 pMlmAddBACnf->sessionId = pMlmAddBAReq->sessionId;
5132
5133 // Update the result code
5134 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
5135
5136 limPostSmeMessage( pMac,
5137 LIM_MLM_ADDBA_CNF,
5138 (tANI_U32 *) pMlmAddBACnf );
5139 }
5140
5141 // Restore MLME state
5142 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07005143 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005144
5145 }
5146
5147 // Free the buffer allocated for tLimMlmAddBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305148 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005149
5150}
5151
5152/**
5153 * \brief Send an ADDBA Rsp to peer STA in response
5154 * to an ADDBA Req received earlier
5155 *
5156 * \sa limProcessMlmAddBARsp
5157 *
5158 * \param pMac The global tpAniSirGlobal object
5159 *
5160 * \param pMsgBuf The MLME ADDBA Rsp message buffer
5161 *
5162 * \return none
5163 */
5164void limProcessMlmAddBARsp( tpAniSirGlobal pMac,
5165 tANI_U32 *pMsgBuf )
5166{
5167tpLimMlmAddBARsp pMlmAddBARsp;
5168 tANI_U16 aid;
5169 tpDphHashNode pSta;
5170 tpPESession psessionEntry;
5171
5172
5173 if(pMsgBuf == NULL)
5174 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005175 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 return;
5177 }
5178
5179 pMlmAddBARsp = (tpLimMlmAddBARsp) pMsgBuf;
5180
5181 if(( psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBARsp->sessionId))== NULL)
5182 {
5183 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005184 FL("session does not exist for given session ID"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305185 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return;
5187 }
5188
5189
5190 // Send ADDBA Rsp over the air
5191 if( eSIR_SUCCESS != limSendAddBARsp( pMac,pMlmAddBARsp,psessionEntry))
5192 {
5193 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005194 FL("Failed to send ADDBA Rsp to peer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGE );
5196 /* Clean the BA context maintained by HAL and TL on failure */
5197 pSta = dphLookupHashEntry( pMac, pMlmAddBARsp->peerMacAddr, &aid,
5198 &psessionEntry->dph.dphHashTable);
5199 if( NULL != pSta )
5200 {
5201 limPostMsgDelBAInd( pMac, pSta, pMlmAddBARsp->baTID, eBA_RECIPIENT,
5202 psessionEntry);
5203 }
5204 }
5205
5206 // Time to post a WDA_DELBA_IND to HAL in order
5207 // to cleanup the HAL and SoftMAC entries
5208
5209
5210 // Free the buffer allocated for tLimMlmAddBARsp
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305211 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005212
5213}
5214
5215/**
5216 * \brief Setup an A-MPDU/BA session
5217 *
5218 * \sa limProcessMlmDelBAReq
5219 *
5220 * \param pMac The global tpAniSirGlobal object
5221 *
5222 * \param pMsgBuf The MLME DELBA Req message buffer
5223 *
5224 * \return none
5225 */
5226void limProcessMlmDelBAReq( tpAniSirGlobal pMac,
5227 tANI_U32 *pMsgBuf )
5228{
5229 tSirRetStatus status = eSIR_SUCCESS;
5230 tpLimMlmDelBAReq pMlmDelBAReq;
5231 tpLimMlmDelBACnf pMlmDelBACnf;
5232 tpPESession psessionEntry;
5233
5234
5235 if(pMsgBuf == NULL)
5236 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005237 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 return;
5239 }
5240
5241 // TODO - Need to validate MLME state
5242 pMlmDelBAReq = (tpLimMlmDelBAReq) pMsgBuf;
5243
5244 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDelBAReq->sessionId))== NULL)
5245 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005246 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305247 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 return;
5249 }
5250
5251 // Send DELBA Ind over the air
5252 if( eSIR_SUCCESS !=
5253 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
5254 status = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
5255 else
5256 {
5257 tANI_U16 aid;
5258 tpDphHashNode pSta;
5259
5260 // Time to post a WDA_DELBA_IND to HAL in order
5261 // to cleanup the HAL and SoftMAC entries
5262 pSta = dphLookupHashEntry( pMac, pMlmDelBAReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
5263 if( NULL != pSta )
5264 {
5265 status = limPostMsgDelBAInd( pMac,
5266 pSta,
5267 pMlmDelBAReq->baTID,
5268 pMlmDelBAReq->baDirection,psessionEntry);
5269
5270 }
5271 }
5272
5273 //
5274 // Respond immediately to SME with DELBA CNF using
5275 // LIM_MLM_DELBA_CNF with appropriate status
5276 //
5277
5278 // Allocate for LIM_MLM_DELBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305279
5280 pMlmDelBACnf = vos_mem_malloc(sizeof( tLimMlmDelBACnf ));
5281 if ( NULL == pMlmDelBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305283 limLog( pMac, LOGP, FL("AllocateMemory failed"));
5284 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 return;
5286 }
5287 else
5288 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305289 vos_mem_set((void *) pMlmDelBACnf, sizeof( tLimMlmDelBACnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005290
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305291 vos_mem_copy((void *) pMlmDelBACnf,
5292 (void *) pMlmDelBAReq,
5293 sizeof( tLimMlmDelBAReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005294
5295 // Update DELBA result code
5296 pMlmDelBACnf->delBAReasonCode = pMlmDelBAReq->delBAReasonCode;
5297
5298 /* Update PE session Id*/
5299 pMlmDelBACnf->sessionId = pMlmDelBAReq->sessionId;
5300
5301 limPostSmeMessage( pMac,
5302 LIM_MLM_DELBA_CNF,
5303 (tANI_U32 *) pMlmDelBACnf );
5304 }
5305
5306 // Free the buffer allocated for tLimMlmDelBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305307 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005308
5309}
5310
5311/**
5312 * @function : limSMPowerSaveStateInd( )
5313 *
5314 * @brief : This function is called upon receiving the PMC Indication to update the STA's MimoPs State.
5315 *
5316 * LOGIC:
5317 *
5318 * ASSUMPTIONS:
5319 * NA
5320 *
5321 * NOTE:
5322 * NA
5323 *
5324 * @param pMac - Pointer to Global MAC structure
5325 * @param limMsg - Lim Message structure object with the MimoPSparam in body
5326 * @return None
5327 */
5328
5329tSirRetStatus
5330limSMPowerSaveStateInd(tpAniSirGlobal pMac, tSirMacHTMIMOPowerSaveState state)
5331{
5332#if 0
5333 tSirRetStatus retStatus = eSIR_SUCCESS;
5334#if 0
5335 tANI_U32 cfgVal1;
5336 tANI_U16 cfgVal2;
5337 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
5338 tpDphHashNode pSta = NULL;
5339
5340 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5341 /** Verify the Mode of operation */
5342 if (pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005343 PELOGE(limLog(pMac, LOGE, FL("Got PMC indication when System not in the STA Role"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 return eSIR_FAILURE;
5345 }
5346
5347 if ((pMac->lim.gHTMIMOPSState == state) || (state == eSIR_HT_MIMO_PS_NA )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005348 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 -07005349 return eSIR_FAILURE;
5350 }
5351
5352 if (!pMac->lim.htCapability){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005353 PELOGW(limLog(pMac, LOGW, FL(" Not in 11n or HT capable mode"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 return eSIR_FAILURE;
5355 }
5356
5357 /** Update the CFG about the default MimoPS State */
5358 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &cfgVal1) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005359 limLog(pMac, LOGP, FL("could not retrieve HT Cap CFG "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 return eSIR_FAILURE;
5361 }
5362
5363 cfgVal2 = (tANI_U16)cfgVal1;
5364 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &cfgVal2;
5365 pHTCapabilityInfo->mimoPowerSave = state;
5366
5367 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005368 limLog(pMac, LOGP, FL("could not update HT Cap Info CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 return eSIR_FAILURE;
5370 }
5371
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005372 PELOG2(limLog(pMac, LOG2, FL(" The HT Capability for Mimo Pwr is updated to State: %u "),state);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005374 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 -07005375 /** Update in the LIM the MIMO PS state of the SELF */
5376 pMac->lim.gHTMIMOPSState = state;
5377 return eSIR_SUCCESS;
5378 }
5379
5380 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5381 if (!pSta->mlmStaContext.htCapability) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005382 limLog( pMac, LOGE,FL( "limSendSMPowerState: Peer is not HT Capable " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 return eSIR_FAILURE;
5384 }
5385
5386 if (isEnteringMimoPS(pMac->lim.gHTMIMOPSState, state)) {
5387 tSirMacAddr macAddr;
5388 /** Obtain the AP's Mac Address */
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305389 vos_mem_copy((tANI_U8 *)macAddr, psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 /** Send Action Frame with the corresponding mode */
5391 retStatus = limSendSMPowerStateFrame(pMac, macAddr, state);
5392 if (retStatus != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005393 PELOGE(limLog(pMac, LOGE, "Update SM POWER: Sending Action Frame has failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 return retStatus;
5395 }
5396 }
5397
5398 /** Update MlmState about the SetMimoPS State */
5399 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
5400 pMac->lim.gLimMlmState = eLIM_MLM_WT_SET_MIMOPS_STATE;
5401 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
5402
5403 /** Update the HAL and s/w mac about the mode to be set */
5404 retStatus = limPostSMStateUpdate( pMac,psessionEntry->staId, state);
5405
5406 PELOG2(limLog(pMac, LOG2, " Updated the New SMPS State");)
5407 /** Update in the LIM the MIMO PS state of the SELF */
5408 pMac->lim.gHTMIMOPSState = state;
5409#endif
5410 return retStatus;
5411#endif
5412return eSIR_SUCCESS;
5413}
5414
Jeff Johnsone7245742012-09-05 17:12:55 -07005415#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005416ePhyChanBondState limGet11ACPhyCBState(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 htSecondaryChannelOffset,tANI_U8 peerCenterChan, tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07005417{
5418 ePhyChanBondState cbState = PHY_SINGLE_CHANNEL_CENTERED;
5419
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005420 if(!psessionEntry->apChanWidth)
Jeff Johnsone7245742012-09-05 17:12:55 -07005421 {
5422 return htSecondaryChannelOffset;
5423 }
5424
5425 if ( (htSecondaryChannelOffset
5426 == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
5427 )
5428 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005429 if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005430 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005431 else if ((channel + 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005432 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005433 else if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005434 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
5435 else
5436 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005437 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005438 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005439 }
5440 if ( (htSecondaryChannelOffset
5441 == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
5442 )
5443 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005444 if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005445 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005446 else if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005447 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005448 else if ((channel - 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005449 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
5450 else
5451 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005452 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005453 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005454 }
5455 return cbState;
5456}
5457
5458#endif
5459
Jeff Johnson295189b2012-06-20 16:38:30 -07005460void
Jeff Johnsone7245742012-09-05 17:12:55 -07005461limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005462{
5463#if !defined WLAN_FEATURE_VOWIFI
5464 tANI_U32 localPwrConstraint;
5465#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005466 tpPESession peSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07005467
Jeff Johnsone7245742012-09-05 17:12:55 -07005468 peSession = peFindSessionBySessionId (pMac, peSessionId);
5469
5470 if ( NULL == peSession)
5471 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005472 limLog (pMac, LOGP, FL("Invalid PE session = %d"), peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005473 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005475#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07005476#ifdef WLAN_FEATURE_11AC
5477 if ( peSession->vhtCapability )
5478 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005479 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005480 }
5481 else
5482#endif
5483 {
5484 limSendSwitchChnlParams( pMac, channel, secChannelOffset, maxTxPower, peSessionId);
5485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005486#else
5487 if (wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005488 limLog(pMac, LOGP, FL("could not read WNI_CFG_LOCAL_POWER_CONSTRAINT from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 return;
5490 }
5491 // Send WDA_CHNL_SWITCH_IND to HAL
Jeff Johnsone7245742012-09-05 17:12:55 -07005492#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005493 if ( peSession->vhtCapability && peSession->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07005494 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005495 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005496 }
5497 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005498#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005499 {
5500 limSendSwitchChnlParams( pMac, channel, secChannelOffset, (tPowerdBm)localPwrConstraint, peSessionId);
5501 }
5502#endif
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 }