blob: a8a4fd9450b0deb4c3beaa4b3b1ea26c8876093a [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
103/**
104 * limProcessMlmReqMessages()
105 *
106 *FUNCTION:
107 * This function is called by limPostMlmMessage(). This
108 * function handles MLM primitives invoked by SME.
109 *
110 *LOGIC:
111 * Depending on the message type, corresponding function will be
112 * called.
113 *
114 *ASSUMPTIONS:
115 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
116 * APIs exposed by Beacon Processing module for setting parameters
117 * at MAC hardware.
118 * 2. If attempt to Reassociate with an AP fails, link with current
119 * AP is restored back.
120 *
121 *NOTE:
122 *
123 * @param pMac Pointer to Global MAC structure
124 * @param msgType Indicates the MLM primitive message type
125 * @param *pMsgBuf A pointer to the MLM message buffer
126 *
127 * @return None
128 */
129
130void
131limProcessMlmReqMessages(tpAniSirGlobal pMac, tpSirMsgQ Msg)
132{
133 switch (Msg->type)
134 {
135 case LIM_MLM_START_REQ: limProcessMlmStartReq(pMac, Msg->bodyptr); break;
136 case LIM_MLM_SCAN_REQ: limProcessMlmScanReq(pMac, Msg->bodyptr); break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700137#ifdef FEATURE_OEM_DATA_SUPPORT
138 case LIM_MLM_OEM_DATA_REQ: limProcessMlmOemDataReq(pMac, Msg->bodyptr); break;
139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 case LIM_MLM_JOIN_REQ: limProcessMlmJoinReq(pMac, Msg->bodyptr); break;
141 case LIM_MLM_AUTH_REQ: limProcessMlmAuthReq(pMac, Msg->bodyptr); break;
142 case LIM_MLM_ASSOC_REQ: limProcessMlmAssocReq(pMac, Msg->bodyptr); break;
143 case LIM_MLM_REASSOC_REQ: limProcessMlmReassocReq(pMac, Msg->bodyptr); break;
144 case LIM_MLM_DISASSOC_REQ: limProcessMlmDisassocReq(pMac, Msg->bodyptr); break;
145 case LIM_MLM_DEAUTH_REQ: limProcessMlmDeauthReq(pMac, Msg->bodyptr); break;
146 case LIM_MLM_SETKEYS_REQ: limProcessMlmSetKeysReq(pMac, Msg->bodyptr); break;
147 case LIM_MLM_REMOVEKEY_REQ: limProcessMlmRemoveKeyReq(pMac, Msg->bodyptr); break;
148 case SIR_LIM_MIN_CHANNEL_TIMEOUT: limProcessMinChannelTimeout(pMac); break;
149 case SIR_LIM_MAX_CHANNEL_TIMEOUT: limProcessMaxChannelTimeout(pMac); break;
150 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
151 limProcessPeriodicProbeReqTimer(pMac); break;
152 case SIR_LIM_JOIN_FAIL_TIMEOUT: limProcessJoinFailureTimeout(pMac); break;
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800153 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
154 limProcessPeriodicJoinProbeReqTimer(pMac); break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 case SIR_LIM_AUTH_FAIL_TIMEOUT: limProcessAuthFailureTimeout(pMac); break;
156 case SIR_LIM_AUTH_RSP_TIMEOUT: limProcessAuthRspTimeout(pMac, Msg->bodyval); break;
157 case SIR_LIM_ASSOC_FAIL_TIMEOUT: limProcessAssocFailureTimeout(pMac, Msg->bodyval); break;
158#ifdef WLAN_FEATURE_VOWIFI_11R
159 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:limProcessFTPreauthRspTimeout(pMac); break;
160#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530161#ifdef WLAN_FEATURE_LFR_MBB
162 case SIR_LIM_PREAUTH_MBB_RSP_TIMEOUT:
163 lim_process_preauth_mbb_rsp_timeout(pMac);
164 break;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530165 case SIR_LIM_REASSOC_MBB_RSP_TIMEOUT:
166 lim_process_reassoc_mbb_rsp_timeout(pMac);
167 break;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case SIR_LIM_REMAIN_CHN_TIMEOUT: limProcessRemainOnChnTimeout(pMac); break;
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800170 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
171 limProcessInsertSingleShotNOATimeout(pMac); break;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530172 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
173 limConvertActiveChannelToPassiveChannel(pMac); break;
Sushant Kaushik9e923872015-04-02 17:09:31 +0530174 case SIR_LIM_AUTH_RETRY_TIMEOUT:
175 limProcessAuthRetryTimer(pMac);
176 break;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800177 case SIR_LIM_DISASSOC_ACK_TIMEOUT: limProcessDisassocAckTimeout(pMac); break;
178 case SIR_LIM_DEAUTH_ACK_TIMEOUT: limProcessDeauthAckTimeout(pMac); break;
Abhishek Singh550aa8c2017-10-30 17:34:53 +0530179 case SIR_LIM_SAP_ECSA_TIMEOUT: lim_process_ap_ecsa_timeout(pMac);break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case LIM_MLM_ADDBA_REQ: limProcessMlmAddBAReq( pMac, Msg->bodyptr ); break;
181 case LIM_MLM_ADDBA_RSP: limProcessMlmAddBARsp( pMac, Msg->bodyptr ); break;
182 case LIM_MLM_DELBA_REQ: limProcessMlmDelBAReq( pMac, Msg->bodyptr ); break;
183 case LIM_MLM_TSPEC_REQ:
184 default:
185 break;
186 } // switch (msgType)
187} /*** end limProcessMlmReqMessages() ***/
188
189
190/**
191 * limSetScanMode()
192 *
193 *FUNCTION:
194 * This function is called to setup system into Scan mode
195 *
196 *LOGIC:
197 * NA
198 *
199 *ASSUMPTIONS:
200 * NA
201 *
202 *NOTE:
203 *
204 * @param pMac - Pointer to Global MAC structure
205 * @return None
206 */
207
208void
209limSetScanMode(tpAniSirGlobal pMac)
210{
211 tSirLinkTrafficCheck checkTraffic;
212
213 /// Set current scan channel id to the first in the channel list
214 pMac->lim.gLimCurrentScanChannelId = 0;
215
Jeff Johnson62c27982013-02-27 17:53:55 -0800216 if ( IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) )
217 {
218 checkTraffic = eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
219 }
220 else if (IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac))
221 {
222 checkTraffic = eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
223 }
224 else
225 checkTraffic = eSIR_CHECK_ROAMING_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530227 limLog(pMac, LOG1, FL("Calling limSendHalInitScanReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_SCAN_WAIT_STATE, checkTraffic);
229
230 return ;
231} /*** end limSetScanMode() ***/
232
233//WLAN_SUSPEND_LINK Related
234
235/* limIsLinkSuspended()
236 *
237 *FUNCTION:
238 * This function returns is link is suspended or not.
239 *
240 *LOGIC:
Jeff Johnson62c27982013-02-27 17:53:55 -0800241 * Since Suspend link uses init scan, it just returns
242 * gLimSystemInScanLearnMode flag.
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 *
244 *ASSUMPTIONS:
245 * NA
246 *
247 *NOTE:
248 *
249 * @param pMac - Pointer to Global MAC structure
250 * @return None
251 */
252tANI_U8
253limIsLinkSuspended(tpAniSirGlobal pMac)
254{
255 return pMac->lim.gLimSystemInScanLearnMode;
256}
257/**
258 * limSuspendLink()
259 *
260 *FUNCTION:
261 * This function is called to suspend traffic. Internally this function uses WDA_INIT_SCAN_REQ.
262 *
263 *LOGIC:
264 * NA
265 *
266 *ASSUMPTIONS:
267 * NA
268 *
269 *NOTE:
270 *
271 * @param pMac - Pointer to Global MAC structure
Jeff Johnson62c27982013-02-27 17:53:55 -0800272 * @param trafficCheck - Takes value from enum tSirLinkTrafficCheck.
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 * @param callback - Callback function to be called after suspending the link.
274 * @param data - Pointer to any buffer that will be passed to callback.
275 * @return None
276 */
277void
278limSuspendLink(tpAniSirGlobal pMac, tSirLinkTrafficCheck trafficCheck, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
279{
280 if( NULL == callback )
281 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700282 limLog( pMac, LOGE, "%s:%d: Invalid parameters", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 return;
284 }
285
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530286 if( pMac->lim.gpLimSuspendCallback ||
287 pMac->lim.gLimSystemInScanLearnMode )
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 {
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700289 limLog( pMac, LOGE, FL("Something is wrong, SuspendLinkCbk:%pK "
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +0530290 "IsSystemInScanLearnMode:%d"), pMac->lim.gpLimSuspendCallback,
291 pMac->lim.gLimSystemInScanLearnMode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 callback( pMac, eHAL_STATUS_FAILURE, data );
293 return;
294 }
295
296 pMac->lim.gLimSystemInScanLearnMode = 1;
297 pMac->lim.gpLimSuspendCallback = callback;
298 pMac->lim.gpLimSuspendData = data;
299 limSendHalInitScanReq(pMac, eLIM_HAL_SUSPEND_LINK_WAIT_STATE, trafficCheck );
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800300
301 WDA_TrafficStatsTimerActivate(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302}
303
304/**
305 * limResumeLink()
306 *
307 *FUNCTION:
308 * This function is called to Resume traffic after a suspend. Internally this function uses WDA_FINISH_SCAN_REQ.
309 *
310 *LOGIC:
311 * NA
312 *
313 *ASSUMPTIONS:
314 * NA
315 *
316 *NOTE:
317 *
318 * @param pMac - Pointer to Global MAC structure
319 * @param callback - Callback function to be called after Resuming the link.
320 * @param data - Pointer to any buffer that will be passed to callback.
321 * @return None
322 */
323void
324limResumeLink(tpAniSirGlobal pMac, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
325{
326 if( NULL == callback )
327 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700328 limLog( pMac, LOGE, "%s:%d: Invalid parameters", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return;
330 }
331
332 if( pMac->lim.gpLimResumeCallback )
333 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700334 limLog( pMac, LOGE, "%s:%d: gLimResumeLink callback is not NULL...something is wrong", __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 callback( pMac, eHAL_STATUS_FAILURE, data );
336 return;
337 }
338
339 pMac->lim.gpLimResumeCallback = callback;
340 pMac->lim.gpLimResumeData = data;
Abhishek Singh53bfb332013-12-12 18:03:29 +0530341
342 /* eLIM_HAL_IDLE_SCAN_STATE state indicate limSendHalInitScanReq failed.
343 * In case limSendHalInitScanReq is success, Scanstate would be
344 * eLIM_HAL_SUSPEND_LINK_STATE
345 */
346 if( eLIM_HAL_IDLE_SCAN_STATE != pMac->lim.gLimHalScanState )
347 {
348 limSendHalFinishScanReq(pMac, eLIM_HAL_RESUME_LINK_WAIT_STATE );
349 }
350 else
351 {
352 limLog(pMac, LOGW, FL("Init Scan failed, we will not call finish scan."
353 " calling the callback with failure status"));
354 pMac->lim.gpLimResumeCallback( pMac, eSIR_FAILURE, pMac->lim.gpLimResumeData);
355 pMac->lim.gpLimResumeCallback = NULL;
356 pMac->lim.gpLimResumeData = NULL;
357 pMac->lim.gLimSystemInScanLearnMode = 0;
358 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800359
360 if(limIsInMCC(pMac))
361 {
362 WDA_TrafficStatsTimerActivate(TRUE);
363 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700364}
365//end WLAN_SUSPEND_LINK Related
366
367
368/**
369 *
370 * limChangeChannelWithCallback()
371 *
372 * FUNCTION:
373 * This function is called to change channel and perform off channel operation
374 * if required. The caller registers a callback to be called at the end of the
Jeff Johnson62c27982013-02-27 17:53:55 -0800375 * channel change.
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 *
377 */
378void
379limChangeChannelWithCallback(tpAniSirGlobal pMac, tANI_U8 newChannel,
380 CHANGE_CHANNEL_CALLBACK callback,
381 tANI_U32 *cbdata, tpPESession psessionEntry)
382{
383 // Sanity checks for the current and new channel
384#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700385 PELOGE(limLog( pMac, LOGE, "Switching channel to %d", newChannel);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700386#endif
387 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
388
389 pMac->lim.gpchangeChannelCallback = callback;
390 pMac->lim.gpchangeChannelData = cbdata;
391
392 limSendSwitchChnlParams(pMac, newChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -0700393 PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 psessionEntry->maxTxPower, psessionEntry->peSessionId);
395
396 return;
397}
398
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530399/**
400 * lim_is_spoofing_needed() - Check whether spoofing is needed for scan
401 * @mac: Pointer to mac
402 *
403 * Return: If spoofing is needed then return true else false.
404 */
405static bool lim_is_spoofing_needed(tpAniSirGlobal mac)
406{
407 /*
408 * If mac spoofing response from firmware is not enabled
409 * then disable spoofing.
410 */
411 if (!mac->lim.isSpoofingEnabled)
412 return false;
413
414 /*
415 * If all the octets of spoof mac-address are zero
416 * then disable spoofing.
417 */
418 if (vos_is_macaddr_zero((v_MACADDR_t *)&mac->lim.spoofMacAddr))
419 return false;
420
421 /*
422 * If disableP2PMacSpoof is enabled and scan is P2P scan
423 * then disable spoofing.
424 */
425 if (mac->roam.configParam.disableP2PMacSpoofing &&
426 mac->lim.gpLimMlmScanReq->p2pSearch)
427 return false;
428
429 /* Randomize NL (cfg80211) scan only when scan_randomize is set */
430 if (mac->lim.gpLimMlmScanReq->nl_scan)
431 return mac->lim.gpLimMlmScanReq->scan_randomize;
432
433 /* Randomize all other scans only when spoof_mac_oui is set */
434 return mac->lim.spoof_mac_oui;
435}
Jeff Johnson295189b2012-06-20 16:38:30 -0700436
437/**
438 * limContinuePostChannelScan()
439 *
440 *FUNCTION:
441 * This function is called to scan the current channel.
442 *
443 *LOGIC:
444 *
445 *ASSUMPTIONS:
446 * NA
447 *
448 *NOTE:
449 * NA
450 *
451 * @param pMac - Pointer to Global MAC structure
452 *
453 * @return None
454 */
455
456void limContinuePostChannelScan(tpAniSirGlobal pMac)
457{
458 tANI_U8 channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 tANI_U8 i = 0;
460 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 if( pMac->lim.abortScan || (NULL == pMac->lim.gpLimMlmScanReq ) ||
463 (pMac->lim.gLimCurrentScanChannelId >
464 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)))
465 {
466 pMac->lim.abortScan = 0;
467 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
468 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
469 //Set the resume channel to Any valid channel (invalid).
470 //This will instruct HAL to set it to any previous valid channel.
471 peSetResumeChannel(pMac, 0, 0);
472
473 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
474 return;
475 }
476
477 channelNum = limGetCurrentScanChannel(pMac);
Agarwal Ashish7fed3812014-04-14 15:17:31 +0530478
479 if (channelNum == limGetCurrentOperatingChannel(pMac) &&
480 limIsconnectedOnDFSChannel(channelNum))
481 {
482 limCovertChannelScanType(pMac, channelNum, true);
483 }
484
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 if ((pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN) &&
486 (limActiveScanAllowed(pMac, channelNum)))
487 {
488 TX_TIMER *periodicScanTimer;
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -0800490 pMac->lim.probeCounter++;
Abhishek Singh795e1b82015-09-25 15:35:03 +0530491 /* Prepare and send Probe Request frame for all
492 * the SSIDs present in the saved MLM
493 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 do
495 {
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530496 tSirMacAddr gSelfMacAddr;
497 bool spoof = lim_is_spoofing_needed(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +0530498
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +0530499 if (spoof)
500 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr,
501 VOS_MAC_ADDRESS_LEN);
502 else
503 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr,
504 VOS_MAC_ADDRESS_LEN);
505
Abhishek Singh525045c2014-12-15 17:18:45 +0530506 limLog(pMac, LOG1,
Agarwal Ashishfb3b1c82015-08-18 16:57:31 +0530507 FL(" Mac Addr "MAC_ADDRESS_STR " used in sending ProbeReq number %d, for SSID %s on channel: %d"),
508 MAC_ADDR_ARRAY(gSelfMacAddr) ,i, pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 // include additional IE if there is
510 status = limSendProbeReqMgmtFrame( pMac, &pMac->lim.gpLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +0530511 pMac->lim.gpLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 pMac->lim.gpLimMlmScanReq->dot11mode,
513 pMac->lim.gpLimMlmScanReq->uIEFieldLen,
514 (tANI_U8 *)(pMac->lim.gpLimMlmScanReq)+pMac->lim.gpLimMlmScanReq->uIEFieldOffset);
515
516 if ( status != eSIR_SUCCESS)
517 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700518 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);)
520 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
521 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
522 return;
523 }
524 i++;
525 } while (i < pMac->lim.gpLimMlmScanReq->numSsid);
526
527 {
528#if defined WLAN_FEATURE_VOWIFI
529 //If minChannelTime is set to zero, SME is requesting scan to not use min channel timer.
530 //This is used in 11k to request for beacon measurement request with a fixed duration in
531 //max channel time.
532 if( pMac->lim.gpLimMlmScanReq->minChannelTime != 0 )
533 {
534#endif
535 /// TXP has sent Probe Request
536 /// Activate minChannelTimer
537 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
538
539#ifdef GEN6_TODO
Abhishek Singh95f7b252015-10-14 14:15:35 +0530540 /* revisit this piece of code to assign the appropriate sessionId
541 * below priority - LOW/might not be needed
542 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 pMac->lim.limTimers.gLimMinChannelTimer.sessionId = sessionId;
Abhishek Singh95f7b252015-10-14 14:15:35 +0530544#endif
545 if (tx_timer_activate(&pMac->lim.limTimers.gLimMinChannelTimer) !=
546 TX_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530548 limLog(pMac, LOGE, FL("could not start min channel timer"));
549 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
550 limSendHalEndScanReq(pMac, channelNum,
551 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 return;
553 }
554
555 // Initialize max timer too
556 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +0530557 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer) !=
558 TX_SUCCESS)
559 {
560 limLog(pMac, LOGE, FL("could not start max channel timer"));
561 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
562 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
563 limSendHalEndScanReq(pMac, channelNum,
564 eLIM_HAL_END_SCAN_WAIT_STATE);
565 return;
566 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700567#if defined WLAN_FEATURE_VOWIFI
568 }
569 else
570 {
571#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700572 PELOGE(limLog( pMac, LOGE, "Min channel time == 0, Use only max chan timer" );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573#endif
574 //No Need to start Min channel timer. Start Max Channel timer.
575 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
576 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
577 == TX_TIMER_ERROR)
578 {
579 /// Could not activate max channel timer.
580 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530581 limLog(pMac,LOGE, FL("could not start max channel timer"));
582 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
583 limSendHalEndScanReq(pMac,
584 channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
585 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 }
587
588 }
589#endif
590 }
591 /* Start peridic timer which will trigger probe req based on min/max
592 channel timer */
593 periodicScanTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
Sachin Ahuja49dedd72014-11-24 16:35:24 +0530594 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 if (tx_timer_activate(periodicScanTimer) != TX_SUCCESS)
596 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530597 limLog(pMac, LOGE, FL("could not start periodic probe req "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700598 "timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 }
600 periodicScanTimer->sessionId = channelNum;
601 }
602 else
603 {
604 tANI_U32 val;
Abhishek Singh525045c2014-12-15 17:18:45 +0530605 limLog(pMac, LOG1, FL("START PASSIVE Scan chan %d"), channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700606
607 /// Passive Scanning. Activate maxChannelTimer
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer)
609 != TX_SUCCESS)
610 {
611 // Could not deactivate max channel timer.
612 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530613 limLog(pMac, LOGE, FL("Unable to deactivate max channel timer"));
614 limSendHalEndScanReq(pMac, channelNum,
615 eLIM_HAL_END_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 }
617 else
618 {
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530619 if (pMac->miracast_mode)
620 {
621 val = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
622 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
623 }
624 else if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 &val) != eSIR_SUCCESS)
626 {
627 /**
628 * Could not get max channel value
629 * from CFG. Log error.
630 */
Abhishek Singh95f7b252015-10-14 14:15:35 +0530631 limLog(pMac, LOGE,
632 FL("could not retrieve passive max chan value, Use Def val"));
633 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 }
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530635
636 val = SYS_MS_TO_TICKS(val);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530637 if (tx_timer_change(&pMac->lim.limTimers.gLimMaxChannelTimer,
638 val, 0) != TX_SUCCESS)
639 {
640 // Could not change max channel timer.
641 // Log error
Abhishek Singh95f7b252015-10-14 14:15:35 +0530642 limLog(pMac, LOGE, FL("Unable to change max channel timer"));
643 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
644 limSendHalEndScanReq(pMac, channelNum,
645 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530646 return;
647 }
Abhishek Singh95f7b252015-10-14 14:15:35 +0530648 else if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
649 != TX_SUCCESS)
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530650 {
Abhishek Singh95f7b252015-10-14 14:15:35 +0530651
652 limLog(pMac, LOGE, FL("could not start max channel timer"));
653 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
654 limSendHalEndScanReq(pMac, channelNum,
655 eLIM_HAL_END_SCAN_WAIT_STATE);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +0530656 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 }
658 }
659 // Wait for Beacons to arrive
660 } // if (pMac->lim.gLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
661
Abhishek Singh95f7b252015-10-14 14:15:35 +0530662 limAddScanChannelInfo(pMac, channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 return;
664}
665
666
667
668
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530669
670/* limCovertChannelScanType()
671 *
672 *FUNCTION:
673 * This function is called to get the list, change the channel type and set again.
674 *
675 *LOGIC:
676 *
677 *ASSUMPTIONS:
678 * NA
679 *
680 *NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
681 * If a channel is PASSIVE, this fucntion will make it as ACTIVE
682 * NA
683 *
684 * @param pMac - Pointer to Global MAC structure
685 * channelNum - Channel which need to be convert
686 PassiveToActive - Boolean flag to convert channel
687 *
688 * @return None
689 */
690
691
692void limCovertChannelScanType(tpAniSirGlobal pMac,tANI_U8 channelNum, tANI_BOOLEAN passiveToActive)
693{
694
695 tANI_U32 i;
696 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
697 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530698
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530699 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
700 != eSIR_SUCCESS)
701 {
702 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list"));)
703 return ;
704 }
705 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
706 {
707 limLog(pMac, LOGE, FL("Invalid scan control list length:%d"), len);
708 return ;
709 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530710 if (pMac->fActiveScanOnDFSChannels)
711 {
712 limLog(pMac, LOG1, FL("DFS feature triggered,"
713 "block scan type conversion"));
714 return ;
715 }
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530716 for (i=0; (i+1) < len; i+=2)
717 {
718 if (channelPair[i] == channelNum)
719 {
720 if ((eSIR_PASSIVE_SCAN == channelPair[i+1]) && TRUE == passiveToActive)
721 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530722 limLog(pMac, LOG1, FL("Channel %d changed from Passive to Active"),
723 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530724 channelPair[i+1] = eSIR_ACTIVE_SCAN;
725 break ;
726 }
727 if ((eSIR_ACTIVE_SCAN == channelPair[i+1]) && FALSE == passiveToActive)
728 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530729 limLog(pMac, LOG1, FL("Channel %d changed from Active to Passive"),
730 channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530731 channelPair[i+1] = eSIR_PASSIVE_SCAN;
732 break ;
733 }
734 }
735 }
736
737 cfgSetStrNotify(pMac, WNI_CFG_SCAN_CONTROL_LIST, (tANI_U8 *)channelPair, len, FALSE);
738 return ;
739}
740
741
742
743
744/* limSetDFSChannelList()
745 *
746 *FUNCTION:
747 * This function is called to convert DFS channel list to active channel list when any
748 * beacon is present on that channel. This function store time for passive channels
749 * which help to know that for how much time channel has been passive.
750 *
751 *LOGIC:
752 *
753 *ASSUMPTIONS:
754 * NA
755 *
756 *NOTE: If a channel is ACTIVE, it won't store any time
757 * If a channel is PAssive, it will store time as timestamp
758 * NA
759 *
760 * @param pMac - Pointer to Global MAC structure
761 * dfsChannelList - DFS channel list.
762 * @return None
763 */
764
765void limSetDFSChannelList(tpAniSirGlobal pMac,tANI_U8 channelNum, tSirDFSChannelList *dfsChannelList)
766{
767
768 tANI_BOOLEAN passiveToActive = TRUE;
Hanumantha Reddy Pothula97ea0952015-10-09 11:29:39 +0530769 tANI_U32 cfgVal;
770
771 if (eSIR_SUCCESS == wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON,
772 &cfgVal))
773 {
774 limLog(pMac, LOG1, FL("WNI_CFG_ACTIVE_PASSIVE_CON: %d"), cfgVal);
775 if (!cfgVal)
776 return;
777 }
778
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530779 if ((1 <= channelNum) && (165 >= channelNum))
780 {
781 if (eANI_BOOLEAN_TRUE == limIsconnectedOnDFSChannel(channelNum))
782 {
783 if (dfsChannelList->timeStamp[channelNum] == 0)
784 {
785 //Received first beacon; Convert DFS channel to Active channel.
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530786 limLog(pMac, LOG1, FL("Received first beacon on DFS channel: %d"), channelNum);
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530787 limCovertChannelScanType(pMac,channelNum, passiveToActive);
788 }
Abhishek Singh6fcdf652016-11-23 10:59:12 +0530789
790 if (!pMac->fActiveScanOnDFSChannels &&
791 dfsChannelList->timeStamp[channelNum] &&
792 !limActiveScanAllowed(pMac, channelNum))
793 limLog(pMac, LOGE,
794 FL("Received beacon on DFS channel %d with dfs time stamp %lu, but channel is still DFS"),
795 channelNum, dfsChannelList->timeStamp[channelNum]);
796
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530797 dfsChannelList->timeStamp[channelNum] = vos_timer_get_system_time();
798 }
799 else
800 {
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530801 return;
802 }
803 if (!tx_timer_running(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer))
804 {
805 tx_timer_activate(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer);
806 }
807 }
808 else
809 {
810 PELOGE(limLog(pMac, LOGE, FL("Invalid Channel: %d"), channelNum);)
811 return;
812 }
813
814 return;
815}
816
Paul Zhang83289792017-02-28 18:58:52 +0800817void limDoSendAuthMgmtFrame(tpAniSirGlobal pMac, tpPESession psessionEntry)
818{
819 tSirMacAuthFrameBody authFrameBody;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530820
Paul Zhang83289792017-02-28 18:58:52 +0800821 //Prepare & send Authentication frame
822 authFrameBody.authAlgoNumber =
823 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
824 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
825 authFrameBody.authStatusCode = 0;
826 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
827 limSendAuthMgmtFrame(pMac,
828 &authFrameBody,
829 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
830 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
831 if (tx_timer_activate(&pMac->lim.limTimers.gLimAuthFailureTimer)
832 != TX_SUCCESS) {
833 //Could not start Auth failure timer.
834 //Log error
835 limLog(pMac, LOGP,
836 FL("could not start Auth failure timer"));
837 //Cleanup as if auth timer expired
838 limProcessAuthFailureTimeout(pMac);
839 } else {
840 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE,
841 psessionEntry->peSessionId, eLIM_AUTH_RETRY_TIMER));
842 //Activate Auth Retry timer
843 if (tx_timer_activate
844 (&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
845 != TX_SUCCESS) {
846 limLog(pMac, LOGP,
847 FL("could not activate Auth Retry timer"));
848 }
849 }
850 return;
851}
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530852
Jeff Johnson295189b2012-06-20 16:38:30 -0700853/*
854* Creates a Raw frame to be sent before every Scan, if required.
855* If only infra link is active (mlmState = Link Estb), then send Data Null
856* If only BT-AMP-AP link is active(mlmState = BSS_STARTED), then send CTS2Self frame.
857* If only BT-AMP-STA link is active(mlmState = BSS_STARTED or Link Est) then send CTS2Self
858* If Only IBSS link is active, then send CTS2Self
859* for concurrent scenario: Infra+BT or Infra+IBSS, always send CTS2Self, no need to send Data Null
860*
861*/
862static void __limCreateInitScanRawFrame(tpAniSirGlobal pMac,
863 tpInitScanParams pInitScanParam)
864{
865 tANI_U8 i;
866 pInitScanParam->scanEntry.activeBSScnt = 0;
867
868 /* Don't send CTS to self as we have issue with BTQM queues where BTQM can
869 * not handle transmition of CTS2self frames. Sending CTS 2 self at this
870 * juncture also doesn't serve much purpose as probe request frames go out
871 * immediately, No need to notify BSS in IBSS case.
872 * */
873
874 for(i =0; i < pMac->lim.maxBssId; i++)
875 {
876 if(pMac->lim.gpSession[i].valid == TRUE)
877 {
878 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
879 {
880 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
881 (pInitScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
882 {
883 pInitScanParam->scanEntry.bssIdx[pInitScanParam->scanEntry.activeBSScnt]
884 = pMac->lim.gpSession[i].bssIdx;
885 pInitScanParam->scanEntry.activeBSScnt++;
886
887 }
888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 else if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
890 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
891 )
892 {
893 pInitScanParam->useNoA = TRUE;
894 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 }
896 }
897 if (pInitScanParam->scanEntry.activeBSScnt)
898 {
899 pInitScanParam->notifyBss = TRUE;
900 pInitScanParam->frameType = SIR_MAC_DATA_FRAME;
901 pInitScanParam->frameLength = 0;
902 }
903}
904
905/*
906* Creates a Raw frame to be sent during finish scan, if required.
907* Send data null frame, only when there is just one session active and that session is
908* in 'link Estb' state.
909* if more than one session is active, don't send any frame.
910* for concurrent scenario: Infra+BT or Infra+IBSS, no need to send Data Null
911*
912*/
913static void __limCreateFinishScanRawFrame(tpAniSirGlobal pMac,
914 tpFinishScanParams pFinishScanParam)
915{
916 tANI_U8 i;
917 pFinishScanParam->scanEntry.activeBSScnt = 0;
918
919 for(i =0; i < pMac->lim.maxBssId; i++)
920 {
921 if(pMac->lim.gpSession[i].valid == TRUE)
922 {
923 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
924 {
925 //BT-STA can either be in LINK-ESTB state or BSS_STARTED State
926 //for BT, need to send CTS2Self
927 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
928 (pFinishScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
929 {
930 pFinishScanParam->scanEntry.bssIdx[pFinishScanParam->scanEntry.activeBSScnt]
931 = pMac->lim.gpSession[i].bssIdx;
932 pFinishScanParam->scanEntry.activeBSScnt++;
933 }
934 }
935 }
936 }
937
938 if (pFinishScanParam->scanEntry.activeBSScnt)
939 {
940 pFinishScanParam->notifyBss = TRUE;
941 pFinishScanParam->frameType = SIR_MAC_DATA_FRAME;
942 pFinishScanParam->frameLength = 0;
943 }
944}
945
946void
947limSendHalInitScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState, tSirLinkTrafficCheck trafficCheck)
948{
949
950
951 tSirMsgQ msg;
952 tpInitScanParams pInitScanParam;
953 tSirRetStatus rc = eSIR_SUCCESS;
954
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530955 pInitScanParam = vos_mem_malloc(sizeof(*pInitScanParam));
956 if ( NULL == pInitScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530958 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 goto error;
960 }
961
962 /*Initialize the pInitScanParam with 0*/
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530963 vos_mem_set((tANI_U8 *)pInitScanParam, sizeof(*pInitScanParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964
965 msg.type = WDA_INIT_SCAN_REQ;
966 msg.bodyptr = pInitScanParam;
967 msg.bodyval = 0;
968
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +0530969 vos_mem_set((tANI_U8 *)&pInitScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 if (nextState == eLIM_HAL_INIT_LEARN_WAIT_STATE)
971 {
972 pInitScanParam->notifyBss = TRUE;
973 pInitScanParam->notifyHost = FALSE;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700974 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
975 {
976 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
977 }
978 else
979 {
980 pInitScanParam->scanMode = eHAL_SYS_MODE_LEARN;
981 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
Jeff Johnsone7245742012-09-05 17:12:55 -0700983 pInitScanParam->frameType = SIR_MAC_CTRL_CTS;
984 __limCreateInitScanRawFrame(pMac, pInitScanParam);
985 pInitScanParam->checkLinkTraffic = trafficCheck;
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 }
987 else
988 {
989 if(nextState == eLIM_HAL_SUSPEND_LINK_WAIT_STATE)
990 {
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700991 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
992 {
993 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SUSPEND_LINK;
994 }
995 else
996 {
997 pInitScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
998 }
999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 }
1001 else
1002 {
Madan Mohan Koyyalamudi94d111d2012-11-19 20:11:26 -08001003 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
1004 {
1005 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
1006 }
1007 else
1008 {
1009 pInitScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 }
1012 __limCreateInitScanRawFrame(pMac, pInitScanParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 if (pInitScanParam->useNoA)
1014 {
1015 pInitScanParam->scanDuration = pMac->lim.gTotalScanDuration;
1016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 /* Inform HAL whether it should check for traffic on the link
1018 * prior to performing a background scan
1019 */
1020 pInitScanParam->checkLinkTraffic = trafficCheck;
1021 }
1022
1023 pMac->lim.gLimHalScanState = nextState;
1024 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001025 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001026
1027 rc = wdaPostCtrlMsg(pMac, &msg);
1028 if (rc == eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001029 PELOG3(limLog(pMac, LOG3, FL("wdaPostCtrlMsg() return eSIR_SUCCESS pMac=%x nextState=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 pMac, pMac->lim.gLimHalScanState);)
1031 return;
1032 }
1033
1034 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301035 vos_mem_free(pInitScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001036 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038error:
1039 switch(nextState)
1040 {
1041 case eLIM_HAL_START_SCAN_WAIT_STATE:
Padma, Santhosh Kumar9a3eea12015-02-18 14:05:03 +05301042 case eLIM_HAL_INIT_SCAN_WAIT_STATE:
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1044 break;
1045
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047 //WLAN_SUSPEND_LINK Related
1048 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
1049 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1050 if( pMac->lim.gpLimSuspendCallback )
1051 {
1052 pMac->lim.gpLimSuspendCallback( pMac, rc, pMac->lim.gpLimSuspendData );
1053 pMac->lim.gpLimSuspendCallback = NULL;
1054 pMac->lim.gpLimSuspendData = NULL;
1055 }
1056 pMac->lim.gLimSystemInScanLearnMode = 0;
1057 break;
1058 //end WLAN_SUSPEND_LINK Related
1059 default:
1060 break;
1061 }
1062 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1063
1064 return ;
1065}
1066
1067void
1068limSendHalStartScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1069{
1070 tSirMsgQ msg;
1071 tpStartScanParams pStartScanParam;
1072 tSirRetStatus rc = eSIR_SUCCESS;
1073
1074 /**
1075 * The Start scan request to be sent only if Start Scan is not already requested
1076 */
1077 if(pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE)
1078 {
1079
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301080 pStartScanParam = vos_mem_malloc(sizeof(*pStartScanParam));
1081 if ( NULL == pStartScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301083 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 goto error;
1085 }
1086
1087 msg.type = WDA_START_SCAN_REQ;
1088 msg.bodyptr = pStartScanParam;
1089 msg.bodyval = 0;
1090 pStartScanParam->status = eHAL_STATUS_SUCCESS;
1091 pStartScanParam->scanChannel = (tANI_U8)channelNum;
1092
1093 pMac->lim.gLimHalScanState = nextState;
1094 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1095
Jeff Johnsone7245742012-09-05 17:12:55 -07001096 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098 rc = wdaPostCtrlMsg(pMac, &msg);
1099 if (rc == eSIR_SUCCESS) {
1100 return;
1101 }
1102
1103 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301104 vos_mem_free(pStartScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001105 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001106
1107error:
1108 switch(nextState)
1109 {
1110 case eLIM_HAL_START_SCAN_WAIT_STATE:
1111 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
1112 break;
1113
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 default:
1116 break;
1117 }
1118 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1119
1120 }
1121 else
1122 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001123 PELOGW(limLog(pMac, LOGW, FL("Invalid state for START_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 }
1125
1126 return;
1127}
1128
1129void limSendHalEndScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
1130{
1131 tSirMsgQ msg;
1132 tpEndScanParams pEndScanParam;
1133 tSirRetStatus rc = eSIR_SUCCESS;
1134
1135 /**
1136 * 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 -07001137 * Start scan is not already requestd.
1138 * after finish scan rsp from firmware host is sending endscan request so adding
1139 * check for IDLE SCAN STATE also added to avoid this issue
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 */
1141 if((pMac->lim.gLimHalScanState != eLIM_HAL_END_SCAN_WAIT_STATE) &&
Leela Venkata Kiran Kumar Reddy Chirala66639a62013-08-29 15:38:19 -07001142 (pMac->lim.gLimHalScanState != eLIM_HAL_IDLE_SCAN_STATE) &&
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07001143 (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE) &&
1144 (pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE) &&
1145 (pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE))
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301146 {
1147 pEndScanParam = vos_mem_malloc(sizeof(*pEndScanParam));
1148 if ( NULL == pEndScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301150 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 goto error;
1152 }
1153
1154 msg.type = WDA_END_SCAN_REQ;
1155 msg.bodyptr = pEndScanParam;
1156 msg.bodyval = 0;
1157 pEndScanParam->status = eHAL_STATUS_SUCCESS;
1158 pEndScanParam->scanChannel = (tANI_U8)channelNum;
1159
1160 pMac->lim.gLimHalScanState = nextState;
1161 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001162 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001163
1164 rc = wdaPostCtrlMsg(pMac, &msg);
1165 if (rc == eSIR_SUCCESS) {
1166 return;
1167 }
1168
1169 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301170 vos_mem_free(pEndScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001171 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
1173 error:
1174 switch(nextState)
1175 {
1176 case eLIM_HAL_END_SCAN_WAIT_STATE:
1177 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_END_FAILED);
1178 break;
1179
Jeff Johnson295189b2012-06-20 16:38:30 -07001180
1181 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001182 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg Rcvd invalid nextState %d"), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 break;
1184 }
1185 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001186 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 }
1188 else
1189 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001190 PELOGW(limLog(pMac, LOGW, FL("Invalid state for END_SCAN_REQ message=%d"), pMac->lim.gLimHalScanState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 }
1192
1193
1194 return;
1195}
1196
Bhargav Shahe3a6ff02016-04-11 16:31:49 +05301197
1198void limSendTLPauseInd(tpAniSirGlobal pMac, uint16_t staId)
1199{
1200 tSirMsgQ msg;
1201 tSirRetStatus rc = eSIR_SUCCESS;
1202
1203 msg.type = WDA_PAUSE_TL_IND;
1204 msg.bodyval = staId;
1205
1206 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1207
1208 rc = wdaPostCtrlMsg(pMac, &msg);
1209 if (rc == eSIR_SUCCESS) {
1210 return;
1211 }
1212
1213 limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);
1214
1215 return;
1216}
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218/**
1219 * limSendHalFinishScanReq()
1220 *
1221 *FUNCTION:
1222 * This function is called to finish scan/learn request..
1223 *
1224 *LOGIC:
1225 *
1226 *ASSUMPTIONS:
1227 * NA
1228 *
1229 *NOTE:
1230 * NA
1231 *
1232 * @param pMac - Pointer to Global MAC structure
1233 * @param nextState - this parameters determines whether this call is for scan or learn
1234 *
1235 * @return None
1236 */
1237void limSendHalFinishScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState)
1238{
1239
1240 tSirMsgQ msg;
1241 tpFinishScanParams pFinishScanParam;
1242 tSirRetStatus rc = eSIR_SUCCESS;
1243
1244 if(pMac->lim.gLimHalScanState == nextState)
1245 {
1246 /*
1247 * PE may receive multiple probe responses, while waiting for HAL to send 'FINISH_SCAN_RSP' message
1248 * PE was sending multiple finish scan req messages to HAL
1249 * this check will avoid that.
1250 * If PE is already waiting for the 'finish_scan_rsp' message from HAL, it will ignore this request.
1251 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001252 PELOGW(limLog(pMac, LOGW, FL("Next Scan State is same as the current state: %d "), nextState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 return;
1254 }
1255
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301256 pFinishScanParam = vos_mem_malloc(sizeof(*pFinishScanParam));
1257 if ( NULL == pFinishScanParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301259 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 goto error;
1261 }
1262
1263 msg.type = WDA_FINISH_SCAN_REQ;
1264 msg.bodyptr = pFinishScanParam;
1265 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001266
1267 peGetResumeChannel(pMac, &pFinishScanParam->currentOperChannel, &pFinishScanParam->cbState);
1268
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301269 vos_mem_set((tANI_U8 *)&pFinishScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001270
1271 if (nextState == eLIM_HAL_FINISH_LEARN_WAIT_STATE)
1272 {
1273 //AP - No pkt need to be transmitted
1274 pFinishScanParam->scanMode = eHAL_SYS_MODE_LEARN;
1275 pFinishScanParam->notifyBss = FALSE;
1276 pFinishScanParam->notifyHost = FALSE;
1277 pFinishScanParam->frameType = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 pFinishScanParam->frameLength = 0;
1280 pMac->lim.gLimHalScanState = nextState;
1281 }
1282 else
1283 {
1284 /* If STA is associated with an AP (ie. STA is in
1285 * LINK_ESTABLISHED state), then STA need to inform
1286 * the AP via either DATA-NULL
1287 */
1288 if (nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE)
1289 {
1290 pFinishScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
1291 }
1292 else
1293 {
1294 pFinishScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1295 }
1296 pFinishScanParam->notifyHost = FALSE;
1297 __limCreateFinishScanRawFrame(pMac, pFinishScanParam);
1298 //WLAN_SUSPEND_LINK Related
1299 pMac->lim.gLimHalScanState = nextState;
1300 //end WLAN_SUSPEND_LINK Related
1301 }
1302
1303 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001304 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306 rc = wdaPostCtrlMsg(pMac, &msg);
1307 if (rc == eSIR_SUCCESS) {
1308 return;
1309 }
1310 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301311 vos_mem_free(pFinishScanParam);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001312 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d"), rc);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001313
1314 error:
1315 if(nextState == eLIM_HAL_FINISH_SCAN_WAIT_STATE)
1316 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_FINISH_FAILED);
1317 //WLAN_SUSPEND_LINK Related
1318 else if ( nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE )
1319 {
1320 if( pMac->lim.gpLimResumeCallback )
1321 {
1322 pMac->lim.gpLimResumeCallback( pMac, rc, pMac->lim.gpLimResumeData );
1323 pMac->lim.gpLimResumeCallback = NULL;
1324 pMac->lim.gpLimResumeData = NULL;
1325 pMac->lim.gLimSystemInScanLearnMode = 0;
1326 }
1327 }
1328 //end WLAN_SUSPEND_LINK Related
1329 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1330 return;
1331}
1332
1333/**
1334 * limContinueChannelScan()
1335 *
1336 *FUNCTION:
1337 * This function is called by limPerformChannelScan().
1338 * This function is called to continue channel scanning when
1339 * Beacon/Probe Response frame are received.
1340 *
1341 *LOGIC:
1342 * Scan criteria stored in pMac->lim.gLimMlmScanReq is used
1343 * to perform channel scan. In this function MLM sub module
1344 * makes channel switch, sends PROBE REQUEST frame in case of
1345 * ACTIVE SCANNING, starts min/max channel timers, programs
1346 * NAV to probeDelay timer and waits for Beacon/Probe Response.
1347 * Once all required channels are scanned, LIM_MLM_SCAN_CNF
1348 * primitive is used to send Scan results to SME sub module.
1349 *
1350 *ASSUMPTIONS:
1351 * 1. In case of Active scanning, start MAX channel time iff
1352 * MIN channel timer expired and activity is observed on
1353 * the channel.
1354 *
1355 *NOTE:
1356 * NA
1357 *
1358 * @param pMac Pointer to Global MAC structure
1359 * @return None
1360 */
1361void
1362limContinueChannelScan(tpAniSirGlobal pMac)
1363{
1364 tANI_U8 channelNum;
1365
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 if (pMac->lim.gLimCurrentScanChannelId >
1367 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)
1368 || pMac->lim.abortScan)
1369 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 pMac->lim.abortScan = 0;
1371 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1372 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1373
1374 //Set the resume channel to Any valid channel (invalid).
1375 //This will instruct HAL to set it to any previous valid channel.
1376 peSetResumeChannel(pMac, 0, 0);
1377
1378 /// Done scanning all required channels
1379 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 return;
1381 }
1382
1383 /// Atleast one more channel is to be scanned
1384
1385 if ((pMac->lim.gLimReturnAfterFirstMatch & 0x40) ||
1386 (pMac->lim.gLimReturnAfterFirstMatch & 0x80))
1387 {
1388 while (pMac->lim.gLimCurrentScanChannelId <=
1389 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1390 {
1391 if (((limGetCurrentScanChannel(pMac) <= 14) &&
1392 pMac->lim.gLim24Band11dScanDone) ||
1393 ((limGetCurrentScanChannel(pMac) > 14) &&
1394 pMac->lim.gLim50Band11dScanDone))
1395 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001396 limLog(pMac, LOGW, FL("skipping chan %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 limGetCurrentScanChannel(pMac));
1398 pMac->lim.gLimCurrentScanChannelId++;
1399 }
1400 else
1401 break;
1402 }
1403
1404 if (pMac->lim.gLimCurrentScanChannelId >
1405 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1406 {
1407 pMac->lim.abortScan = 0;
1408 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1409 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1410 /// Done scanning all required channels
1411 //Set the resume channel to Any valid channel (invalid).
1412 //This will instruct HAL to set it to any previous valid channel.
1413 peSetResumeChannel(pMac, 0, 0);
1414 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
1415 return;
1416 }
1417 }
1418
1419 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh525045c2014-12-15 17:18:45 +05301420 limLog(pMac, LOG1, FL("Current Channel to be scanned is %d"),
1421 channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07001422
1423 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_SCAN_WAIT_STATE);
1424 return;
1425} /*** end limContinueChannelScan() ***/
1426
1427
1428
1429/**
1430 * limRestorePreScanState()
1431 *
1432 *FUNCTION:
1433 * This function is called by limContinueChannelScan()
1434 * to restore HW state prior to entering 'scan state'
1435 *
1436 *LOGIC
1437 *
1438 *ASSUMPTIONS:
1439 *
1440 *NOTE:
1441 * NA
1442 *
1443 * @param pMac Pointer to Global MAC structure
1444 * @return None
1445 */
1446void
1447limRestorePreScanState(tpAniSirGlobal pMac)
1448{
1449 int i;
1450
1451 /// Deactivate MIN/MAX channel timers if running
1452 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1453 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1454
1455 /* Re-activate Heartbeat timers for connected sessions as scan
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001456 * is done if the DUT is in active mode
1457 * AND it is not a ROAMING ("background") scan */
1458 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 (ePMM_STATE_READY == pMac->pmm.gPmmState))
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001460 && (pMac->lim.gLimBackgroundScanMode != eSIR_ROAMING_SCAN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 {
1462 for(i=0;i<pMac->lim.maxBssId;i++)
1463 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001464 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1465 (pMac->lim.gpSession[i].valid == TRUE) &&
Yathish9f22e662012-12-10 14:21:35 -08001466 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState) &&
1467 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 {
1469 limReactivateHeartBeatTimer(pMac, peFindSessionBySessionId(pMac,i));
1470 }
1471 }
1472 }
1473
1474 /**
1475 * clean up message queue.
1476 * If SME messages, redirect to deferred queue.
1477 * The rest will be discarded.
1478 */
1479 //limCleanupMsgQ(pMac);
1480
1481 pMac->lim.gLimSystemInScanLearnMode = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301482 limLog(pMac, LOG1, FL("Scan ended, took %ld tu"),
1483 (tx_time_get() - pMac->lim.scanStartTime));
Jeff Johnson295189b2012-06-20 16:38:30 -07001484} /*** limRestorePreScanState() ***/
1485
Jeff Johnsone7245742012-09-05 17:12:55 -07001486#ifdef FEATURE_OEM_DATA_SUPPORT
1487
1488void limSendHalOemDataReq(tpAniSirGlobal pMac)
1489{
1490 tSirMsgQ msg;
1491 tpStartOemDataReq pStartOemDataReq = NULL;
1492 tSirRetStatus rc = eSIR_SUCCESS;
1493 tpLimMlmOemDataRsp pMlmOemDataRsp;
1494 tANI_U32 reqLen = 0;
1495 if(NULL == pMac->lim.gpLimMlmOemDataReq)
1496 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001497 PELOGE(limLog(pMac, LOGE, FL("Null pointer"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001498 goto error;
1499 }
1500
1501 reqLen = sizeof(tStartOemDataReq);
1502
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301503 pStartOemDataReq = vos_mem_malloc(reqLen);
1504 if ( NULL == pStartOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001505 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001506 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Could not allocate memory for pStartOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001507 goto error;
1508 }
1509
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301510 vos_mem_set((tANI_U8*)(pStartOemDataReq), reqLen, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001511
1512 //Now copy over the information to the OEM DATA REQ to HAL
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301513 vos_mem_copy(pStartOemDataReq->selfMacAddr,
1514 pMac->lim.gpLimMlmOemDataReq->selfMacAddr,
1515 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07001516
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301517 vos_mem_copy(pStartOemDataReq->oemDataReq,
1518 pMac->lim.gpLimMlmOemDataReq->oemDataReq,
1519 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001520
1521 //Create the message to be passed to HAL
1522 msg.type = WDA_START_OEM_DATA_REQ;
1523 msg.bodyptr = pStartOemDataReq;
1524 msg.bodyval = 0;
1525
1526 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1527 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1528
1529 rc = wdaPostCtrlMsg(pMac, &msg);
1530 if(rc == eSIR_SUCCESS)
1531 {
1532 return;
1533 }
1534
1535 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301536 vos_mem_free(pStartOemDataReq);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001537 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: posting WDA_START_OEM_DATA_REQ to HAL failed"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001538
1539error:
1540 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001541 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001542
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301543 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1544 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001545 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001546 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001547 return;
1548 }
1549
1550 if(NULL != pMac->lim.gpLimMlmOemDataReq)
1551 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301552 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001553 pMac->lim.gpLimMlmOemDataReq = NULL;
1554 }
1555
1556 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1557
1558 return;
1559}
1560/**
1561 * limSetOemDataReqModeFailed()
1562 *
1563 * FUNCTION:
1564 * This function is used as callback to resume link after the suspend fails while
1565 * starting oem data req mode.
1566 * LOGIC:
1567 * NA
1568 *
1569 * ASSUMPTIONS:
1570 * NA
1571 *
1572 * NOTE:
1573 *
1574 * @param pMac - Pointer to Global MAC structure
1575 * @return None
1576 */
1577
1578void limSetOemDataReqModeFailed(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1579{
1580 tpLimMlmOemDataRsp pMlmOemDataRsp;
1581
1582 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08001583 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnsone7245742012-09-05 17:12:55 -07001584
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301585 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
1586 if ( NULL == pMlmOemDataRsp )
Jeff Johnsone7245742012-09-05 17:12:55 -07001587 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001588 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 return;
1590 }
1591
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301592 if (NULL != pMac->lim.gpLimMlmOemDataReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07001593 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301594 vos_mem_free(pMac->lim.gpLimMlmOemDataReq);
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 pMac->lim.gpLimMlmOemDataReq = NULL;
1596 }
1597
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301598 vos_mem_set(pMlmOemDataRsp, sizeof(tLimMlmOemDataRsp), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001599
1600 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1601
1602 return;
1603}
1604
1605/**
1606 * limSetOemDataReqMode()
1607 *
1608 *FUNCTION:
1609 * This function is called to setup system into OEM DATA REQ mode
1610 *
1611 *LOGIC:
1612 * NA
1613 *
1614 *ASSUMPTIONS:
1615 * NA
1616 *
1617 *NOTE:
1618 *
1619 * @param pMac - Pointer to Global MAC structure
1620 * @return None
1621 */
1622
1623void limSetOemDataReqMode(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1624{
1625 if(status != eHAL_STATUS_SUCCESS)
1626 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001627 limLog(pMac, LOGE, FL("OEM_DATA: failed in suspend link"));
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301628 /* If failed to suspend the link, there is no need
1629 * to resume link. Return failure.
1630 */
1631 limSetOemDataReqModeFailed(pMac, status, data);
Jeff Johnsone7245742012-09-05 17:12:55 -07001632 }
1633 else
1634 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001635 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Calling limSendHalOemDataReq"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001636 limSendHalOemDataReq(pMac);
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 }
1638
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05301639 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001640} /*** end limSendHalOemDataReq() ***/
1641
1642#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001643
1644static void
1645mlm_add_sta(
1646 tpAniSirGlobal pMac,
1647 tpAddStaParams pSta,
1648 tANI_U8 *pBssid,
1649 tANI_U8 htCapable,
1650 tpPESession psessionEntry) //psessionEntry may required in future
1651{
1652 tANI_U32 val;
1653 int i;
1654
1655
1656 pSta->staType = STA_ENTRY_SELF; // Identifying self
1657
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301658 vos_mem_copy(pSta->bssId, pBssid, sizeof( tSirMacAddr ));
1659 vos_mem_copy(pSta->staMac, psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001660
1661 /* Configuration related parameters to be changed to support BT-AMP */
1662
1663 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_LISTEN_INTERVAL, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001664 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001665
1666 pSta->listenInterval = (tANI_U16) val;
1667
1668 if (eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) )
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001669 limLog(pMac, LOGP, FL("Couldn't get SHORT_PREAMBLE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 pSta->shortPreambleSupported = (tANI_U8)val;
1671
1672 pSta->assocId = 0; // Is SMAC OK with this?
1673 pSta->wmmEnabled = 0;
1674 pSta->uAPSD = 0;
1675 pSta->maxSPLen = 0;
1676 pSta->us32MaxAmpduDuration = 0;
1677 pSta->maxAmpduSize = 0; // 0: 8k, 1: 16k,2: 32k,3: 64k
1678
1679
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001680 /* For Self STA get the LDPC capability from config.ini*/
1681 pSta->htLdpcCapable =
1682 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
1683 pSta->vhtLdpcCapable =
1684 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
1685
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1687 {
1688 pSta->htCapable = htCapable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 pSta->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
1690 pSta->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry );
1691 pSta->mimoPS = (tSirMacHTMIMOPowerSaveState)limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
1692 pSta->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
1693 pSta->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
1694 pSta->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
1695 pSta->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
1696 pSta->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
1697 pSta->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
1698 pSta->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
1699 pSta->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001701#ifdef WLAN_FEATURE_11AC
1702 if (psessionEntry->vhtCapability)
1703 {
1704 pSta->vhtCapable = VOS_TRUE;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001705 pSta->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001706 }
1707#endif
1708#ifdef WLAN_FEATURE_11AC
1709 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry,NULL);
1710#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 limFillSupportedRatesInfo(pMac, NULL, &pSta->supportedRates,psessionEntry);
1714
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001715 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 -07001716 pSta->greenFieldCapable, pSta->txChannelWidthSet, pSta->mimoPS, pSta->lsigTxopProtection,
1717 pSta->fDsssCckMode40Mhz,pSta->fShortGI20Mhz, pSta->fShortGI40Mhz);
1718
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 if (VOS_P2P_GO_MODE == psessionEntry->pePersona)
1720 {
1721 pSta->p2pCapableSta = 1;
1722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001723
1724 //Disable BA. It will be set as part of ADDBA negotiation.
1725 for( i = 0; i < STACFG_MAX_TC; i++ )
1726 {
1727 pSta->staTCParams[i].txUseBA = eBA_DISABLE;
1728 pSta->staTCParams[i].rxUseBA = eBA_DISABLE;
1729 }
1730
1731}
1732
1733//
1734// New HAL interface - WDA_ADD_BSS_REQ
1735// Package WDA_ADD_BSS_REQ to HAL, in order to start a BSS
1736//
1737tSirResultCodes
1738limMlmAddBss (
1739 tpAniSirGlobal pMac,
1740 tLimMlmStartReq *pMlmStartReq,
1741 tpPESession psessionEntry)
1742{
1743 tSirMsgQ msgQ;
1744 tpAddBssParams pAddBssParams = NULL;
1745 tANI_U32 retCode;
1746
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 // Package WDA_ADD_BSS_REQ message parameters
1748
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301749 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
1750 if ( NULL == pAddBssParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301752 limLog( pMac, LOGE, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 // Respond to SME with LIM_MLM_START_CNF
1754 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1755 }
1756
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301757 vos_mem_set(pAddBssParams, sizeof(tAddBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001758
1759 // Fill in tAddBssParams members
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301760 vos_mem_copy(pAddBssParams->bssId, pMlmStartReq->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 sizeof( tSirMacAddr ));
1762
1763 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301764 vos_mem_copy (pAddBssParams->selfMacAddr,
1765 psessionEntry->selfMacAddr,
1766 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001767
1768 pAddBssParams->bssType = pMlmStartReq->bssType;
1769 if ((pMlmStartReq->bssType == eSIR_IBSS_MODE) ||
1770 (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE)||
1771 (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE)) {
1772 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
1773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 else if (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE){
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_AP;
1776 }
1777
Jeff Johnsone7245742012-09-05 17:12:55 -07001778 pAddBssParams->shortSlotTimeSupported = psessionEntry->shortSlotTimeSupported;
Jeff Johnson295189b2012-06-20 16:38:30 -07001779
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 pAddBssParams->beaconInterval = pMlmStartReq->beaconPeriod;
1781 pAddBssParams->dtimPeriod = pMlmStartReq->dtimPeriod;
1782 pAddBssParams->cfParamSet.cfpCount = pMlmStartReq->cfParamSet.cfpCount;
1783 pAddBssParams->cfParamSet.cfpPeriod = pMlmStartReq->cfParamSet.cfpPeriod;
1784 pAddBssParams->cfParamSet.cfpMaxDuration = pMlmStartReq->cfParamSet.cfpMaxDuration;
1785 pAddBssParams->cfParamSet.cfpDurRemaining = pMlmStartReq->cfParamSet.cfpDurRemaining;
1786
1787 pAddBssParams->rateSet.numRates = pMlmStartReq->rateSet.numRates;
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301788 if (pAddBssParams->rateSet.numRates > SIR_MAC_RATESET_EID_MAX) {
1789 limLog(pMac, LOGW,
1790 FL("num of sup rates %d exceeding the limit %d, resetting"),
1791 pAddBssParams->rateSet.numRates,
1792 SIR_MAC_RATESET_EID_MAX);
1793 pAddBssParams->rateSet.numRates = SIR_MAC_RATESET_EID_MAX;
1794 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301795 vos_mem_copy(pAddBssParams->rateSet.rate,
lifeng62aa8d52018-08-09 18:38:43 +08001796 pMlmStartReq->rateSet.rate, pAddBssParams->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798 pAddBssParams->nwType = pMlmStartReq->nwType;
1799
1800 pAddBssParams->htCapable = pMlmStartReq->htCapable;
Jeff Johnsone7245742012-09-05 17:12:55 -07001801#ifdef WLAN_FEATURE_11AC
1802 pAddBssParams->vhtCapable = psessionEntry->vhtCapability;
1803 pAddBssParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
1804#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 pAddBssParams->htOperMode = pMlmStartReq->htOperMode;
1806 pAddBssParams->dualCTSProtection = pMlmStartReq->dualCTSProtection;
1807 pAddBssParams->txChannelWidthSet = pMlmStartReq->txChannelWidthSet;
1808
1809 pAddBssParams->currentOperChannel = pMlmStartReq->channelNumber;
Jeff Johnsone7245742012-09-05 17:12:55 -07001810 pAddBssParams->currentExtChannel = pMlmStartReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
Chet Lanctot8cecea22014-02-11 19:09:36 -08001812#ifdef WLAN_FEATURE_11W
1813 pAddBssParams->rmfEnabled = psessionEntry->limRmfEnabled;
1814#endif
1815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 /* Update PE sessionId*/
1817 pAddBssParams->sessionId = pMlmStartReq->sessionId;
1818
1819 //Send the SSID to HAL to enable SSID matching for IBSS
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301820 pAddBssParams->ssId.length = pMlmStartReq->ssId.length;
1821 if (pAddBssParams->ssId.length > SIR_MAC_MAX_SSID_LENGTH) {
1822 limLog(pMac, LOGE,
1823 FL("Invalid ssid length %d, max length allowed %d"),
1824 pAddBssParams->ssId.length,
1825 SIR_MAC_MAX_SSID_LENGTH);
1826 vos_mem_free(pAddBssParams);
1827 return eSIR_SME_INVALID_PARAMETERS;
1828 }
1829 vos_mem_copy(pAddBssParams->ssId.ssId,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301830 pMlmStartReq->ssId.ssId,
lifeng62aa8d52018-08-09 18:38:43 +08001831 pAddBssParams->ssId.length);
Abhishek Singh70c0eb12018-06-27 15:28:52 +05301832
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 pAddBssParams->bHiddenSSIDEn = pMlmStartReq->ssidHidden;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001834 limLog( pMac, LOGE, FL( "TRYING TO HIDE SSID %d" ),pAddBssParams->bHiddenSSIDEn);
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 // CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed.
1836 pAddBssParams->bProxyProbeRespEn = 0;
1837 pAddBssParams->obssProtEnabled = pMlmStartReq->obssProtEnabled;
1838
Jeff Johnson295189b2012-06-20 16:38:30 -07001839#if defined WLAN_FEATURE_VOWIFI
1840 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
1841#endif
1842 mlm_add_sta(pMac, &pAddBssParams->staContext,
1843 pAddBssParams->bssId, pAddBssParams->htCapable,psessionEntry);
1844
1845 pAddBssParams->status = eHAL_STATUS_SUCCESS;
1846 pAddBssParams->respReqd = 1;
1847
1848 // Set a new state for MLME
1849 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001850 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852 pAddBssParams->halPersona=psessionEntry->pePersona; //pass on the session persona to hal
1853
1854 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
1855
1856#if defined WLAN_FEATURE_VOWIFI_11R
1857 pAddBssParams->extSetStaKeyParamValid = 0;
1858#endif
1859
1860 //
1861 // FIXME_GEN4
1862 // A global counter (dialog token) is required to keep track of
1863 // all PE <-> HAL communication(s)
1864 //
1865 msgQ.type = WDA_ADD_BSS_REQ;
1866 msgQ.reserved = 0;
1867 msgQ.bodyptr = pAddBssParams;
1868 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001869 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001870
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001871 limLog( pMac, LOGW, FL( "Sending WDA_ADD_BSS_REQ..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1873 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001874 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301875 vos_mem_free(pAddBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1877 }
1878
1879 return eSIR_SME_SUCCESS;
1880}
1881
1882
1883/**
1884 * limProcessMlmStartReq()
1885 *
1886 *FUNCTION:
1887 * This function is called to process MLM_START_REQ message
1888 * from SME
1889 *
1890 *LOGIC:
1891 * 1) MLME receives LIM_MLM_START_REQ from LIM
1892 * 2) MLME sends WDA_ADD_BSS_REQ to HAL
1893 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
1894 * MLME now waits for HAL to send WDA_ADD_BSS_RSP
1895 *
1896 *ASSUMPTIONS:
1897 *
1898 *NOTE:
1899 *
1900 * @param pMac Pointer to Global MAC structure
1901 * @param *pMsgBuf A pointer to the MLM message buffer
1902 * @return None
1903 */
1904
1905static void
1906limProcessMlmStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1907{
1908 tLimMlmStartReq *pMlmStartReq;
1909 tLimMlmStartCnf mlmStartCnf;
1910 tpPESession psessionEntry = NULL;
1911
1912 if(pMsgBuf == NULL)
1913 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001914 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 return;
1916 }
1917
1918 pMlmStartReq = (tLimMlmStartReq *) pMsgBuf;
1919 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmStartReq->sessionId))==NULL)
1920 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001921 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 mlmStartCnf.resultCode = eSIR_SME_REFUSED;
1923 goto end;
1924 }
1925
1926 if (psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE)
1927 {
1928 /**
1929 * Should not have received Start req in states other than idle.
1930 * Return Start confirm with failure code.
1931 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001932 PELOGE(limLog(pMac, LOGE, FL("received unexpected MLM_START_REQ in state %X"),psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
1934 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1935 goto end;
1936 }
1937
1938 #if 0
1939 if (cfgSetInt(pMac, WNI_CFG_CURRENT_CHANNEL, pMlmStartReq->channelNumber)!= eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001940 limLog(pMac, LOGP, FL("could not set CURRENT_CHANNEL at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001941
1942 pMac->lim.gLimCurrentChannelId = pMlmStartReq->channelNumber;
1943 #endif //TO SUPPORT BT-AMP
1944
1945
1946 // Update BSSID & SSID at CFG database
1947 #if 0 //We are not using the BSSID and SSID from the config file, instead we are reading form the session table
1948 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pMlmStartReq->bssId, sizeof(tSirMacAddr))
1949 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001950 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
1952
1953
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05301954 vos_mem_copy( pMac->lim.gLimCurrentBssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 pMlmStartReq->bssId,
1956 sizeof(tSirMacAddr));
1957 #endif //TO SUPPORT BT-AMP
1958
1959 #if 0
1960 if (cfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *) &pMlmStartReq->ssId.ssId, pMlmStartReq->ssId.length)
1961 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001962 limLog(pMac, LOGP, FL("could not update SSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 #endif //To SUPPORT BT-AMP
1964
1965
1966 // pMac->lim.gLimCurrentSSID.length = pMlmStartReq->ssId.length;
1967
1968 #if 0
1969 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
1970 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
1971 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
1972 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001973 limLog(pMac, LOGP, FL("could not update Operational Rateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 #endif //TO SUPPORT BT-AMP
1975
1976
Jeff Johnson295189b2012-06-20 16:38:30 -07001977
Jeff Johnson295189b2012-06-20 16:38:30 -07001978#if 0 // Periodic timer for remove WPS PBC proble response entry in PE is disbaled now.
1979 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1980 {
1981 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_FALSE)
1982 {
1983 if (tx_timer_create(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer,
1984 "PS OVERLAP Timer",
1985 limWPSOverlapTimerHandler,
1986 SIR_LIM_WPS_OVERLAP_TIMEOUT, // expiration_input
1987 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // initial_ticks
1988 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // reschedule_ticks
1989 TX_AUTO_ACTIVATE /* TX_NO_ACTIVATE*/) != TX_SUCCESS)
1990 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001991 limLog(pMac, LOGP, FL("failed to create WPS overlap Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 }
1993
1994 pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId = pMlmStartReq->sessionId;
1995 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001996 limLog(pMac, LOGE, FL("Create WPS overlap Timer, session=%d"), pMlmStartReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
1998 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
1999 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002000 limLog(pMac, LOGP, FL("tx_timer_activate failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 }
2003 }
2004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006
2007
2008 mlmStartCnf.resultCode = limMlmAddBss(pMac, pMlmStartReq,psessionEntry);
2009
2010end:
2011 /* Update PE session Id */
2012 mlmStartCnf.sessionId = pMlmStartReq->sessionId;
2013
2014 /// Free up buffer allocated for LimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302015 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002016
2017 //
2018 // Respond immediately to LIM, only if MLME has not been
2019 // successfully able to send WDA_ADD_BSS_REQ to HAL.
2020 // Else, LIM_MLM_START_CNF will be sent after receiving
2021 // WDA_ADD_BSS_RSP from HAL
2022 //
2023 if( eSIR_SME_SUCCESS != mlmStartCnf.resultCode )
2024 limPostSmeMessage(pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf);
2025} /*** limProcessMlmStartReq() ***/
2026
2027
2028/*
2029* This function checks if Scan is allowed or not.
2030* It checks each session and if any session is not in the normal state,
2031* it will return false.
2032* Note: BTAMP_STA can be in LINK_EST as well as BSS_STARTED State, so
2033* both cases are handled below.
2034*/
2035
2036static tANI_U8 __limMlmScanAllowed(tpAniSirGlobal pMac)
2037{
2038 int i;
2039
Jeff Johnson43971f52012-07-17 12:26:56 -07002040 if(pMac->lim.gLimMlmState != eLIM_MLM_IDLE_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 {
2042 return FALSE;
2043 }
2044 for(i =0; i < pMac->lim.maxBssId; i++)
2045 {
2046 if(pMac->lim.gpSession[i].valid == TRUE)
2047 {
2048 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
2049 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
2050 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) )||
2051
2052 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
2053 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
2054 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2055 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
2057 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
2058 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
2059 && (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 ))
2061 {
2062 return FALSE;
2063
2064 }
2065 }
2066 }
2067
2068 return TRUE;
2069}
2070
2071
2072
2073/**
2074 * limProcessMlmScanReq()
2075 *
2076 *FUNCTION:
2077 * This function is called to process MLM_SCAN_REQ message
2078 * from SME
2079 *
2080 *LOGIC:
2081 *
2082 *ASSUMPTIONS:
2083 *
2084 *NOTE:
2085 *
2086 * @param pMac Pointer to Global MAC structure
2087 * @param *pMsgBuf A pointer to the MLM message buffer
2088 * @return None
2089 */
2090
2091static void
2092limProcessMlmScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2093{
2094 tLimMlmScanCnf mlmScanCnf;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002095 tANI_U8 i = 0;
2096 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
2098 if (pMac->lim.gLimSystemInScanLearnMode)
2099 {
2100 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002101 FL("Sending START_SCAN from LIM while one req is pending"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302102 vos_mem_free(pMsgBuf);
Madan Mohan Koyyalamudid4b301b2012-10-11 14:15:54 -07002103 /*Send back a failure*/
2104 mlmScanCnf.resultCode = eSIR_SME_SCAN_FAILED;
2105 mlmScanCnf.scanResultLength = 0;
2106 limPostSmeMessage(pMac,
2107 LIM_MLM_SCAN_CNF,
2108 (tANI_U32 *) &mlmScanCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 return;
2110 }
2111
2112 if(__limMlmScanAllowed(pMac) &&
2113 (((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels != 0))
2114
2115 {
2116 /// Hold onto SCAN REQ criteria
2117 pMac->lim.gpLimMlmScanReq = (tLimMlmScanReq *) pMsgBuf;
2118
Abhishek Singh127a8442014-12-15 17:31:27 +05302119 limLog(pMac, LOG1, FL("Number of channels to scan are %d "),
2120 pMac->lim.gpLimMlmScanReq->channelList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002121
2122 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2123
2124 if (pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
2125 pMac->lim.gLimMlmState = eLIM_MLM_WT_PROBE_RESP_STATE;
2126 else // eSIR_PASSIVE_SCAN
2127 pMac->lim.gLimMlmState = eLIM_MLM_PASSIVE_SCAN_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002128 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002129
2130 pMac->lim.gLimSystemInScanLearnMode = 1;
2131
Maleka Vinayd500cd42012-12-10 12:37:09 -08002132 /* temporary fix to handle case where NOA duration calculation is incorrect
2133 * for scanning on DFS channels */
2134
2135 pMac->lim.gTotalScanDuration = 0;
2136
2137 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
2138 {
2139 /*
2140 * Could not get max channel value
2141 * from CFG. Log error.
2142 */
Abhishek Singh95f7b252015-10-14 14:15:35 +05302143 limLog(pMac, LOGP,
2144 FL("could not retrieve passive max channel value use def"));
2145 /* use a default value */
2146 val= WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME_STADEF;
Maleka Vinayd500cd42012-12-10 12:37:09 -08002147 }
2148
2149 for (i = 0; i < pMac->lim.gpLimMlmScanReq->channelList.numChannels; i++) {
2150 tANI_U8 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[i];
2151
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05302152 if (pMac->miracast_mode) {
2153 pMac->lim.gTotalScanDuration += (DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
2154 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST);
2155 } else if (limActiveScanAllowed(pMac, channelNum)) {
Maleka Vinayd500cd42012-12-10 12:37:09 -08002156 /* Use min + max channel time to calculate the total duration of scan */
2157 pMac->lim.gTotalScanDuration += pMac->lim.gpLimMlmScanReq->minChannelTime + pMac->lim.gpLimMlmScanReq->maxChannelTime;
2158 } else {
2159 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
2160 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
2161 */
2162 pMac->lim.gTotalScanDuration += val;
2163 }
2164 }
2165
2166 /* Adding an overhead of 5ms to account for the scan messaging delays */
2167 pMac->lim.gTotalScanDuration += 5;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 limSetScanMode(pMac);
2169 }
2170 else
2171 {
2172 /**
2173 * Should not have received SCAN req in other states
2174 * OR should not have received LIM_MLM_SCAN_REQ with
2175 * zero number of channels
2176 * Log error
2177 */
2178 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302179 FL("received unexpected MLM_SCAN_REQ in state %d OR zero number of channels: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 pMac->lim.gLimMlmState, ((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels);
2181 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2182
2183 /// Free up buffer allocated for
2184 /// pMac->lim.gLimMlmScanReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302185 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002186
2187 /// Return Scan confirm with INVALID_PARAMETERS
2188
2189 mlmScanCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2190 mlmScanCnf.scanResultLength = 0;
2191 limPostSmeMessage(pMac,
2192 LIM_MLM_SCAN_CNF,
2193 (tANI_U32 *) &mlmScanCnf);
2194 }
2195} /*** limProcessMlmScanReq() ***/
2196
Jeff Johnsone7245742012-09-05 17:12:55 -07002197#ifdef FEATURE_OEM_DATA_SUPPORT
2198static void limProcessMlmOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2199{
2200 tLimMlmOemDataRsp* pMlmOemDataRsp;
2201
2202 if (((pMac->lim.gLimMlmState == eLIM_MLM_IDLE_STATE) ||
2203 (pMac->lim.gLimMlmState == eLIM_MLM_JOINED_STATE) ||
2204 (pMac->lim.gLimMlmState == eLIM_MLM_AUTHENTICATED_STATE) ||
2205 (pMac->lim.gLimMlmState == eLIM_MLM_BSS_STARTED_STATE) ||
2206 (pMac->lim.gLimMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)))
2207 {
2208 //Hold onto the oem data request criteria
2209 pMac->lim.gpLimMlmOemDataReq = (tLimMlmOemDataReq*)pMsgBuf;
2210
2211 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
2212
2213 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
2214
2215 //Now request for link suspension
2216 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, limSetOemDataReqMode, NULL);
2217 }
2218 else
2219 {
2220 /**
2221 * Should not have received oem data req in other states
2222 * Log error
2223 */
2224
Sushant Kaushik1b645382014-10-13 16:39:36 +05302225 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 -07002226
2227 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
2228
2229 /// Free up buffer allocated
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302230 vos_mem_free(pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07002231
2232 /// Return Meas confirm with INVALID_PARAMETERS
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302233 pMlmOemDataRsp = vos_mem_malloc(sizeof(tLimMlmOemDataRsp));
2234 if ( pMlmOemDataRsp != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002235 {
2236 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302237 vos_mem_free(pMlmOemDataRsp);
Jeff Johnsone7245742012-09-05 17:12:55 -07002238 }
2239 else
2240 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002241 limLog(pMac, LOGP, FL("Could not allocate memory for pMlmOemDataRsp"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002242 return;
2243 }
2244 }
2245
2246 return;
2247}
2248#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07002249
2250
2251/**
2252 * limProcessMlmPostJoinSuspendLink()
2253 *
2254 *FUNCTION:
2255 * This function is called after the suspend link while joining
2256 * off channel.
2257 *
2258 *LOGIC:
2259 * Check for suspend state.
2260 * If success, proceed with setting link state to recieve the
2261 * probe response/beacon from intended AP.
2262 * Switch to the APs channel.
2263 * On an error case, send the MLM_JOIN_CNF with error status.
2264 *
2265 *ASSUMPTIONS:
2266 *
2267 *NOTE:
2268 *
2269 * @param pMac Pointer to Global MAC structure
2270 * @param status status of suspend link.
2271 * @param ctx passed while calling suspend link(psessionEntry)
2272 * @return None
2273 */
2274static void
2275limProcessMlmPostJoinSuspendLink(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *ctx)
2276{
Jeff Johnsone7245742012-09-05 17:12:55 -07002277 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 tLimMlmJoinCnf mlmJoinCnf;
2279 tpPESession psessionEntry = (tpPESession)ctx;
2280 tSirLinkState linkState;
2281
2282 if( eHAL_STATUS_SUCCESS != status )
2283 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302284 limLog(pMac, LOGE, FL("Sessionid %d Suspend link(NOTIFY_BSS) failed. "
2285 "still proceeding with join"),psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 }
2287 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2288 psessionEntry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002289 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002290
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302291 limLog(pMac, LOG1, FL("Sessionid %d prev lim state %d new lim state %d "
2292 "systemrole = %d"), psessionEntry->peSessionId,
2293 psessionEntry->limPrevMlmState,
2294 psessionEntry->limMlmState,psessionEntry->limSystemRole);
2295
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
2297
2298 //assign appropriate sessionId to the timer object
2299 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId = psessionEntry->peSessionId;
2300
2301 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 -07002302 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: linkState:%d"),linkState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303
2304 if (limSetLinkState(pMac, linkState,
2305 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,
2306 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2307 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302308 limLog(pMac, LOGE,
2309 FL("SessionId:%d limSetLinkState to eSIR_LINK_PREASSOC_STATE"
2310 " Failed!!"),psessionEntry->peSessionId);
2311 limPrintMacAddr(pMac,
2312 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
2315 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 goto error;
2317 }
2318
2319 /** Derive channel from BSS description and store it in the CFG */
2320 // chanNum = pMac->lim.gpLimMlmJoinReq->bssDescription.channelId;
2321
2322 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07002323 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 //store the channel switch sessionEntry in the lim global var
2325 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_JOIN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002326#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002327 psessionEntry->pLimMlmReassocRetryReq = NULL;
2328#endif
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302329
2330#ifdef FEATURE_WLAN_DIAG_SUPPORT
2331 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2332 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_JOIN);
2333#endif
2334
Dino Myclea7f18452014-04-24 08:55:31 +05302335 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: suspend link success(%d) "
2336 "on sessionid: %d setting channel to: %d with secChanOffset:%d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302337 "and maxtxPower: %d"), status, psessionEntry->peSessionId,
2338 chanNum, secChanOffset, psessionEntry->maxTxPower);
Jeff Johnsone7245742012-09-05 17:12:55 -07002339 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
2341 return;
2342error:
2343 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2344 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
2345 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2346 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2347
2348}
2349
2350
2351
2352/**
2353 * limProcessMlmJoinReq()
2354 *
2355 *FUNCTION:
2356 * This function is called to process MLM_JOIN_REQ message
2357 * from SME
2358 *
2359 *LOGIC:
2360 * 1) Initialize LIM, HAL, DPH
2361 * 2) Configure the BSS for which the JOIN REQ was received
2362 * a) Send WDA_ADD_BSS_REQ to HAL -
2363 * This will identify the BSS that we are interested in
2364 * --AND--
2365 * Add a STA entry for the AP (in a STA context)
2366 * b) Wait for WDA_ADD_BSS_RSP
2367 * c) Send WDA_ADD_STA_REQ to HAL
2368 * This will add the "local STA" entry to the STA table
2369 * 3) Continue as before, i.e,
2370 * a) Send a PROBE REQ
2371 * b) Wait for PROBE RSP/BEACON containing the SSID that
2372 * we are interested in
2373 * c) Then start an AUTH seq
2374 * d) Followed by the ASSOC seq
2375 *
2376 *ASSUMPTIONS:
2377 *
2378 *NOTE:
2379 *
2380 * @param pMac Pointer to Global MAC structure
2381 * @param *pMsgBuf A pointer to the MLM message buffer
2382 * @return None
2383 */
2384
2385static void
2386limProcessMlmJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2387{
2388 tLimMlmJoinCnf mlmJoinCnf;
2389 tANI_U8 sessionId;
2390 tpPESession psessionEntry;
2391
2392 sessionId = ((tpLimMlmJoinReq)pMsgBuf)->sessionId;
2393
2394 if((psessionEntry = peFindSessionBySessionId(pMac,sessionId))== NULL)
2395 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302396 limLog(pMac, LOGE, FL("SessionId:%d session does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 goto error;
2398 }
2399
2400 if (( (psessionEntry->limSystemRole != eLIM_AP_ROLE ) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE )) &&
2401 ( (psessionEntry->limMlmState == eLIM_MLM_IDLE_STATE) ||
2402 (psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE)) &&
2403 (SIR_MAC_GET_ESS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo) !=
2404 SIR_MAC_GET_IBSS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo)))
2405 {
2406 #if 0
2407 if (pMac->lim.gpLimMlmJoinReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302408 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 #endif //TO SUPPORT BT-AMP , review 23sep
2410
2411 /// Hold onto Join request parameters
2412
2413 psessionEntry->pLimMlmJoinReq =(tpLimMlmJoinReq) pMsgBuf;
2414
2415 if( isLimSessionOffChannel(pMac, sessionId) )
2416 {
2417 //suspend link
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302418 limLog(pMac, LOG1, FL("Suspend link as LimSession on sessionid %d"
2419 "is off channel"),sessionId);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302420 if (limIsLinkSuspended(pMac))
2421 {
2422 limLog(pMac, LOGE, FL("Link is already suspended for some other"
2423 " reason. Return failure on sessionId:%d"), sessionId);
2424 goto error;
2425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
2427 limProcessMlmPostJoinSuspendLink, (tANI_U32*)psessionEntry );
2428 }
2429 else
2430 {
2431 //No need to suspend link.
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302432 limLog(pMac,LOG1,"SessionId:%d Join request on current channel",
2433 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 limProcessMlmPostJoinSuspendLink( pMac, eHAL_STATUS_SUCCESS,
2435 (tANI_U32*) psessionEntry );
2436 }
2437
2438 return;
2439 }
2440 else
2441 {
2442 /**
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302443 * Should not have received JOIN req in states other than
2444 * Idle state or on AP.
2445 * Return join confirm with invalid parameters code.
2446 */
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302447 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302448 FL("SessionId:%d Unexpected Join request for role %d state %d "),
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302449 psessionEntry->peSessionId,psessionEntry->limSystemRole,
2450 psessionEntry->limMlmState);
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302451 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 }
2453
2454error:
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302455 vos_mem_free(pMsgBuf);
2456 if (psessionEntry != NULL)
2457 psessionEntry->pLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002458
Kanchanapally, Vidyullatha35570872015-03-18 17:26:57 +05302459 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2460 mlmJoinCnf.sessionId = sessionId;
2461 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2462 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002463} /*** limProcessMlmJoinReq() ***/
2464
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302465#ifdef WLAN_FEATURE_SAE
2466/**
2467 * lim_process_mlm_auth_req_sae() - Handle SAE authentication
2468 * @mac_ctx: global MAC context
2469 * @session: PE session entry
2470 *
2471 * This function is called by lim_process_mlm_auth_req to handle SAE
2472 * authentication.
2473 *
2474 * Return: tSirRetStatus
2475 */
2476static VOS_STATUS lim_process_mlm_auth_req_sae(tpAniSirGlobal mac_ctx,
2477 tpPESession session)
2478{
2479 VOS_STATUS status = VOS_STATUS_SUCCESS;
2480 struct sir_sae_info *sae_info;
2481 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002482
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302483 sae_info = vos_mem_malloc(sizeof(*sae_info));
2484 if (sae_info == NULL) {
2485 limLog(mac_ctx, LOGP, FL("Memory allocation failed"));
2486 return VOS_STATUS_E_FAILURE;
2487 }
2488
2489 sae_info->msg_type = eWNI_SME_TRIGGER_SAE;
2490 sae_info->msg_len = sizeof(*sae_info);
2491 sae_info->vdev_id = session->smeSessionId;
2492
2493 vos_mem_copy(sae_info->peer_mac_addr.bytes, session->bssId,
2494 VOS_MAC_ADDR_SIZE);
2495
2496 sae_info->ssid.length = session->ssId.length;
2497 vos_mem_copy(sae_info->ssid.ssId, session->ssId.ssId,
2498 session->ssId.length);
2499 limLog(mac_ctx, LOG1, FL("vdev_id %d ssid %.*s "MAC_ADDRESS_STR""),
2500 sae_info->vdev_id, sae_info->ssid.length,sae_info->ssid.ssId,
2501 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
2502
2503 msg.type = eWNI_SME_TRIGGER_SAE;
2504 msg.bodyptr = sae_info;
2505 msg.bodyval = 0;
2506
2507 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
2508 {
2509 limLog(mac_ctx, LOGE, "%s failed to post msg to self ",
2510 __func__);
2511 vos_mem_free((void *)sae_info);
2512 status = VOS_STATUS_E_FAILURE;
2513 }
2514
2515 session->limMlmState = eLIM_MLM_WT_SAE_AUTH_STATE;
2516
2517 MTRACE(macTrace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
2518 session->limMlmState));
2519
2520 return status;
2521}
2522#else
2523static VOS_STATUS lim_process_mlm_auth_req_sae(tpAniSirGlobal mac_ctx,
2524 tpPESession session)
2525{
2526 return VOS_STATUS_E_NOSUPPORT;
2527}
2528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002529
2530/**
2531 * limProcessMlmAuthReq()
2532 *
2533 *FUNCTION:
2534 * This function is called to process MLM_AUTH_REQ message
2535 * from SME
2536 *
2537 *LOGIC:
2538 *
2539 *ASSUMPTIONS:
2540 *
2541 *NOTE:
2542 *
2543 * @param pMac Pointer to Global MAC structure
2544 * @param *pMsgBuf A pointer to the MLM message buffer
2545 * @return None
2546 */
2547
2548static void
2549limProcessMlmAuthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2550{
2551 tANI_U32 numPreAuthContexts;
2552 tSirMacAddr currentBssId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 tLimMlmAuthCnf mlmAuthCnf;
2554 struct tLimPreAuthNode *preAuthNode;
2555 tpDphHashNode pStaDs;
2556 tANI_U8 sessionId;
2557 tpPESession psessionEntry;
2558
2559 if(pMsgBuf == NULL)
2560 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002561 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 return;
2563 }
2564
2565 pMac->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) pMsgBuf;
2566 sessionId = pMac->lim.gpLimMlmAuthReq->sessionId;
2567 if((psessionEntry= peFindSessionBySessionId(pMac,sessionId) )== NULL)
2568 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302569 limLog(pMac, LOGP, FL("SessionId:%d Session Does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 return;
2571 }
2572
Abhishek Singhcd09b562013-12-24 16:02:20 +05302573 limLog(pMac, LOG1,FL("Process Auth Req on sessionID %d Systemrole %d"
2574 "mlmstate %d from: "MAC_ADDRESS_STR" with authtype %d"), sessionId,
2575 psessionEntry->limSystemRole,psessionEntry->limMlmState,
2576 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr),
2577 pMac->lim.gpLimMlmAuthReq->authType);
2578
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 /**
2581 * Expect Auth request only when:
2582 * 1. STA joined/associated with a BSS or
2583 * 2. STA is in IBSS mode
2584 * and STA is going to authenticate with a unicast
2585 * adress and requested authentication algorithm is
2586 * supported.
2587 */
2588 #if 0
2589 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2590 eSIR_SUCCESS)
2591 {
2592 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002593 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 }
2595 #endif //To SuppoRT BT-AMP
2596
2597 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2598
2599 if (((((psessionEntry->limSystemRole== eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2600 ((psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) ||
2601 (psessionEntry->limMlmState ==
2602 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
2603 ((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) &&
2604 (psessionEntry->limMlmState == eLIM_MLM_BSS_STARTED_STATE))) &&
2605 (limIsGroupAddr(pMac->lim.gpLimMlmAuthReq->peerMacAddr)
2606 == false) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 (limIsAuthAlgoSupported(
2608 pMac,
2609 pMac->lim.gpLimMlmAuthReq->authType,
2610 psessionEntry) == true)
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 )
2612 {
2613 /**
2614 * This is a request for pre-authentication.
2615 * Check if there exists context already for
Jeff Johnson1250df42012-12-10 14:31:52 -08002616 * the requested peer OR
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 * if this request is for the AP we're currently
2618 * associated with.
2619 * If yes, return auth confirm immediately when
2620 * requested auth type is same as the one used before.
2621 */
2622 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2623 (psessionEntry->limMlmState ==
2624 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2625 (((pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) != NULL) &&
2626 (pMac->lim.gpLimMlmAuthReq->authType ==
2627 pStaDs->mlmStaContext.authType)) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302628 (vos_mem_compare(pMac->lim.gpLimMlmAuthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 currentBssId,
2630 sizeof(tSirMacAddr)) )) ||
2631 (((preAuthNode =
2632 limSearchPreAuthList(
2633 pMac,
2634 pMac->lim.gpLimMlmAuthReq->peerMacAddr)) != NULL) &&
2635 (preAuthNode->authType ==
2636 pMac->lim.gpLimMlmAuthReq->authType)))
2637 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302638 limLog(pMac, LOG2,
2639 FL("Already have pre-auth context with peer: "MAC_ADDRESS_STR),
2640 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
2642 mlmAuthCnf.resultCode = (tSirResultCodes)
2643 eSIR_MAC_SUCCESS_STATUS;
2644
2645
2646 goto end;
2647 }
2648 else
2649 {
2650 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
2651 (tANI_U32 *) &numPreAuthContexts) != eSIR_SUCCESS)
2652 {
2653 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002654 FL("Could not retrieve NumPreAuthLimit from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002656
2657 if (pMac->lim.gLimNumPreAuthContexts == numPreAuthContexts)
2658 {
2659 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002660 FL("Number of pre-auth reached max limit"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661
2662 /// Return Auth confirm with reject code
2663 mlmAuthCnf.resultCode =
2664 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
2665
2666 goto end;
2667 }
2668 }
2669
2670 // Delete pre-auth node if exists
2671 if (preAuthNode)
2672 limDeletePreAuthNode(pMac,
2673 pMac->lim.gpLimMlmAuthReq->peerMacAddr);
2674
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05302676 if (pMac->lim.gpLimMlmAuthReq->authType == eSIR_AUTH_TYPE_SAE) {
2677 if (lim_process_mlm_auth_req_sae(pMac, psessionEntry) !=
2678 VOS_STATUS_SUCCESS) {
2679 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2680 goto end;
2681 } else {
2682 limLog(pMac, LOG1,
2683 FL("lim_process_mlm_auth_req_sae is successful"));
2684 return;
2685 }
2686 } else {
2687 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
2688 }
2689
Jeff Johnsone7245742012-09-05 17:12:55 -07002690 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002691
Jeff Johnsone7245742012-09-05 17:12:55 -07002692 //assign appropriate sessionId to the timer object
2693 pMac->lim.limTimers.gLimAuthFailureTimer.sessionId = sessionId;
Sushant Kaushik9e923872015-04-02 17:09:31 +05302694 /* assign appropriate sessionId to the timer object */
2695 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId = sessionId;
2696 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07002697 // Activate Auth failure timer
2698 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_AUTH_FAIL_TIMER));
Paul Zhang83289792017-02-28 18:58:52 +08002699
2700 limDoSendAuthMgmtFrame(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 return;
2702 }
2703 else
2704 {
2705 /**
2706 * Unexpected auth request.
2707 * Return Auth confirm with Invalid parameters code.
2708 */
2709 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2710
2711 goto end;
2712 }
2713
2714end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302715 vos_mem_copy((tANI_U8 *) &mlmAuthCnf.peerMacAddr,
2716 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2717 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002718
2719 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
2720 mlmAuthCnf.sessionId = sessionId;
2721
2722 /// Free up buffer allocated
2723 /// for pMac->lim.gLimMlmAuthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302724 vos_mem_free( pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 pMac->lim.gpLimMlmAuthReq = NULL;
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302726 limLog(pMac,LOG1,"SessionId:%d LimPostSme LIM_MLM_AUTH_CNF ",sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 limPostSmeMessage(pMac, LIM_MLM_AUTH_CNF, (tANI_U32 *) &mlmAuthCnf);
2728} /*** limProcessMlmAuthReq() ***/
2729
2730
2731
2732/**
2733 * limProcessMlmAssocReq()
2734 *
2735 *FUNCTION:
2736 * This function is called to process MLM_ASSOC_REQ message
2737 * from SME
2738 *
2739 *LOGIC:
2740 *
2741 *ASSUMPTIONS:
2742 *
2743 *NOTE:
2744 *
2745 * @param pMac Pointer to Global MAC structure
2746 * @param *pMsgBuf A pointer to the MLM message buffer
2747 * @return None
2748 */
2749
2750static void
2751limProcessMlmAssocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2752{
2753 tSirMacAddr currentBssId;
2754 tLimMlmAssocReq *pMlmAssocReq;
2755 tLimMlmAssocCnf mlmAssocCnf;
2756 tpPESession psessionEntry;
2757 // tANI_U8 sessionId;
2758
2759 if(pMsgBuf == NULL)
2760 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002761 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 return;
2763 }
2764 pMlmAssocReq = (tLimMlmAssocReq *) pMsgBuf;
2765
2766 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmAssocReq->sessionId) )== NULL)
2767 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302768 limLog(pMac, LOGP,FL("SessionId:%d Session Does not exist"),
2769 pMlmAssocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302770 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 return;
2772 }
2773
Abhishek Singhcd09b562013-12-24 16:02:20 +05302774 limLog(pMac, LOG1,FL("Process Assoc Req on sessionID %d Systemrole %d"
2775 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmAssocReq->sessionId,
2776 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2777 MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));
2778
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 #if 0
2780 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2781 eSIR_SUCCESS)
2782 {
2783 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002784 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 }
2786 #endif //TO SUPPORT BT-AMP
2787 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2788
2789 if ( (psessionEntry->limSystemRole != eLIM_AP_ROLE && psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE) &&
2790 (psessionEntry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302791 (vos_mem_compare(pMlmAssocReq->peerMacAddr, currentBssId, sizeof(tSirMacAddr))) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002793
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 /// map the session entry pointer to the AssocFailureTimer
2795 pMac->lim.limTimers.gLimAssocFailureTimer.sessionId = pMlmAssocReq->sessionId;
2796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2798 psessionEntry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002799 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302800 limLog(pMac,LOG1,"SessionId:%d Sending Assoc_Req Frame",
2801 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803 /// Prepare and send Association request frame
2804 limSendAssocReqMgmtFrame(pMac, pMlmAssocReq,psessionEntry);
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302805#ifdef FEATURE_WLAN_DIAG_SUPPORT
2806 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_REQ_EVENT, psessionEntry,
2807 eSIR_SUCCESS, eSIR_SUCCESS);
2808#endif
2809
Jeff Johnson295189b2012-06-20 16:38:30 -07002810
2811 //Set the link state to postAssoc, so HW can start receiving frames from AP.
2812 if ((psessionEntry->bssType == eSIR_BTAMP_STA_MODE)||
2813 ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE) && (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
2814 {
2815 if(limSetLinkState(pMac, eSIR_LINK_BTAMP_POSTASSOC_STATE, currentBssId,
2816 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002817 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002819 /// Start association failure timer
2820 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
2821 if (tx_timer_activate(&pMac->lim.limTimers.gLimAssocFailureTimer)
2822 != TX_SUCCESS)
2823 {
2824 /// Could not start Assoc failure timer.
2825 // Log error
2826 limLog(pMac, LOGP,
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302827 FL("SessionId:%d could not start Association failure timer"),
2828 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 // Cleanup as if assoc timer expired
2830 limProcessAssocFailureTimeout(pMac,LIM_ASSOC );
2831
2832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002833
2834 return;
2835 }
2836 else
2837 {
2838 /**
2839 * Received Association request either in invalid state
2840 * or to a peer MAC entity whose address is different
2841 * from one that STA is currently joined with or on AP.
2842 * Return Assoc confirm with Invalid parameters code.
2843 */
2844
2845 // Log error
2846 PELOGW(limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302847 FL("received unexpected MLM_ASSOC_CNF in state %d for role=%d, MAC addr= "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302848 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2849 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2851
2852 mlmAssocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2853 mlmAssocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2854
2855 goto end;
2856 }
2857
2858end:
2859 /* Update PE session Id*/
2860 mlmAssocCnf.sessionId = pMlmAssocReq->sessionId;
2861
2862 /// Free up buffer allocated for assocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302863 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002864
2865 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
2866} /*** limProcessMlmAssocReq() ***/
2867
2868
2869
2870/**
2871 * limProcessMlmReassocReq()
2872 *
2873 *FUNCTION:
2874 * This function is called to process MLM_REASSOC_REQ message
2875 * from SME
2876 *
2877 *LOGIC:
2878 *
2879 *ASSUMPTIONS:
2880 *
2881 *NOTE:
2882 *
2883 * @param pMac Pointer to Global MAC structure
2884 * @param *pMsgBuf A pointer to the MLM message buffer
2885 * @return None
2886 */
2887
2888static void
2889limProcessMlmReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2890{
Jeff Johnsone7245742012-09-05 17:12:55 -07002891 tANI_U8 chanNum, secChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 struct tLimPreAuthNode *pAuthNode;
2893 tLimMlmReassocReq *pMlmReassocReq;
2894 tLimMlmReassocCnf mlmReassocCnf;
2895 tpPESession psessionEntry;
2896
2897 if(pMsgBuf == NULL)
2898 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002899 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 return;
2901 }
2902
2903 pMlmReassocReq = (tLimMlmReassocReq *) pMsgBuf;
Abhishek Singhcd09b562013-12-24 16:02:20 +05302904
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmReassocReq->sessionId)) == NULL)
2906 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302907 limLog(pMac, LOGE,FL("Session Does not exist for given sessionId %d"),
2908 pMlmReassocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302909 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 return;
2911 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302912
2913 limLog(pMac, LOG1,FL("Process ReAssoc Req on sessionID %d Systemrole %d"
2914 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmReassocReq->sessionId,
2915 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2916 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
2917
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 if (((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) &&
2919 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
2920 {
2921 if (psessionEntry->pLimMlmReassocReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302922 vos_mem_free(psessionEntry->pLimMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002923
2924 /* Hold Re-Assoc request as part of Session, knock-out pMac */
2925 /// Hold onto Reassoc request parameters
2926 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
2927
2928 // See if we have pre-auth context with new AP
2929 pAuthNode = limSearchPreAuthList(pMac, psessionEntry->limReAssocbssId);
2930
2931 if (!pAuthNode &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302932 (!vos_mem_compare(pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 psessionEntry->bssId,
2934 sizeof(tSirMacAddr)) ))
2935 {
2936 // Either pre-auth context does not exist AND
2937 // we are not reassociating with currently
2938 // associated AP.
2939 // Return Reassoc confirm with not authenticated
2940 mlmReassocCnf.resultCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2941 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2942
2943 goto end;
2944 }
2945
2946 //assign the sessionId to the timer object
2947 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = pMlmReassocReq->sessionId;
2948
2949 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2950 psessionEntry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002952
2953#if 0
2954 // Update BSSID at CFG database
2955 if (wlan_cfgSetStr(pMac, WNI_CFG_BSSID,
2956 pMac->lim.gLimReassocBssId,
2957 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
2958 {
2959 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002960 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 }
2962#endif //TO SUPPORT BT-AMP
2963
2964 /* Copy Global Reassoc ID*/
2965 // sirCopyMacAddr(psessionEntry->reassocbssId,pMac->lim.gLimReAssocBssId);
2966
2967 /**
2968 * Derive channel from BSS description and
2969 * store it at CFG.
2970 */
2971
2972 chanNum = psessionEntry->limReassocChannelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07002973 secChannelOffset = psessionEntry->reAssocHtSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002974
2975 /* To Support BT-AMP .. read channel number from psessionEntry*/
2976 //chanNum = psessionEntry->currentOperChannel;
2977
2978 // Apply previously set configuration at HW
2979 limApplyConfiguration(pMac,psessionEntry);
2980
2981 //store the channel switch sessionEntry in the lim global var
2982 /* We have already saved the ReAssocreq Pointer abobe */
2983 //psessionEntry->pLimReAssocReq = (void *)pMlmReassocReq;
2984 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_REASSOC;
2985
Jeff Johnsone7245742012-09-05 17:12:55 -07002986 /** Switch channel to the new Operating channel for Reassoc*/
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302987
2988#ifdef FEATURE_WLAN_DIAG_SUPPORT
2989 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2990 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_REASSOC);
2991#endif
2992
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 limSetChannel(pMac, chanNum, secChannelOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002994
2995 return;
2996 }
2997 else
2998 {
2999 /**
3000 * Received Reassoc request in invalid state or
3001 * in AP role.Return Reassoc confirm with Invalid
3002 * parameters code.
3003 */
3004
3005 // Log error
Abhishek Singhcd09b562013-12-24 16:02:20 +05303006 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303007 FL("received unexpected MLM_REASSOC_CNF in state %d for role=%d, "
Abhishek Singhcd09b562013-12-24 16:02:20 +05303008 "MAC addr= "
3009 MAC_ADDRESS_STR), psessionEntry->limMlmState,
3010 psessionEntry->limSystemRole,
3011 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3013
3014 mlmReassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3015 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3016
3017 goto end;
3018 }
3019
3020end:
3021 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3022 /* Update PE sessio Id*/
3023 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
3024 /// Free up buffer allocated for reassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303025 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 psessionEntry->pLimReAssocReq = NULL;
3027
3028 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3029} /*** limProcessMlmReassocReq() ***/
3030
3031
3032static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003033limProcessMlmDisassocReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003034{
3035 tANI_U16 aid;
3036 tSirMacAddr currentBssId;
3037 tpDphHashNode pStaDs;
3038 tLimMlmDisassocReq *pMlmDisassocReq;
3039 tLimMlmDisassocCnf mlmDisassocCnf;
3040 tpPESession psessionEntry;
3041 extern tANI_BOOLEAN sendDisassocFrame;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303042 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303043 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303044 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003045
3046 if(eHAL_STATUS_SUCCESS != suspendStatus)
3047 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003048 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003049#if 0
3050 //It can ignore the status and proceed with the disassoc processing.
3051 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3052 goto end;
3053#endif
3054 }
3055
3056 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
3057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
3059 {
3060
Abhishek Singhcd09b562013-12-24 16:02:20 +05303061 limLog(pMac, LOGE,
3062 FL("session does not exist for given sessionId %d"),
3063 pMlmDisassocReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3065 goto end;
3066 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303067 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d Systemrole %d"
3068 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3069 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3070 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3071
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 #if 0
3073 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3074 eSIR_SUCCESS)
3075 {
3076 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003077 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 }
3079 #endif //BT-AMP Support
3080 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3081
3082 switch (psessionEntry->limSystemRole)
3083 {
3084 case eLIM_STA_ROLE:
3085 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303086 if ( !vos_mem_compare(pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 currentBssId,
3088 sizeof(tSirMacAddr)) )
3089 {
3090 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303091 FL("received MLM_DISASSOC_REQ with invalid BSS id from: "
3092 MAC_ADDRESS_STR),
3093 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003094
3095 /// Prepare and Send LIM_MLM_DISASSOC_CNF
3096
3097 mlmDisassocCnf.resultCode =
3098 eSIR_SME_INVALID_PARAMETERS;
3099
3100 goto end;
3101 }
3102
3103 break;
3104
3105 case eLIM_STA_IN_IBSS_ROLE:
3106
3107 break;
3108
3109 default: // eLIM_AP_ROLE
3110
3111 // Fall through
3112 break;
3113
3114 } // end switch (psessionEntry->limSystemRole)
3115
3116 /**
3117 * Check if there exists a context for the peer entity
3118 * to be disassociated with.
3119 */
3120 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3121 if ((pStaDs == NULL) ||
3122 (pStaDs &&
3123 ((pStaDs->mlmStaContext.mlmState !=
3124 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3125 (pStaDs->mlmStaContext.mlmState !=
3126 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
3127 (pStaDs->mlmStaContext.mlmState !=
3128 eLIM_MLM_ASSOCIATED_STATE))))
3129 {
3130 /**
3131 * Received LIM_MLM_DISASSOC_REQ for STA that does not
3132 * have context or in some transit state.
3133 * Log error
3134 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303135 limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303136 FL("received MLM_DISASSOC_REQ for STA that either has no context "
3137 "or in some transit state, Addr= "
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303138 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3139 if (pStaDs != NULL)
3140 limLog(pMac, LOGE, FL("Sta MlmState : %d"),
3141 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003142
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303143 /*
3144 * Disassociation response due to
3145 * host triggered disassociation
3146 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303148 pSirSmeDisassocRsp = vos_mem_malloc(sizeof(tSirSmeDisassocRsp));
3149 if ( NULL == pSirSmeDisassocRsp )
3150 {
3151 // Log error
3152 limLog(pMac, LOGP,
3153 FL("call to AllocateMemory failed for eWNI_SME_DISASSOC_RSP"));
3154 return;
3155 }
3156 limLog(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
3157 "retCode: %d for "MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3158 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3159 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
3160 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
3161 pSirSmeDisassocRsp->sessionId = pMlmDisassocReq->sessionId;
3162 pSirSmeDisassocRsp->transactionId = 0;
3163 pSirSmeDisassocRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003164
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303165 pBuf = (tANI_U8 *) pSirSmeDisassocRsp->peerMacAddr;
3166 vos_mem_copy( pBuf, pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr));
3167
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303168 msg.type = eWNI_SME_DISASSOC_RSP;
3169 msg.bodyptr = pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303170
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303171 if (pMac->lim.sme_msg_callback)
3172 pMac->lim.sme_msg_callback(pMac, &msg);
3173 else
3174 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
3175
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303176 return;
3177
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 }
3179
3180 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3181 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3182 pMlmDisassocReq->reasonCode;
3183 pStaDs->mlmStaContext.cleanupTrigger = pMlmDisassocReq->disassocTrigger;
Mukul Sharma91947a22014-06-09 11:07:51 +05303184 /** Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3185 * This is to address the issue of race condition between
3186 * disconnect request from the HDD and deauth from AP
3187 */
3188 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003189
3190 /// Send Disassociate frame to peer entity
Jeff Johnsone7245742012-09-05 17:12:55 -07003191 if (sendDisassocFrame && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003193 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = pMlmDisassocReq;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303194 if (IS_FW_IN_TX_PATH_FEATURE_ENABLE)
Sandeep Puligilla25728282013-12-01 19:44:14 +05303195 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303196 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Sandeep Puligilla25728282013-12-01 19:44:14 +05303197 pMlmDisassocReq->peerMacAddr,
3198 psessionEntry, FALSE);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303199 /* Send Disassoc CNF and receive path cleanup */
3200 limSendDisassocCnf(pMac);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303201 }
3202 else
3203 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303204 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003205 pMlmDisassocReq->peerMacAddr,
3206 psessionEntry, TRUE);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 }
3209 else
3210 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003211 /* Disassoc frame is not sent OTA */
3212 sendDisassocFrame = 1;
3213 // Receive path cleanup with dummy packet
3214 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs,psessionEntry))
3215 {
3216 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3217 goto end;
3218 }
3219 // Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303220 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 return;
3224
3225end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303226 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3227 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3228 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3230 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3231
3232 /* Update PE session ID*/
3233 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3234
3235 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303236 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003237
3238 limPostSmeMessage(pMac,
3239 LIM_MLM_DISASSOC_CNF,
3240 (tANI_U32 *) &mlmDisassocCnf);
3241}
3242
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003243tANI_BOOLEAN limCheckDisassocDeauthAckPending(tpAniSirGlobal pMac,
3244 tANI_U8 *staMac
3245 )
3246{
3247 tLimMlmDisassocReq *pMlmDisassocReq;
3248 tLimMlmDeauthReq *pMlmDeauthReq;
3249 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3250 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3251 if (
3252 (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303253 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003254 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3255 sizeof(tSirMacAddr))))
3256 ||
3257 (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303258 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003259 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303260 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003261 )
3262 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003263 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth ack pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003264 return eANI_BOOLEAN_TRUE;
3265 }
3266 else
3267 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003268 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth Ack not pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003269 return eANI_BOOLEAN_FALSE;
3270 }
3271}
3272
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003273void limCleanUpDisassocDeauthReq(tpAniSirGlobal pMac,
3274 tANI_U8 *staMac,
3275 tANI_BOOLEAN cleanRxPath)
3276{
3277 tLimMlmDisassocReq *pMlmDisassocReq;
3278 tLimMlmDeauthReq *pMlmDeauthReq;
3279 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3280 if (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303281 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003282 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3283 sizeof(tSirMacAddr))))
3284 {
3285 if (cleanRxPath)
3286 {
3287 limProcessDisassocAckTimeout(pMac);
3288 }
3289 else
3290 {
3291 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3292 {
3293 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3294 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303295 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003296 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3297 }
3298 }
3299
3300 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3301 if (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303302 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003303 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
3304 sizeof(tSirMacAddr))))
3305 {
3306 if (cleanRxPath)
3307 {
3308 limProcessDeauthAckTimeout(pMac);
3309 }
3310 else
3311 {
3312 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3313 {
3314 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3315 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303316 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003317 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3318 }
3319 }
3320}
3321
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003322void limProcessDisassocAckTimeout(tpAniSirGlobal pMac)
3323{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303324 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003325 limSendDisassocCnf(pMac);
3326}
3327
Jeff Johnson295189b2012-06-20 16:38:30 -07003328/**
3329 * limProcessMlmDisassocReq()
3330 *
3331 *FUNCTION:
3332 * This function is called to process MLM_DISASSOC_REQ message
3333 * from SME
3334 *
3335 *LOGIC:
3336 *
3337 *ASSUMPTIONS:
3338 *
3339 *NOTE:
3340 *
3341 * @param pMac Pointer to Global MAC structure
3342 * @param *pMsgBuf A pointer to the MLM message buffer
3343 * @return None
3344 */
3345
3346static void
3347limProcessMlmDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3348{
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 tLimMlmDisassocReq *pMlmDisassocReq;
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351 if(pMsgBuf == NULL)
3352 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003353 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 return;
3355 }
3356
3357 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05303358
Abhishek Singhcd09b562013-12-24 16:02:20 +05303359 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d "
3360 "from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3361 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003362
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003363 limProcessMlmDisassocReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003364
Jeff Johnson295189b2012-06-20 16:38:30 -07003365} /*** limProcessMlmDisassocReq() ***/
3366
3367static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003368limProcessMlmDeauthReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369{
3370 tANI_U16 aid;
3371 tSirMacAddr currentBssId;
3372 tpDphHashNode pStaDs;
3373 struct tLimPreAuthNode *pAuthNode;
3374 tLimMlmDeauthReq *pMlmDeauthReq;
3375 tLimMlmDeauthCnf mlmDeauthCnf;
3376 tpPESession psessionEntry;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303377 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
3378 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303379 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003380
3381 if(eHAL_STATUS_SUCCESS != suspendStatus)
3382 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003383 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003384#if 0
3385 //It can ignore the status and proceed with the disassoc processing.
3386 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3387 goto end;
3388#endif
3389 }
3390
3391 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3392
3393 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3394 {
3395
Abhishek Singhcd09b562013-12-24 16:02:20 +05303396 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3397 pMlmDeauthReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303398 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 return;
3400 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303401 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d Systemrole %d"
3402 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3403 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3404 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 #if 0
3406 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3407 eSIR_SUCCESS)
3408 {
3409 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003410 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 }
3412 #endif //SUPPORT BT-AMP
3413 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3414
3415 switch (psessionEntry->limSystemRole)
3416 {
3417 case eLIM_STA_ROLE:
3418 case eLIM_BT_AMP_STA_ROLE:
3419 switch (psessionEntry->limMlmState)
3420 {
3421 case eLIM_MLM_IDLE_STATE:
3422 // Attempting to Deauthenticate
3423 // with a pre-authenticated peer.
3424 // Deauthetiate with peer if there
3425 // exists a pre-auth context below.
3426 break;
3427
3428 case eLIM_MLM_AUTHENTICATED_STATE:
3429 case eLIM_MLM_WT_ASSOC_RSP_STATE:
3430 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303431 if (!vos_mem_compare(pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 currentBssId,
3433 sizeof(tSirMacAddr)) )
3434 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05303435 limLog(pMac, LOGE,
3436 FL("received MLM_DEAUTH_REQ with invalid BSS id "
3437 "Peer MAC: "MAC_ADDRESS_STR " CFG BSSID Addr : "
3438 MAC_ADDRESS_STR),
3439 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr),
3440 MAC_ADDR_ARRAY(currentBssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003441
3442 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3443
3444 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3445
3446 goto end;
3447 }
3448
3449 if ((psessionEntry->limMlmState ==
3450 eLIM_MLM_AUTHENTICATED_STATE) ||
3451 (psessionEntry->limMlmState ==
3452 eLIM_MLM_WT_ASSOC_RSP_STATE))
3453 {
3454 // Send Deauthentication frame
3455 // to peer entity
3456 limSendDeauthMgmtFrame(
3457 pMac,
3458 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003459 pMlmDeauthReq->peerMacAddr,
3460 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461
3462 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3463 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3464 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003465 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 goto end;
3467 }
3468 else
3469 {
3470 // LINK_ESTABLISED_STATE
3471 // Cleanup RX & TX paths
3472 // below
3473 }
3474
3475 break;
3476
3477 default:
3478
3479 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303480 FL("received MLM_DEAUTH_REQ with in state %d for peer "MAC_ADDRESS_STR),
3481 psessionEntry->limMlmState,MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3483
3484 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3485 mlmDeauthCnf.resultCode =
3486 eSIR_SME_STA_NOT_AUTHENTICATED;
3487
3488 goto end;
3489 }
3490
3491 break;
3492
3493 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303494 limLog(pMac, LOGE,
3495 FL("received MLM_DEAUTH_REQ IBSS Mode "));
3496 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3497 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 default: // eLIM_AP_ROLE
3499 break;
3500
3501 } // end switch (psessionEntry->limSystemRole)
3502
3503 /**
3504 * Check if there exists a context for the peer entity
3505 * to be deauthenticated with.
3506 */
3507 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3508
3509 if (pStaDs == NULL)
3510 {
3511 /// Check if there exists pre-auth context for this STA
3512 pAuthNode = limSearchPreAuthList(pMac,
3513 pMlmDeauthReq->peerMacAddr);
3514
3515 if (pAuthNode == NULL)
3516 {
3517 /**
3518 * Received DEAUTH REQ for a STA that is neither
3519 * Associated nor Pre-authenticated. Log error,
3520 * Prepare and Send LIM_MLM_DEAUTH_CNF
3521 */
3522 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303523 FL("received MLM_DEAUTH_REQ in mlme state %d for STA that "
3524 "does not have context, Addr="MAC_ADDRESS_STR),
3525 psessionEntry->limMlmState,
3526 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003527
3528 mlmDeauthCnf.resultCode =
3529 eSIR_SME_STA_NOT_AUTHENTICATED;
3530 }
3531 else
3532 {
3533 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3534
3535 /// Delete STA from pre-auth STA list
3536 limDeletePreAuthNode(pMac, pMlmDeauthReq->peerMacAddr);
3537
3538 /// Send Deauthentication frame to peer entity
3539 limSendDeauthMgmtFrame(pMac,
3540 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003541 pMlmDeauthReq->peerMacAddr,
3542 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 }
3544
3545 goto end;
3546 }
3547 else if ((pStaDs->mlmStaContext.mlmState !=
3548 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3549 (pStaDs->mlmStaContext.mlmState !=
3550 eLIM_MLM_WT_ASSOC_CNF_STATE))
3551 {
3552 /**
3553 * Received LIM_MLM_DEAUTH_REQ for STA that is n
3554 * some transit state. Log error.
3555 */
3556 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303557 FL("received MLM_DEAUTH_REQ for STA that either has no context or in some transit state, Addr="
3558 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003559
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303560 /*
3561 * Deauthentication response to host triggered
3562 * deauthentication.
3563 */
3564 pSirSmeDeauthRsp = vos_mem_malloc(sizeof(tSirSmeDeauthRsp));
3565 if ( NULL == pSirSmeDeauthRsp )
3566 {
3567 // Log error
3568 limLog(pMac, LOGP,
3569 FL("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003570
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303571 return;
3572 }
3573 limLog(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
3574 "retCode: %d for"MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3575 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3576 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
3577 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
3578 pSirSmeDeauthRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
3579 pSirSmeDeauthRsp->sessionId = pMlmDeauthReq->sessionId;
3580 pSirSmeDeauthRsp->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303582 pBuf = (tANI_U8 *) pSirSmeDeauthRsp->peerMacAddr;
3583 vos_mem_copy( pBuf, pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr));
3584
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303585 msg.type = eWNI_SME_DEAUTH_RSP;
3586 msg.bodyptr = pSirSmeDeauthRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303587
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303588 if (pMac->lim.sme_msg_callback)
3589 pMac->lim.sme_msg_callback(pMac, &msg);
3590 else
3591 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303592
3593 return;
3594
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 }
3596
3597 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3598 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3599 pMlmDeauthReq->reasonCode;
3600 pStaDs->mlmStaContext.cleanupTrigger = pMlmDeauthReq->deauthTrigger;
3601
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003602 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = pMlmDeauthReq;
Abhishek Singh94152932014-01-16 19:04:51 +05303603
3604 /* Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3605 * This is to address the issue of race condition between
3606 * disconnect request from the HDD and disassoc from
3607 * inactivity timer. This will make sure that we will not
3608 * process disassoc if deauth is in progress for the station
3609 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
3610 */
3611 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
3612
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 /// Send Deauthentication frame to peer entity
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303614 /* If FW_IN_TX_PATH feature is enabled
3615 do not wait for ACK */
3616 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3617 {
3618 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3619 pMlmDeauthReq->peerMacAddr,
3620 psessionEntry, FALSE);
3621
3622 /* Send Deauth CNF and receive path cleanup */
3623 limSendDeauthCnf(pMac);
3624 }
3625 else
3626 {
3627 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3628 pMlmDeauthReq->peerMacAddr,
3629 psessionEntry, TRUE);
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631
3632 return;
3633
3634end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303635 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3636 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3637 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3639 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3640 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3641
3642 // Free up buffer allocated
3643 // for mlmDeauthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303644 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645
3646 limPostSmeMessage(pMac,
3647 LIM_MLM_DEAUTH_CNF,
3648 (tANI_U32 *) &mlmDeauthCnf);
3649
3650}
3651
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003652
3653void limProcessDeauthAckTimeout(tpAniSirGlobal pMac)
3654{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303655 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003656 limSendDeauthCnf(pMac);
3657}
3658
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303659void lim_process_ap_ecsa_timeout(tpAniSirGlobal mac_ctx)
3660{
3661 tSirMsgQ msg = {0};
3662 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
3663 tpPESession session;
3664
3665 session = peFindSessionBySessionId(mac_ctx,
3666 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3667
3668 if(!session)
3669 {
3670 limLog(mac_ctx, LOGE, FL("session does not exist for given sessionId %d"),
3671 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3672 return;
3673 }
3674 limLog(mac_ctx, LOG1, FL("session id %d switch count %d"),
3675 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId,
3676 session->gLimChannelSwitch.switchCount);
3677 /*
3678 * For each beacon interval decrement switch count to use proper value
3679 * in probe resp sent by host. Once it becomes 0 send tx complete
3680 * indication to SME.
3681 */
3682 if (session->gLimChannelSwitch.switchCount > 0) {
3683 session->gLimChannelSwitch.switchCount--;
Abhishek Singh449c5372017-12-19 17:21:20 +05303684 lim_send_chan_switch_action_frame(mac_ctx,
3685 session->gLimChannelSwitch.primaryChannel, session);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303686 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
3687 session->peSessionId;
3688 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
3689
3690 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
3691 TX_SUCCESS)
3692 {
3693 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
3694 lim_process_ap_ecsa_timeout(mac_ctx);
3695 }
3696 return;
3697 }
3698
3699 session->include_ecsa_ie = false;
3700 session->include_wide_ch_bw_ie = false;
3701
3702 ecsa_ie_cmp_ind = vos_mem_malloc(sizeof(*ecsa_ie_cmp_ind));
3703 if(!ecsa_ie_cmp_ind)
3704 {
3705 limLog(mac_ctx, LOGE, FL("failed to allocate ecsa_ie_cmp_ind"));
3706 return;
3707 }
3708 ecsa_ie_cmp_ind->session_id = session->smeSessionId;
3709
3710 msg.type = eWNI_SME_ECSA_IE_BEACON_COMP_IND;
3711 msg.bodyptr = ecsa_ie_cmp_ind;
3712 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3713 return;
3714}
3715
3716void lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal mac_ctx,
3717 tpPESession session, tpSwitchChannelParams chan_params)
3718{
3719 tSirMsgQ msg = {0};
3720 struct sir_channel_chanege_rsp *params;
3721
3722 params = vos_mem_malloc(sizeof(*params));
3723 if (!params) {
3724 limLog(mac_ctx, LOGE, FL("AllocateMemory failed for pSmeSwithChnlParams"));
3725 return;
3726 }
3727
3728 params->sme_session_id = session->smeSessionId;
3729 params->new_channel = chan_params->channelNumber;
3730 params->status = chan_params->status;
3731
3732 msg.type = eWNI_SME_ECSA_CHAN_CHANGE_RSP;
3733 msg.bodyptr = params;
3734 msg.bodyval = 0;
3735 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3736
3737 if (chan_params->channelNumber == session->currentOperChannel) {
3738 limApplyConfiguration(mac_ctx, session);
3739 limSendBeaconInd(mac_ctx, session);
3740 } else {
3741 limLog(mac_ctx, LOGE, FL("channel switch resp chan %d and session channel doesnt match %d"),
3742 chan_params->channelNumber, session->currentOperChannel);
3743 }
3744
3745 return;
3746}
3747
3748
Jeff Johnson295189b2012-06-20 16:38:30 -07003749/**
3750 * limProcessMlmDeauthReq()
3751 *
3752 *FUNCTION:
3753 * This function is called to process MLM_DEAUTH_REQ message
3754 * from SME
3755 *
3756 *LOGIC:
3757 *
3758 *ASSUMPTIONS:
3759 *
3760 *NOTE:
3761 *
3762 * @param pMac Pointer to Global MAC structure
3763 * @param *pMsgBuf A pointer to the MLM message buffer
3764 * @return None
3765 */
3766
3767static void
3768limProcessMlmDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3769{
3770// tANI_U16 aid;
3771// tSirMacAddr currentBssId;
3772// tpDphHashNode pStaDs;
3773// struct tLimPreAuthNode *pAuthNode;
3774 tLimMlmDeauthReq *pMlmDeauthReq;
3775// tLimMlmDeauthCnf mlmDeauthCnf;
3776 tpPESession psessionEntry;
3777
3778 if(pMsgBuf == NULL)
3779 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003780 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 return;
3782 }
3783
3784 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3785
Abhishek Singhcd09b562013-12-24 16:02:20 +05303786 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d "
3787 "from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3788 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3791 {
3792
Abhishek Singhcd09b562013-12-24 16:02:20 +05303793 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3794 pMlmDeauthReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 return;
3796 }
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003797 limProcessMlmDeauthReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
3798
Jeff Johnson295189b2012-06-20 16:38:30 -07003799} /*** limProcessMlmDeauthReq() ***/
3800
3801
3802
3803/**
3804 * @function : limProcessMlmSetKeysReq()
3805 *
3806 * @brief : This function is called to process MLM_SETKEYS_REQ message
3807 * from SME
3808 *
3809 *LOGIC:
3810 *
3811 *ASSUMPTIONS:
3812 *
3813 *NOTE:
3814 *
3815 * @param pMac Pointer to Global MAC structure
3816 * @param *pMsgBuf A pointer to the MLM message buffer
3817 * @return None
3818 */
3819
3820static void
3821limProcessMlmSetKeysReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3822{
3823tANI_U16 aid;
3824tANI_U16 staIdx = 0;
3825tANI_U32 defaultKeyId = 0;
3826tSirMacAddr currentBssId;
3827tpDphHashNode pStaDs;
3828tLimMlmSetKeysReq *pMlmSetKeysReq;
3829tLimMlmSetKeysCnf mlmSetKeysCnf;
3830tpPESession psessionEntry;
3831
3832 if(pMsgBuf == NULL)
3833 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003834 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 return;
3836 }
3837
3838
3839 pMlmSetKeysReq = (tLimMlmSetKeysReq *) pMsgBuf;
3840 // Hold onto the SetKeys request parameters
3841 pMac->lim.gpLimMlmSetKeysReq = (void *) pMlmSetKeysReq;
3842
3843 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmSetKeysReq->sessionId))== NULL)
3844 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003845 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 return;
3847 }
3848
3849 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003850 FL( "Received MLM_SETKEYS_REQ with parameters:"
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "),
3852 pMlmSetKeysReq->aid,
3853 pMlmSetKeysReq->edType,
3854 pMlmSetKeysReq->numKeys );
3855 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3856
3857 #if 0
3858 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, currentBssId, &cfg )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003859 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 return;
3861 }
3862 #endif //TO SUPPORT BT-AMP
3863 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3864
3865 switch( psessionEntry->limSystemRole ) {
3866 case eLIM_STA_ROLE:
3867 case eLIM_BT_AMP_STA_ROLE:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003868 //In case of TDLS, peerMac address need not be BssId. Skip this check
3869 //if TDLS is enabled.
3870#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 if((!limIsAddrBC( pMlmSetKeysReq->peerMacAddr ) ) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303872 (!vos_mem_compare(pMlmSetKeysReq->peerMacAddr,
3873 currentBssId, sizeof(tSirMacAddr))) ){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003874 limLog( pMac, LOGW, FL("Received MLM_SETKEYS_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3876
3877 // Prepare and Send LIM_MLM_SETKEYS_CNF with error code
3878 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3879 goto end;
3880 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003881#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 // Fall thru' & 'Plumb' keys below
3883 break;
3884 case eLIM_STA_IN_IBSS_ROLE:
3885 default: // others
3886 // Fall thru...
3887 break;
3888 }
3889
3890 /**
3891 * Use the "unicast" parameter to determine if the "Group Keys"
3892 * are being set.
3893 * pMlmSetKeysReq->key.unicast = 0 -> Multicast/broadcast
3894 * pMlmSetKeysReq->key.unicast - 1 -> Unicast keys are being set
3895 */
3896 if( limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003897 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "), pMlmSetKeysReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 /** When trying to set Group Keys for any
3899 * security mode other than WEP, use the
3900 * STA Index corresponding to the AP...
3901 */
3902 switch( pMlmSetKeysReq->edType ) {
3903 case eSIR_ED_CCMP:
3904
3905#ifdef WLAN_FEATURE_11W
3906 case eSIR_ED_AES_128_CMAC:
3907#endif
3908 staIdx = psessionEntry->staId;
3909 break;
3910
3911 default:
3912 break;
3913 }
3914 }else {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003915 limLog( pMac, LOG1, FL("Trying to set Unicast Keys..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 /**
3917 * Check if there exists a context for the
3918 * peer entity for which keys need to be set.
3919 */
3920
3921
3922 pStaDs = dphLookupHashEntry( pMac, pMlmSetKeysReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
3923
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 if ((pStaDs == NULL) ||
3925 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) && (psessionEntry->limSystemRole != eLIM_AP_ROLE))) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 /**
3927 * Received LIM_MLM_SETKEYS_REQ for STA
3928 * that does not have context or in some
3929 * transit state. Log error.
3930 */
3931 limLog( pMac, LOG1,
3932 FL("Received MLM_SETKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3933 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3934
3935 // Prepare and Send LIM_MLM_SETKEYS_CNF
3936 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3937 goto end;
3938 } else
3939 staIdx = pStaDs->staIndex;
3940 }
3941
3942 if ((pMlmSetKeysReq->numKeys == 0) && (pMlmSetKeysReq->edType != eSIR_ED_NONE)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003943 //
3944 // Broadcast/Multicast Keys (for WEP!!) are NOT sent
3945 // via this interface!!
3946 //
3947 // This indicates to HAL that the WEP Keys need to be
3948 // extracted from the CFG and applied to hardware
3949 defaultKeyId = 0xff;
3950 }else if(pMlmSetKeysReq->key[0].keyId &&
3951 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
3952 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))){
3953 /* If the Key Id is non zero and encryption mode is WEP,
3954 * the key index is coming from the upper layers so that key only
3955 * need to be used as the default tx key, This is being used only
3956 * in case of WEP mode in HAL */
3957 defaultKeyId = pMlmSetKeysReq->key[0].keyId;
3958 }else
3959 defaultKeyId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003960
3961 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003962 FL( "Trying to set keys for STA Index [%d], using defaultKeyId [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 staIdx,
3964 defaultKeyId );
3965
3966 if(limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
3967 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3968 psessionEntry->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003969 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003970 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 psessionEntry->peSessionId);
3972
3973 // Package WDA_SET_BSSKEY_REQ message parameters
3974 limSendSetBssKeyReq(pMac, pMlmSetKeysReq,psessionEntry);
3975 return;
3976 }else {
3977 // Package WDA_SET_STAKEY_REQ / WDA_SET_STA_BCASTKEY_REQ message parameters
3978 limSendSetStaKeyReq(pMac, pMlmSetKeysReq, staIdx, (tANI_U8) defaultKeyId,psessionEntry);
3979 return;
3980 }
3981
3982end:
3983 mlmSetKeysCnf.sessionId= pMlmSetKeysReq->sessionId;
3984 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
3985
3986} /*** limProcessMlmSetKeysReq() ***/
3987
3988/**
3989 * limProcessMlmRemoveKeyReq()
3990 *
3991 *FUNCTION:
3992 * This function is called to process MLM_REMOVEKEY_REQ message
3993 * from SME
3994 *
3995 *LOGIC:
3996 *
3997 *ASSUMPTIONS:
3998 *
3999 *NOTE:
4000 *
4001 * @param pMac Pointer to Global MAC structure
4002 * @param *pMsgBuf A pointer to the MLM message buffer
4003 * @return None
4004 */
4005
4006static void
4007limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4008{
4009tANI_U16 aid;
4010tANI_U16 staIdx = 0;
4011tSirMacAddr currentBssId;
4012tpDphHashNode pStaDs;
4013tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
4014tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
4015 tpPESession psessionEntry;
4016
4017 if(pMsgBuf == NULL)
4018 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004019 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 return;
4021 }
4022
4023 pMlmRemoveKeyReq = (tLimMlmRemoveKeyReq *) pMsgBuf;
4024
4025
4026 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyReq->sessionId))== NULL)
4027 {
4028 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004029 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304030 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 return;
4032 }
4033
4034
4035 if( pMac->lim.gpLimMlmRemoveKeyReq != NULL )
4036 {
4037 // Free any previous requests.
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304038 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
4040 }
4041 // Hold onto the RemoveKeys request parameters
4042 pMac->lim.gpLimMlmRemoveKeyReq = (void *) pMlmRemoveKeyReq;
4043
4044 #if 0
4045 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
4046 WNI_CFG_BSSID,
4047 currentBssId,
4048 &cfg ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004049 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 #endif //TO-SUPPORT BT-AMP
4051 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
4052
4053 switch( psessionEntry->limSystemRole )
4054 {
4055 case eLIM_STA_ROLE:
4056 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304057 if (( limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr ) != true ) &&
4058 (!vos_mem_compare(pMlmRemoveKeyReq->peerMacAddr,
4059 currentBssId,
4060 sizeof(tSirMacAddr))))
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 {
4062 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004063 FL("Received MLM_REMOVEKEY_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
4065
4066 // Prepare and Send LIM_MLM_REMOVEKEY_CNF with error code
4067 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4068 goto end;
4069 }
4070 break;
4071
4072 case eLIM_STA_IN_IBSS_ROLE:
4073 default: // eLIM_AP_ROLE
4074 // Fall thru...
4075 break;
4076 }
4077
4078
4079 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
4080 if(limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr )) //Second condition for IBSS or AP role.
4081 {
4082 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004083 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 // Package WDA_REMOVE_BSSKEY_REQ message parameters
4085 limSendRemoveBssKeyReq( pMac,pMlmRemoveKeyReq,psessionEntry);
4086 return;
4087 }
4088
4089 /**
4090 * Check if there exists a context for the
4091 * peer entity for which keys need to be removed.
4092 */
4093 pStaDs = dphLookupHashEntry( pMac, pMlmRemoveKeyReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4094 if ((pStaDs == NULL) ||
4095 (pStaDs &&
4096 (pStaDs->mlmStaContext.mlmState !=
4097 eLIM_MLM_LINK_ESTABLISHED_STATE)))
4098 {
4099 /**
4100 * Received LIM_MLM_REMOVEKEY_REQ for STA
4101 * that does not have context or in some
4102 * transit state. Log error.
4103 */
4104 limLog( pMac, LOGW,
4105 FL("Received MLM_REMOVEKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
4106 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
4107
4108 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
4109 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4110 mlmRemoveKeyCnf.sessionId = pMlmRemoveKeyReq->sessionId;
4111
4112
4113 goto end;
4114 }
4115 else
4116 staIdx = pStaDs->staIndex;
4117
4118
4119
4120 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004121 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004122
4123 // Package WDA_REMOVE_STAKEY_REQ message parameters
4124 limSendRemoveStaKeyReq( pMac,pMlmRemoveKeyReq,staIdx,psessionEntry);
4125 return;
4126
4127end:
4128 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07004129 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 pMlmRemoveKeyReq,
4131 &mlmRemoveKeyCnf );
4132
4133} /*** limProcessMlmRemoveKeyReq() ***/
4134
4135
4136/**
4137 * limProcessMinChannelTimeout()
4138 *
4139 *FUNCTION:
4140 * This function is called to process Min Channel Timeout
4141 * during channel scan.
4142 *
4143 *LOGIC:
4144 *
4145 *ASSUMPTIONS:
4146 *
4147 *NOTE:
4148 *
4149 * @param pMac Pointer to Global MAC structure
4150 * @return None
4151 */
4152
4153static void
4154limProcessMinChannelTimeout(tpAniSirGlobal pMac)
4155{
4156 tANI_U8 channelNum;
4157
4158#ifdef GEN6_TODO
4159 //if the min Channel is maintained per session, then use the below seesionEntry
4160 //priority - LOW/might not be needed
4161
4162 //TBD-RAJESH HOW TO GET sessionEntry?????
4163 tpPESession psessionEntry;
4164
4165 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimMinChannelTimer.sessionId))== NULL)
4166 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004167 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 return;
4169 }
4170#endif
4171
Abhishek Singh89e1d672013-11-28 15:13:42 +05304172 /*do not process if we are in finish scan wait state i.e.
4173 scan is aborted or finished*/
4174 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE &&
4175 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 /// Min channel timer timed out
4178 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
4179 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
4180 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05304181 /*
4182 * Deactivate Max Channel timer as well since no probe resp/beacons
4183 * are received.
4184 */
4185 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004186 pMac->lim.probeCounter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 if (pMac->lim.gLimCurrentScanChannelId <=
4188 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4189 {
4190 channelNum = (tANI_U8)limGetCurrentScanChannel(pMac);
4191 }
4192 else
4193 {
4194 // This shouldn't be the case, but when this happens, this timeout should be for the last channelId.
4195 // Get the channelNum as close to correct as possible.
4196 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4197 {
4198 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4199 }
4200 else
4201 {
4202 channelNum = 1;
4203 }
4204 }
4205
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004206 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304207 FL("Sending End Scan req from MIN_CH_TIMEOUT in state %d ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004208 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4210 }
4211 else
4212 {
4213 /**
4214 * MIN channel timer should not have timed out
4215 * in states other than wait_probe_response.
4216 * Log error.
4217 */
4218 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304219 FL("received unexpected MIN channel timeout in mlme state %d and hal scan State %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304220 pMac->lim.gLimMlmState,pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 limPrintMlmState(pMac, LOGE, pMac->lim.gLimMlmState);
4222 }
4223} /*** limProcessMinChannelTimeout() ***/
4224
4225
4226
4227/**
4228 * limProcessMaxChannelTimeout()
4229 *
4230 *FUNCTION:
4231 * This function is called to process Max Channel Timeout
4232 * during channel scan.
4233 *
4234 *LOGIC:
4235 *
4236 *ASSUMPTIONS:
4237 *
4238 *NOTE:
4239 *
4240 * @param pMac Pointer to Global MAC structure
4241 * @return None
4242 */
4243
4244static void
4245limProcessMaxChannelTimeout(tpAniSirGlobal pMac)
4246{
4247 tANI_U8 channelNum;
4248
Abhishek Singh89e1d672013-11-28 15:13:42 +05304249 /*do not process if we are in finish scan wait state i.e.
4250 scan is aborted or finished*/
4251 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE ||
4252 pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE) &&
4253 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304255 limLog(pMac, LOG1, FL("Scanning : Max channel timed out"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 /**
4257 * MAX channel timer timed out
4258 * Continue channel scan.
4259 */
4260 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
4261 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
4262 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004263 pMac->lim.probeCounter = 0;
4264
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004265 if (pMac->lim.gLimCurrentScanChannelId <=
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4267 {
4268 channelNum = limGetCurrentScanChannel(pMac);
4269 }
4270 else
4271 {
4272 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4273 {
4274 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4275 }
4276 else
4277 {
4278 channelNum = 1;
4279 }
4280 }
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004281 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304282 FL("Sending End Scan req from MAX_CH_TIMEOUT in state %d on ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004283 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4285 }
4286 else
4287 {
4288 /**
4289 * MAX channel timer should not have timed out
4290 * in states other than wait_scan.
4291 * Log error.
4292 */
4293 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304294 FL("received unexpected MAX channel timeout in mlme state %d and hal scan state %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304295 pMac->lim.gLimMlmState, pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
4297 }
4298} /*** limProcessMaxChannelTimeout() ***/
4299
4300/**
4301 * limProcessPeriodicProbeReqTimer()
4302 *
4303 *FUNCTION:
4304 * This function is called to process periodic probe request
4305 * to send during scan.
4306 *
4307 *LOGIC:
4308 *
4309 *ASSUMPTIONS:
4310 *
4311 *NOTE:
4312 *
4313 * @param pMac Pointer to Global MAC structure
4314 * @return None
4315 */
4316
4317static void
4318limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac)
4319{
4320 tANI_U8 channelNum;
4321 tANI_U8 i = 0;
4322 tSirRetStatus status = eSIR_SUCCESS;
4323 TX_TIMER *pPeriodicProbeReqTimer;
4324 pPeriodicProbeReqTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
4325
4326 if(vos_timer_getCurrentState(&pPeriodicProbeReqTimer->vosTimer)
4327 != VOS_TIMER_STATE_STOPPED)
4328 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304329 limLog(pMac, LOG1, FL("Invalid state of timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 return;
4331 }
4332
4333 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004334 (pPeriodicProbeReqTimer->sessionId != 0xff) && (pMac->lim.probeCounter < pMac->lim.maxProbe))
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 {
4336 tLimMlmScanReq *pLimMlmScanReq = pMac->lim.gpLimMlmScanReq;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004337 pMac->lim.probeCounter++;
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 /**
4339 * Periodic channel timer timed out
4340 * to send probe request.
4341 */
4342 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +05304343 /* Prepare and send Probe Request frame for all the SSIDs
4344 * present in the saved MLM
4345 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 do
4347 {
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304348 tSirMacAddr gSelfMacAddr;
4349 bool spoof = lim_is_spoofing_needed(pMac);
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304350
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304351 if (spoof)
4352 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr,
4353 VOS_MAC_ADDRESS_LEN);
4354 else
4355 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr,
4356 VOS_MAC_ADDRESS_LEN);
4357
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304358 limLog( pMac, LOG1, FL("Mac Addr used in Probe Req is :"MAC_ADDRESS_STR),
4359 MAC_ADDR_ARRAY(gSelfMacAddr));
4360
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 /*
4362 * PELOGE(limLog(pMac, LOGW, FL("sending ProbeReq number %d,"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004363 * " for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 * i, pLimMlmScanReq->ssId[i].ssId,
4365 * channelNum);)
4366 */
4367 status = limSendProbeReqMgmtFrame( pMac, &pLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304368 pLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 pLimMlmScanReq->dot11mode, pLimMlmScanReq->uIEFieldLen,
4370 (tANI_U8 *)(pLimMlmScanReq) + pLimMlmScanReq->uIEFieldOffset);
4371
4372
4373 if ( status != eSIR_SUCCESS)
4374 {
4375 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004376 "%s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 pLimMlmScanReq->ssId[i].ssId,
4378 channelNum);)
4379 return;
4380 }
4381 i++;
4382 } while (i < pLimMlmScanReq->numSsid);
4383
4384 /* Activate timer again */
4385 if (tx_timer_activate(pPeriodicProbeReqTimer) != TX_SUCCESS)
4386 {
4387 limLog(pMac, LOGP, FL("could not start periodic probe"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004388 " req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 return;
4390 }
4391 }
4392 else
4393 {
4394 /**
4395 * Periodic scan is timeout is happening in
4396 * in states other than wait_scan.
4397 * Log error.
4398 */
Mohit Khanna23863762012-09-11 17:40:09 -07004399 limLog(pMac, LOG1,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304400 FL("received unexpected Periodic scan timeout in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 pMac->lim.gLimMlmState);
4402 }
4403} /*** limProcessPeriodicProbeReqTimer() ***/
4404
4405/**
4406 * limProcessJoinFailureTimeout()
4407 *
4408 *FUNCTION:
4409 * This function is called to process JoinFailureTimeout
4410 *
4411 *LOGIC:
4412 *
4413 *ASSUMPTIONS:
4414 *
4415 *NOTE:
4416 *
4417 * @param pMac Pointer to Global MAC structure
4418 * @return None
4419 */
4420
4421static void
4422limProcessJoinFailureTimeout(tpAniSirGlobal pMac)
4423{
4424 tLimMlmJoinCnf mlmJoinCnf;
4425 tSirMacAddr bssid;
4426 tANI_U32 len;
krunal soni8d13b092013-07-19 13:23:29 -07004427#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4428 vos_log_rssi_pkt_type *pRssiLog = NULL;
4429#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004430
4431 //fetch the sessionEntry based on the sessionId
4432 tpPESession psessionEntry;
4433
4434 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimJoinFailureTimer.sessionId))== NULL)
4435 {
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07004436 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 return;
4438 }
krunal soni8d13b092013-07-19 13:23:29 -07004439
4440#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4441 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4442 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4443 if (pRssiLog)
4444 {
4445 pRssiLog->rssi = psessionEntry->rssi;
4446 }
4447 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4448#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4449
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
4451 {
4452 len = sizeof(tSirMacAddr);
4453
4454 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, bssid, &len) !=
4455 eSIR_SUCCESS)
4456 {
4457 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004458 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 return;
4460 }
4461
4462 // 'Change' timer for future activations
4463 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004464 // Change Periodic probe req timer for future activation
4465 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 /**
4467 * Issue MLM join confirm with timeout reason code
4468 */
Kiet Lam82004c62013-11-11 13:24:28 +05304469 PELOGE(limLog(pMac, LOGE, FL(" In state eLIM_MLM_WT_JOIN_BEACON_STATE."));)
4470 PELOGE(limLog(pMac, LOGE, FL(" Join Failure Timeout occurred for session %d with BSS "),
4471 psessionEntry->peSessionId);
4472 limPrintMacAddr(pMac, psessionEntry->bssId, LOGE);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004473
4474 mlmJoinCnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
4475 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4476
4477 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004478 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
4480 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004481 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 /* Update PE session Id */
4483 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
4484
4485
4486 // Freeup buffer allocated to join request
4487 if (psessionEntry->pLimMlmJoinReq)
4488 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304489 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 psessionEntry->pLimMlmJoinReq = NULL;
4491 }
4492
4493 limPostSmeMessage(pMac,
4494 LIM_MLM_JOIN_CNF,
4495 (tANI_U32 *) &mlmJoinCnf);
4496
4497 return;
4498 }
4499 else
4500 {
4501 /**
4502 * Join failure timer should not have timed out
4503 * in states other than wait_join_beacon state.
4504 * Log error.
4505 */
4506 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304507 FL("received unexpected JOIN failure timeout in state %d"),psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4509 }
4510} /*** limProcessJoinFailureTimeout() ***/
4511
4512
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004513/**
4514 * limProcessPeriodicJoinProbeReqTimer()
4515 *
4516 *FUNCTION:
4517 * This function is called to process periodic probe request
4518 * send during joining process.
4519 *
4520 *LOGIC:
4521 *
4522 *ASSUMPTIONS:
4523 *
4524 *NOTE:
4525 *
4526 * @param pMac Pointer to Global MAC structure
4527 * @return None
4528 */
4529
4530static void limProcessPeriodicJoinProbeReqTimer(tpAniSirGlobal pMac)
4531{
4532 tpPESession psessionEntry;
4533 tSirMacSSid ssId;
4534
4535 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId))== NULL)
4536 {
Kiet Lam82004c62013-11-11 13:24:28 +05304537 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4538 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004539 return;
4540 }
4541
4542 if((VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)) &&
4543 (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE))
4544 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304545 vos_mem_copy(ssId.ssId,
4546 psessionEntry->ssId.ssId,
4547 psessionEntry->ssId.length);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004548 ssId.length = psessionEntry->ssId.length;
4549
4550 limSendProbeReqMgmtFrame( pMac, &ssId,
4551 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
4552 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
4553 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
4554
4555 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
4556
4557 // Activate Join Periodic Probe Req timer
4558 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
4559 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004560 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer"));
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004561 return;
4562 }
4563 }
4564 return;
4565} /*** limProcessPeriodicJoinProbeReqTimer() ***/
4566
Sushant Kaushik9e923872015-04-02 17:09:31 +05304567/**
4568 * limProcessAuthRetryTimer()
4569 *
4570 *FUNCTION:
4571 * This function is called to process Auth Retry request
4572 * send during joining process.
4573 *
4574 *LOGIC:
4575 *
4576 *ASSUMPTIONS:
4577 *
4578 *NOTE:
4579 *
4580 * @param pMac Pointer to Global MAC structure
4581 * @return None
4582 */
4583
4584static void limProcessAuthRetryTimer(tpAniSirGlobal pMac)
4585{
4586 tpPESession psessionEntry;
4587 limLog(pMac, LOG1, FL(" ENTER "));
4588 if ((psessionEntry =
4589 peFindSessionBySessionId(pMac,
4590 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId)) == NULL)
4591 {
4592 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4593 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId);
4594 return;
4595 }
4596
4597 if ((VOS_TRUE ==
4598 tx_timer_running(&pMac->lim.limTimers.gLimAuthFailureTimer)) &&
4599 (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
4600 (LIM_AUTH_ACK_RCD_SUCCESS != pMac->authAckStatus))
4601 {
4602 tSirMacAuthFrameBody authFrameBody;
4603
4604 /* Send the auth retry only in case we have received ack failure
4605 * else just restart the retry timer.
4606 */
4607 if (LIM_AUTH_ACK_RCD_FAILURE == pMac->authAckStatus)
4608 {
4609 /// Prepare & send Authentication frame
4610 authFrameBody.authAlgoNumber =
4611 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
4612 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
4613 authFrameBody.authStatusCode = 0;
4614 limLog(pMac, LOGW, FL("Retry Auth "));
4615 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
4616 limSendAuthMgmtFrame(pMac,
4617 &authFrameBody,
4618 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
4619 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
4620 }
4621
4622 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
4623
4624 // Activate Auth Retry timer
4625 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
4626 != TX_SUCCESS)
4627 {
4628 limLog(pMac, LOGE,
4629 FL("could not activate Auth Retry failure timer"));
4630 return;
4631 }
4632 }
4633 return;
4634} /*** limProcessAuthRetryTimer() ***/
4635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636
4637/**
4638 * limProcessAuthFailureTimeout()
4639 *
4640 *FUNCTION:
4641 * This function is called to process Min Channel Timeout
4642 * during channel scan.
4643 *
4644 *LOGIC:
4645 *
4646 *ASSUMPTIONS:
4647 *
4648 *NOTE:
4649 *
4650 * @param pMac Pointer to Global MAC structure
4651 * @return None
4652 */
4653
4654static void
4655limProcessAuthFailureTimeout(tpAniSirGlobal pMac)
4656{
4657 //fetch the sessionEntry based on the sessionId
4658 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004659#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4660 vos_log_rssi_pkt_type *pRssiLog = NULL;
4661#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAuthFailureTimer.sessionId))== NULL)
4663 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004664 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 return;
4666 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304667 limLog(pMac, LOGE, FL("received AUTH failure timeout in sessionid %d "
Sushant Kaushik1b645382014-10-13 16:39:36 +05304668 "limMlmstate %d limSmeState %d"), psessionEntry->peSessionId,
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304669 psessionEntry->limMlmState, psessionEntry->limSmeState);
krunal soni8d13b092013-07-19 13:23:29 -07004670#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4671 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4672 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4673 if (pRssiLog)
4674 {
4675 pRssiLog->rssi = psessionEntry->rssi;
4676 }
4677 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4678#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4679
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 switch (psessionEntry->limMlmState)
4681 {
4682 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
4683 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
4684 /**
4685 * Requesting STA did not receive next auth frame
4686 * before Auth Failure timeout.
4687 * Issue MLM auth confirm with timeout reason code
4688 */
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08004689 //Restore default failure timeout
4690 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
4691 {
4692 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
4693 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
4694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 limRestoreFromAuthState(pMac,eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
4696 break;
4697
4698 default:
4699 /**
4700 * Auth failure timer should not have timed out
4701 * in states other than wt_auth_frame2/4
4702 * Log error.
4703 */
Sushant Kaushik1b645382014-10-13 16:39:36 +05304704 PELOGE(limLog(pMac, LOGE, FL("received unexpected AUTH failure timeout in state %d"), psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
4706
4707 break;
4708 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304709 /* Reinit scan results to remove the unreachable BSS */
4710 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711} /*** limProcessAuthFailureTimeout() ***/
4712
4713
4714
4715/**
4716 * limProcessAuthRspTimeout()
4717 *
4718 *FUNCTION:
4719 * This function is called to process Min Channel Timeout
4720 * during channel scan.
4721 *
4722 *LOGIC:
4723 *
4724 *ASSUMPTIONS:
4725 *
4726 *NOTE:
4727 *
4728 * @param pMac Pointer to Global MAC structure
4729 * @return None
4730 */
4731
4732static void
4733limProcessAuthRspTimeout(tpAniSirGlobal pMac, tANI_U32 authIndex)
4734{
4735 struct tLimPreAuthNode *pAuthNode;
4736 tpPESession psessionEntry;
4737 tANI_U8 sessionId;
4738
4739 pAuthNode = limGetPreAuthNodeFromIndex(pMac, &pMac->lim.gLimPreAuthTimerTable, authIndex);
4740
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304741 if (NULL == pAuthNode)
4742 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004743 limLog(pMac, LOGW, FL("Invalid auth node"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304744 return;
4745 }
4746
4747 if ((psessionEntry = peFindSessionByBssid(pMac, pAuthNode->peerMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004749 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 return;
4751 }
4752
4753 if (psessionEntry->limSystemRole == eLIM_AP_ROLE ||
4754 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
4755 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304756 if (pAuthNode->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 {
4758 /**
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304759 * Authentication response timer timedout
4760 * in unexpected state. Log error
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 */
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304762 PELOGE(limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304763 FL("received AUTH rsp timeout in unexpected state "
4764 "for MAC address: "MAC_ADDRESS_STR),
4765 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 }
4767 else
4768 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304769 // Authentication response timer
4770 // timedout for an STA.
4771 pAuthNode->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
4772 pAuthNode->fTimerStarted = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304773 limLog(pMac, LOG1,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304774 FL("AUTH rsp timedout for MAC address "MAC_ADDRESS_STR),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304775 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004776
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304777 // Change timer to reactivate it in future
4778 limDeactivateAndChangePerStaIdTimer(pMac,
4779 eLIM_AUTH_RSP_TIMER,
4780 pAuthNode->authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004781
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304782 limDeletePreAuthNode(pMac, pAuthNode->peerMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 }
4784 }
4785} /*** limProcessAuthRspTimeout() ***/
4786
4787
4788/**
4789 * limProcessAssocFailureTimeout()
4790 *
4791 *FUNCTION:
4792 * This function is called to process Min Channel Timeout
4793 * during channel scan.
4794 *
4795 *LOGIC:
4796 *
4797 *ASSUMPTIONS:
4798 *
4799 *NOTE:
4800 *
4801 * @param pMac Pointer to Global MAC structure
4802 * @return None
4803 */
4804
4805static void
4806limProcessAssocFailureTimeout(tpAniSirGlobal pMac, tANI_U32 MsgType)
4807{
4808
4809 tLimMlmAssocCnf mlmAssocCnf;
4810 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004811#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4812 vos_log_rssi_pkt_type *pRssiLog = NULL;
4813#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004814
4815 //to fetch the lim/mlm state based on the sessionId, use the below sessionEntry
4816 tANI_U8 sessionId;
4817
4818 if(MsgType == LIM_ASSOC)
4819 {
4820 sessionId = pMac->lim.limTimers.gLimAssocFailureTimer.sessionId;
4821 }
4822 else
4823 {
4824 sessionId = pMac->lim.limTimers.gLimReassocFailureTimer.sessionId;
4825 }
4826
4827 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
4828 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004829 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 return;
4831 }
krunal soni8d13b092013-07-19 13:23:29 -07004832#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4833 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4834 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4835 if (pRssiLog)
4836 {
4837 pRssiLog->rssi = psessionEntry->rssi;
4838 }
4839 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4840#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 /**
4843 * Expected Re/Association Response frame
4844 * not received within Re/Association Failure Timeout.
4845 */
4846
4847
4848
4849
Abhishek Singh70af9c72016-03-09 17:23:30 +05304850 /*
4851 * CR: vos packet memory is leaked when assoc rsp timeouted/failed.
4852 * notify TL that association is failed so that TL can flush the
4853 * cached frame
4854 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 WLANTL_AssocFailed (psessionEntry->staId);
4856
Abhishek Singh70af9c72016-03-09 17:23:30 +05304857 /* Log error */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304858 limLog(pMac, LOG1,
4859 FL("Re/Association Response not received before timeout "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004860
Abhishek Singh70af9c72016-03-09 17:23:30 +05304861 /*
4862 * Send Deauth to handle the scenareo where association timeout happened
4863 * when device has missed the assoc resp sent by peer.
4864 * By sending deauth try to clear the session created on peer device.
4865 */
4866 limLog(pMac, LOGE,
4867 FL("Sessionid: %d try sending Send deauth on channel %d to BSSID: "
4868 MAC_ADDRESS_STR ), psessionEntry->peSessionId,
4869 psessionEntry->currentOperChannel,
4870 MAC_ADDR_ARRAY(psessionEntry->bssId));
4871
4872 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
4873 psessionEntry->bssId,
4874 psessionEntry, FALSE);
4875
4876 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4877 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )||
4878 ((psessionEntry->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
4879 (psessionEntry->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 (psessionEntry->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4881 {
4882 /**
4883 * Re/Assoc failure timer should not have timedout on AP
4884 * or in a state other than wt_re/assoc_response.
4885 */
4886
4887 // Log error
4888 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304889 FL("received unexpected REASSOC failure timeout in state %d for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 psessionEntry->limMlmState, psessionEntry->limSystemRole);
4891 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4892 }
4893 else
4894 {
4895
4896 if ((MsgType == LIM_ASSOC) ||
4897 ((MsgType == LIM_REASSOC) && (psessionEntry->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4898 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004899 PELOGE(limLog(pMac, LOGE, FL("(Re)Assoc Failure Timeout occurred."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
4901 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004902 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4903
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 // 'Change' timer for future activations
4905 limDeactivateAndChangeTimer(pMac, eLIM_ASSOC_FAIL_TIMER);
4906
4907 // Free up buffer allocated for JoinReq held by
4908 // MLM state machine
4909 if (psessionEntry->pLimMlmJoinReq)
4910 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304911 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 psessionEntry->pLimMlmJoinReq = NULL;
4913 }
4914
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 //To remove the preauth node in case of fail to associate
4916 if (limSearchPreAuthList(pMac, psessionEntry->bssId))
4917 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304918 limLog(pMac, LOG1, FL(" delete pre auth node for "
4919 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 limDeletePreAuthNode(pMac, psessionEntry->bssId);
4921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
4923 mlmAssocCnf.resultCode =
4924 eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
4925 mlmAssocCnf.protStatusCode =
4926 eSIR_MAC_UNSPEC_FAILURE_STATUS;
4927
4928 /* Update PE session Id*/
4929 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
4930 if (MsgType == LIM_ASSOC)
4931 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4932 else
4933 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004934 /* Will come here only in case of 11r, ESE, FT when reassoc rsp
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 is not received and we receive a reassoc - timesout */
4936 mlmAssocCnf.resultCode = eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
4937 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4938 }
4939 }
4940 else
4941 {
4942 /**
4943 * Restore pre-reassoc req state.
4944 * Set BSSID to currently associated AP address.
4945 */
4946 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004947 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004948
4949 limRestorePreReassocState(pMac,
4950 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry);
4951 }
4952 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304953 /* Reinit scan results to remove the unreachable BSS */
4954 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004955} /*** limProcessAssocFailureTimeout() ***/
4956
4957
4958
4959/**
4960 * limCompleteMlmScan()
4961 *
4962 *FUNCTION:
4963 * This function is called to send MLM_SCAN_CNF message
4964 * to SME state machine.
4965 *
4966 *LOGIC:
4967 *
4968 *ASSUMPTIONS:
4969 *
4970 *NOTE:
4971 *
4972 * @param pMac Pointer to Global MAC structure
4973 * @param retCode Result code to be sent
4974 * @return None
4975 */
4976
4977void
4978limCompleteMlmScan(tpAniSirGlobal pMac, tSirResultCodes retCode)
4979{
4980 tLimMlmScanCnf mlmScanCnf;
4981
4982 /// Restore previous MLM state
4983 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004984 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 limRestorePreScanState(pMac);
4986
4987 // Free up pMac->lim.gLimMlmScanReq
4988 if( NULL != pMac->lim.gpLimMlmScanReq )
4989 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304990 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 pMac->lim.gpLimMlmScanReq = NULL;
4992 }
4993
4994 mlmScanCnf.resultCode = retCode;
4995 mlmScanCnf.scanResultLength = pMac->lim.gLimMlmScanResultLength;
4996
4997 limPostSmeMessage(pMac, LIM_MLM_SCAN_CNF, (tANI_U32 *) &mlmScanCnf);
4998
4999} /*** limCompleteMlmScan() ***/
5000
5001/**
5002 * \brief Setup an A-MPDU/BA session
5003 *
5004 * \sa limProcessMlmAddBAReq
5005 *
5006 * \param pMac The global tpAniSirGlobal object
5007 *
5008 * \param pMsgBuf The MLME ADDBA Req message buffer
5009 *
5010 * \return none
5011 */
5012void limProcessMlmAddBAReq( tpAniSirGlobal pMac,
5013 tANI_U32 *pMsgBuf )
5014{
5015tSirRetStatus status = eSIR_SUCCESS;
5016tpLimMlmAddBAReq pMlmAddBAReq;
5017tpLimMlmAddBACnf pMlmAddBACnf;
5018 tpPESession psessionEntry;
5019
5020 if(pMsgBuf == NULL)
5021 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005022 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 return;
5024 }
5025
5026 pMlmAddBAReq = (tpLimMlmAddBAReq) pMsgBuf;
5027 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBAReq->sessionId))== NULL)
5028 {
5029 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005030 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305031 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 return;
5033 }
5034
5035
5036 // Send ADDBA Req over the air
5037 status = limSendAddBAReq( pMac, pMlmAddBAReq,psessionEntry);
5038
5039 //
5040 // Respond immediately to LIM, only if MLME has not been
5041 // successfully able to send WDA_ADDBA_REQ to HAL.
5042 // Else, LIM_MLM_ADDBA_CNF will be sent after receiving
5043 // ADDBA Rsp from peer entity
5044 //
5045 if( eSIR_SUCCESS != status )
5046 {
5047 // Allocate for LIM_MLM_ADDBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305048
5049 pMlmAddBACnf = vos_mem_malloc(sizeof( tLimMlmAddBACnf ));
5050 if ( NULL == pMlmAddBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 {
5052 limLog( pMac, LOGP,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005053 FL("AllocateMemory failed"));
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305054 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 return;
5056 }
5057 else
5058 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305059 vos_mem_set((void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ), 0);
5060 vos_mem_copy((void *) pMlmAddBACnf->peerMacAddr,
5061 (void *) pMlmAddBAReq->peerMacAddr,
5062 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005063
5064 pMlmAddBACnf->baDialogToken = pMlmAddBAReq->baDialogToken;
5065 pMlmAddBACnf->baTID = pMlmAddBAReq->baTID;
5066 pMlmAddBACnf->baPolicy = pMlmAddBAReq->baPolicy;
5067 pMlmAddBACnf->baBufferSize = pMlmAddBAReq->baBufferSize;
5068 pMlmAddBACnf->baTimeout = pMlmAddBAReq->baTimeout;
5069 pMlmAddBACnf->sessionId = pMlmAddBAReq->sessionId;
5070
5071 // Update the result code
5072 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
5073
5074 limPostSmeMessage( pMac,
5075 LIM_MLM_ADDBA_CNF,
5076 (tANI_U32 *) pMlmAddBACnf );
5077 }
5078
5079 // Restore MLME state
5080 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07005081 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005082
5083 }
5084
5085 // Free the buffer allocated for tLimMlmAddBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305086 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005087
5088}
5089
5090/**
5091 * \brief Send an ADDBA Rsp to peer STA in response
5092 * to an ADDBA Req received earlier
5093 *
5094 * \sa limProcessMlmAddBARsp
5095 *
5096 * \param pMac The global tpAniSirGlobal object
5097 *
5098 * \param pMsgBuf The MLME ADDBA Rsp message buffer
5099 *
5100 * \return none
5101 */
5102void limProcessMlmAddBARsp( tpAniSirGlobal pMac,
5103 tANI_U32 *pMsgBuf )
5104{
5105tpLimMlmAddBARsp pMlmAddBARsp;
5106 tANI_U16 aid;
5107 tpDphHashNode pSta;
5108 tpPESession psessionEntry;
5109
5110
5111 if(pMsgBuf == NULL)
5112 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005113 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 return;
5115 }
5116
5117 pMlmAddBARsp = (tpLimMlmAddBARsp) pMsgBuf;
5118
5119 if(( psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBARsp->sessionId))== NULL)
5120 {
5121 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005122 FL("session does not exist for given session ID"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305123 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 return;
5125 }
5126
5127
5128 // Send ADDBA Rsp over the air
5129 if( eSIR_SUCCESS != limSendAddBARsp( pMac,pMlmAddBARsp,psessionEntry))
5130 {
5131 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005132 FL("Failed to send ADDBA Rsp to peer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGE );
5134 /* Clean the BA context maintained by HAL and TL on failure */
5135 pSta = dphLookupHashEntry( pMac, pMlmAddBARsp->peerMacAddr, &aid,
5136 &psessionEntry->dph.dphHashTable);
5137 if( NULL != pSta )
5138 {
5139 limPostMsgDelBAInd( pMac, pSta, pMlmAddBARsp->baTID, eBA_RECIPIENT,
5140 psessionEntry);
5141 }
5142 }
5143
5144 // Time to post a WDA_DELBA_IND to HAL in order
5145 // to cleanup the HAL and SoftMAC entries
5146
5147
5148 // Free the buffer allocated for tLimMlmAddBARsp
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305149 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005150
5151}
5152
5153/**
5154 * \brief Setup an A-MPDU/BA session
5155 *
5156 * \sa limProcessMlmDelBAReq
5157 *
5158 * \param pMac The global tpAniSirGlobal object
5159 *
5160 * \param pMsgBuf The MLME DELBA Req message buffer
5161 *
5162 * \return none
5163 */
5164void limProcessMlmDelBAReq( tpAniSirGlobal pMac,
5165 tANI_U32 *pMsgBuf )
5166{
5167 tSirRetStatus status = eSIR_SUCCESS;
5168 tpLimMlmDelBAReq pMlmDelBAReq;
5169 tpLimMlmDelBACnf pMlmDelBACnf;
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 // TODO - Need to validate MLME state
5180 pMlmDelBAReq = (tpLimMlmDelBAReq) pMsgBuf;
5181
5182 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDelBAReq->sessionId))== NULL)
5183 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005184 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305185 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return;
5187 }
5188
5189 // Send DELBA Ind over the air
5190 if( eSIR_SUCCESS !=
5191 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
5192 status = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
5193 else
5194 {
5195 tANI_U16 aid;
5196 tpDphHashNode pSta;
5197
5198 // Time to post a WDA_DELBA_IND to HAL in order
5199 // to cleanup the HAL and SoftMAC entries
5200 pSta = dphLookupHashEntry( pMac, pMlmDelBAReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
5201 if( NULL != pSta )
5202 {
5203 status = limPostMsgDelBAInd( pMac,
5204 pSta,
5205 pMlmDelBAReq->baTID,
5206 pMlmDelBAReq->baDirection,psessionEntry);
5207
5208 }
5209 }
5210
5211 //
5212 // Respond immediately to SME with DELBA CNF using
5213 // LIM_MLM_DELBA_CNF with appropriate status
5214 //
5215
5216 // Allocate for LIM_MLM_DELBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305217
5218 pMlmDelBACnf = vos_mem_malloc(sizeof( tLimMlmDelBACnf ));
5219 if ( NULL == pMlmDelBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305221 limLog( pMac, LOGP, FL("AllocateMemory failed"));
5222 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 return;
5224 }
5225 else
5226 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305227 vos_mem_set((void *) pMlmDelBACnf, sizeof( tLimMlmDelBACnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005228
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305229 vos_mem_copy((void *) pMlmDelBACnf,
5230 (void *) pMlmDelBAReq,
5231 sizeof( tLimMlmDelBAReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005232
5233 // Update DELBA result code
5234 pMlmDelBACnf->delBAReasonCode = pMlmDelBAReq->delBAReasonCode;
5235
5236 /* Update PE session Id*/
5237 pMlmDelBACnf->sessionId = pMlmDelBAReq->sessionId;
5238
5239 limPostSmeMessage( pMac,
5240 LIM_MLM_DELBA_CNF,
5241 (tANI_U32 *) pMlmDelBACnf );
5242 }
5243
5244 // Free the buffer allocated for tLimMlmDelBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305245 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005246
5247}
5248
5249/**
5250 * @function : limSMPowerSaveStateInd( )
5251 *
5252 * @brief : This function is called upon receiving the PMC Indication to update the STA's MimoPs State.
5253 *
5254 * LOGIC:
5255 *
5256 * ASSUMPTIONS:
5257 * NA
5258 *
5259 * NOTE:
5260 * NA
5261 *
5262 * @param pMac - Pointer to Global MAC structure
5263 * @param limMsg - Lim Message structure object with the MimoPSparam in body
5264 * @return None
5265 */
5266
5267tSirRetStatus
5268limSMPowerSaveStateInd(tpAniSirGlobal pMac, tSirMacHTMIMOPowerSaveState state)
5269{
5270#if 0
5271 tSirRetStatus retStatus = eSIR_SUCCESS;
5272#if 0
5273 tANI_U32 cfgVal1;
5274 tANI_U16 cfgVal2;
5275 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
5276 tpDphHashNode pSta = NULL;
5277
5278 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5279 /** Verify the Mode of operation */
5280 if (pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005281 PELOGE(limLog(pMac, LOGE, FL("Got PMC indication when System not in the STA Role"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 return eSIR_FAILURE;
5283 }
5284
5285 if ((pMac->lim.gHTMIMOPSState == state) || (state == eSIR_HT_MIMO_PS_NA )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005286 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 -07005287 return eSIR_FAILURE;
5288 }
5289
5290 if (!pMac->lim.htCapability){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005291 PELOGW(limLog(pMac, LOGW, FL(" Not in 11n or HT capable mode"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 return eSIR_FAILURE;
5293 }
5294
5295 /** Update the CFG about the default MimoPS State */
5296 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &cfgVal1) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005297 limLog(pMac, LOGP, FL("could not retrieve HT Cap CFG "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 return eSIR_FAILURE;
5299 }
5300
5301 cfgVal2 = (tANI_U16)cfgVal1;
5302 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &cfgVal2;
5303 pHTCapabilityInfo->mimoPowerSave = state;
5304
5305 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005306 limLog(pMac, LOGP, FL("could not update HT Cap Info CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 return eSIR_FAILURE;
5308 }
5309
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005310 PELOG2(limLog(pMac, LOG2, FL(" The HT Capability for Mimo Pwr is updated to State: %u "),state);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005312 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 -07005313 /** Update in the LIM the MIMO PS state of the SELF */
5314 pMac->lim.gHTMIMOPSState = state;
5315 return eSIR_SUCCESS;
5316 }
5317
5318 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5319 if (!pSta->mlmStaContext.htCapability) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005320 limLog( pMac, LOGE,FL( "limSendSMPowerState: Peer is not HT Capable " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 return eSIR_FAILURE;
5322 }
5323
5324 if (isEnteringMimoPS(pMac->lim.gHTMIMOPSState, state)) {
5325 tSirMacAddr macAddr;
5326 /** Obtain the AP's Mac Address */
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305327 vos_mem_copy((tANI_U8 *)macAddr, psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 /** Send Action Frame with the corresponding mode */
5329 retStatus = limSendSMPowerStateFrame(pMac, macAddr, state);
5330 if (retStatus != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005331 PELOGE(limLog(pMac, LOGE, "Update SM POWER: Sending Action Frame has failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 return retStatus;
5333 }
5334 }
5335
5336 /** Update MlmState about the SetMimoPS State */
5337 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
5338 pMac->lim.gLimMlmState = eLIM_MLM_WT_SET_MIMOPS_STATE;
5339 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
5340
5341 /** Update the HAL and s/w mac about the mode to be set */
5342 retStatus = limPostSMStateUpdate( pMac,psessionEntry->staId, state);
5343
5344 PELOG2(limLog(pMac, LOG2, " Updated the New SMPS State");)
5345 /** Update in the LIM the MIMO PS state of the SELF */
5346 pMac->lim.gHTMIMOPSState = state;
5347#endif
5348 return retStatus;
5349#endif
5350return eSIR_SUCCESS;
5351}
5352
Jeff Johnsone7245742012-09-05 17:12:55 -07005353#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005354ePhyChanBondState limGet11ACPhyCBState(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 htSecondaryChannelOffset,tANI_U8 peerCenterChan, tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07005355{
5356 ePhyChanBondState cbState = PHY_SINGLE_CHANNEL_CENTERED;
5357
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005358 if(!psessionEntry->apChanWidth)
Jeff Johnsone7245742012-09-05 17:12:55 -07005359 {
5360 return htSecondaryChannelOffset;
5361 }
5362
5363 if ( (htSecondaryChannelOffset
5364 == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
5365 )
5366 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005367 if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005368 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005369 else if ((channel + 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005370 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005371 else if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005372 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
5373 else
5374 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005375 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005376 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005377 }
5378 if ( (htSecondaryChannelOffset
5379 == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
5380 )
5381 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005382 if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005383 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005384 else if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005385 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005386 else if ((channel - 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005387 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
5388 else
5389 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005390 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005391 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005392 }
5393 return cbState;
5394}
5395
5396#endif
5397
Jeff Johnson295189b2012-06-20 16:38:30 -07005398void
Jeff Johnsone7245742012-09-05 17:12:55 -07005399limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005400{
5401#if !defined WLAN_FEATURE_VOWIFI
5402 tANI_U32 localPwrConstraint;
5403#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005404 tpPESession peSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405
Jeff Johnsone7245742012-09-05 17:12:55 -07005406 peSession = peFindSessionBySessionId (pMac, peSessionId);
5407
5408 if ( NULL == peSession)
5409 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005410 limLog (pMac, LOGP, FL("Invalid PE session = %d"), peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005411 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005413#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07005414#ifdef WLAN_FEATURE_11AC
5415 if ( peSession->vhtCapability )
5416 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005417 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005418 }
5419 else
5420#endif
5421 {
5422 limSendSwitchChnlParams( pMac, channel, secChannelOffset, maxTxPower, peSessionId);
5423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005424#else
5425 if (wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005426 limLog(pMac, LOGP, FL("could not read WNI_CFG_LOCAL_POWER_CONSTRAINT from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 return;
5428 }
5429 // Send WDA_CHNL_SWITCH_IND to HAL
Jeff Johnsone7245742012-09-05 17:12:55 -07005430#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005431 if ( peSession->vhtCapability && peSession->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07005432 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005433 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005434 }
5435 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005436#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005437 {
5438 limSendSwitchChnlParams( pMac, channel, secChannelOffset, (tPowerdBm)localPwrConstraint, peSessionId);
5439 }
5440#endif
5441
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 }