blob: b55954a400cc67634871ba56110fb12c82f8fb06 [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
2465
2466
2467/**
2468 * limProcessMlmAuthReq()
2469 *
2470 *FUNCTION:
2471 * This function is called to process MLM_AUTH_REQ message
2472 * from SME
2473 *
2474 *LOGIC:
2475 *
2476 *ASSUMPTIONS:
2477 *
2478 *NOTE:
2479 *
2480 * @param pMac Pointer to Global MAC structure
2481 * @param *pMsgBuf A pointer to the MLM message buffer
2482 * @return None
2483 */
2484
2485static void
2486limProcessMlmAuthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2487{
2488 tANI_U32 numPreAuthContexts;
2489 tSirMacAddr currentBssId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 tLimMlmAuthCnf mlmAuthCnf;
2491 struct tLimPreAuthNode *preAuthNode;
2492 tpDphHashNode pStaDs;
2493 tANI_U8 sessionId;
2494 tpPESession psessionEntry;
2495
2496 if(pMsgBuf == NULL)
2497 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002498 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 return;
2500 }
2501
2502 pMac->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) pMsgBuf;
2503 sessionId = pMac->lim.gpLimMlmAuthReq->sessionId;
2504 if((psessionEntry= peFindSessionBySessionId(pMac,sessionId) )== NULL)
2505 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302506 limLog(pMac, LOGP, FL("SessionId:%d Session Does not exist"),sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 return;
2508 }
2509
Abhishek Singhcd09b562013-12-24 16:02:20 +05302510 limLog(pMac, LOG1,FL("Process Auth Req on sessionID %d Systemrole %d"
2511 "mlmstate %d from: "MAC_ADDRESS_STR" with authtype %d"), sessionId,
2512 psessionEntry->limSystemRole,psessionEntry->limMlmState,
2513 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr),
2514 pMac->lim.gpLimMlmAuthReq->authType);
2515
2516
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 /**
2518 * Expect Auth request only when:
2519 * 1. STA joined/associated with a BSS or
2520 * 2. STA is in IBSS mode
2521 * and STA is going to authenticate with a unicast
2522 * adress and requested authentication algorithm is
2523 * supported.
2524 */
2525 #if 0
2526 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2527 eSIR_SUCCESS)
2528 {
2529 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002530 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 }
2532 #endif //To SuppoRT BT-AMP
2533
2534 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2535
2536 if (((((psessionEntry->limSystemRole== eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2537 ((psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) ||
2538 (psessionEntry->limMlmState ==
2539 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
2540 ((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) &&
2541 (psessionEntry->limMlmState == eLIM_MLM_BSS_STARTED_STATE))) &&
2542 (limIsGroupAddr(pMac->lim.gpLimMlmAuthReq->peerMacAddr)
2543 == false) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 (limIsAuthAlgoSupported(
2545 pMac,
2546 pMac->lim.gpLimMlmAuthReq->authType,
2547 psessionEntry) == true)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 )
2549 {
2550 /**
2551 * This is a request for pre-authentication.
2552 * Check if there exists context already for
Jeff Johnson1250df42012-12-10 14:31:52 -08002553 * the requested peer OR
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 * if this request is for the AP we're currently
2555 * associated with.
2556 * If yes, return auth confirm immediately when
2557 * requested auth type is same as the one used before.
2558 */
2559 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2560 (psessionEntry->limMlmState ==
2561 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2562 (((pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) != NULL) &&
2563 (pMac->lim.gpLimMlmAuthReq->authType ==
2564 pStaDs->mlmStaContext.authType)) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302565 (vos_mem_compare(pMac->lim.gpLimMlmAuthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 currentBssId,
2567 sizeof(tSirMacAddr)) )) ||
2568 (((preAuthNode =
2569 limSearchPreAuthList(
2570 pMac,
2571 pMac->lim.gpLimMlmAuthReq->peerMacAddr)) != NULL) &&
2572 (preAuthNode->authType ==
2573 pMac->lim.gpLimMlmAuthReq->authType)))
2574 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302575 limLog(pMac, LOG2,
2576 FL("Already have pre-auth context with peer: "MAC_ADDRESS_STR),
2577 MAC_ADDR_ARRAY(pMac->lim.gpLimMlmAuthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002578
2579 mlmAuthCnf.resultCode = (tSirResultCodes)
2580 eSIR_MAC_SUCCESS_STATUS;
2581
2582
2583 goto end;
2584 }
2585 else
2586 {
2587 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
2588 (tANI_U32 *) &numPreAuthContexts) != eSIR_SUCCESS)
2589 {
2590 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002591 FL("Could not retrieve NumPreAuthLimit from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002593
2594 if (pMac->lim.gLimNumPreAuthContexts == numPreAuthContexts)
2595 {
2596 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002597 FL("Number of pre-auth reached max limit"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002598
2599 /// Return Auth confirm with reject code
2600 mlmAuthCnf.resultCode =
2601 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
2602
2603 goto end;
2604 }
2605 }
2606
2607 // Delete pre-auth node if exists
2608 if (preAuthNode)
2609 limDeletePreAuthNode(pMac,
2610 pMac->lim.gpLimMlmAuthReq->peerMacAddr);
2611
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2613 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002614 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002615
Jeff Johnsone7245742012-09-05 17:12:55 -07002616 //assign appropriate sessionId to the timer object
2617 pMac->lim.limTimers.gLimAuthFailureTimer.sessionId = sessionId;
Sushant Kaushik9e923872015-04-02 17:09:31 +05302618 /* assign appropriate sessionId to the timer object */
2619 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId = sessionId;
2620 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07002621 // Activate Auth failure timer
2622 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_AUTH_FAIL_TIMER));
Paul Zhang83289792017-02-28 18:58:52 +08002623
2624 limDoSendAuthMgmtFrame(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 return;
2626 }
2627 else
2628 {
2629 /**
2630 * Unexpected auth request.
2631 * Return Auth confirm with Invalid parameters code.
2632 */
2633 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2634
2635 goto end;
2636 }
2637
2638end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302639 vos_mem_copy((tANI_U8 *) &mlmAuthCnf.peerMacAddr,
2640 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2641 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002642
2643 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
2644 mlmAuthCnf.sessionId = sessionId;
2645
2646 /// Free up buffer allocated
2647 /// for pMac->lim.gLimMlmAuthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302648 vos_mem_free( pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 pMac->lim.gpLimMlmAuthReq = NULL;
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302650 limLog(pMac,LOG1,"SessionId:%d LimPostSme LIM_MLM_AUTH_CNF ",sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 limPostSmeMessage(pMac, LIM_MLM_AUTH_CNF, (tANI_U32 *) &mlmAuthCnf);
2652} /*** limProcessMlmAuthReq() ***/
2653
2654
2655
2656/**
2657 * limProcessMlmAssocReq()
2658 *
2659 *FUNCTION:
2660 * This function is called to process MLM_ASSOC_REQ message
2661 * from SME
2662 *
2663 *LOGIC:
2664 *
2665 *ASSUMPTIONS:
2666 *
2667 *NOTE:
2668 *
2669 * @param pMac Pointer to Global MAC structure
2670 * @param *pMsgBuf A pointer to the MLM message buffer
2671 * @return None
2672 */
2673
2674static void
2675limProcessMlmAssocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2676{
2677 tSirMacAddr currentBssId;
2678 tLimMlmAssocReq *pMlmAssocReq;
2679 tLimMlmAssocCnf mlmAssocCnf;
2680 tpPESession psessionEntry;
2681 // tANI_U8 sessionId;
2682
2683 if(pMsgBuf == NULL)
2684 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002685 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 return;
2687 }
2688 pMlmAssocReq = (tLimMlmAssocReq *) pMsgBuf;
2689
2690 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmAssocReq->sessionId) )== NULL)
2691 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302692 limLog(pMac, LOGP,FL("SessionId:%d Session Does not exist"),
2693 pMlmAssocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302694 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 return;
2696 }
2697
Abhishek Singhcd09b562013-12-24 16:02:20 +05302698 limLog(pMac, LOG1,FL("Process Assoc Req on sessionID %d Systemrole %d"
2699 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmAssocReq->sessionId,
2700 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2701 MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));
2702
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 #if 0
2704 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2705 eSIR_SUCCESS)
2706 {
2707 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002708 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 }
2710 #endif //TO SUPPORT BT-AMP
2711 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2712
2713 if ( (psessionEntry->limSystemRole != eLIM_AP_ROLE && psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE) &&
2714 (psessionEntry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302715 (vos_mem_compare(pMlmAssocReq->peerMacAddr, currentBssId, sizeof(tSirMacAddr))) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002717
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 /// map the session entry pointer to the AssocFailureTimer
2719 pMac->lim.limTimers.gLimAssocFailureTimer.sessionId = pMlmAssocReq->sessionId;
2720
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2722 psessionEntry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002723 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302724 limLog(pMac,LOG1,"SessionId:%d Sending Assoc_Req Frame",
2725 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002726
2727 /// Prepare and send Association request frame
2728 limSendAssocReqMgmtFrame(pMac, pMlmAssocReq,psessionEntry);
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302729#ifdef FEATURE_WLAN_DIAG_SUPPORT
2730 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_REQ_EVENT, psessionEntry,
2731 eSIR_SUCCESS, eSIR_SUCCESS);
2732#endif
2733
Jeff Johnson295189b2012-06-20 16:38:30 -07002734
2735 //Set the link state to postAssoc, so HW can start receiving frames from AP.
2736 if ((psessionEntry->bssType == eSIR_BTAMP_STA_MODE)||
2737 ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE) && (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
2738 {
2739 if(limSetLinkState(pMac, eSIR_LINK_BTAMP_POSTASSOC_STATE, currentBssId,
2740 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002741 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002743 /// Start association failure timer
2744 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
2745 if (tx_timer_activate(&pMac->lim.limTimers.gLimAssocFailureTimer)
2746 != TX_SUCCESS)
2747 {
2748 /// Could not start Assoc failure timer.
2749 // Log error
2750 limLog(pMac, LOGP,
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302751 FL("SessionId:%d could not start Association failure timer"),
2752 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002753 // Cleanup as if assoc timer expired
2754 limProcessAssocFailureTimeout(pMac,LIM_ASSOC );
2755
2756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 return;
2759 }
2760 else
2761 {
2762 /**
2763 * Received Association request either in invalid state
2764 * or to a peer MAC entity whose address is different
2765 * from one that STA is currently joined with or on AP.
2766 * Return Assoc confirm with Invalid parameters code.
2767 */
2768
2769 // Log error
2770 PELOGW(limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302771 FL("received unexpected MLM_ASSOC_CNF in state %d for role=%d, MAC addr= "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302772 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2773 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pMlmAssocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2775
2776 mlmAssocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2777 mlmAssocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2778
2779 goto end;
2780 }
2781
2782end:
2783 /* Update PE session Id*/
2784 mlmAssocCnf.sessionId = pMlmAssocReq->sessionId;
2785
2786 /// Free up buffer allocated for assocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302787 vos_mem_free(pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
2789 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
2790} /*** limProcessMlmAssocReq() ***/
2791
2792
2793
2794/**
2795 * limProcessMlmReassocReq()
2796 *
2797 *FUNCTION:
2798 * This function is called to process MLM_REASSOC_REQ message
2799 * from SME
2800 *
2801 *LOGIC:
2802 *
2803 *ASSUMPTIONS:
2804 *
2805 *NOTE:
2806 *
2807 * @param pMac Pointer to Global MAC structure
2808 * @param *pMsgBuf A pointer to the MLM message buffer
2809 * @return None
2810 */
2811
2812static void
2813limProcessMlmReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2814{
Jeff Johnsone7245742012-09-05 17:12:55 -07002815 tANI_U8 chanNum, secChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 struct tLimPreAuthNode *pAuthNode;
2817 tLimMlmReassocReq *pMlmReassocReq;
2818 tLimMlmReassocCnf mlmReassocCnf;
2819 tpPESession psessionEntry;
2820
2821 if(pMsgBuf == NULL)
2822 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002823 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return;
2825 }
2826
2827 pMlmReassocReq = (tLimMlmReassocReq *) pMsgBuf;
Abhishek Singhcd09b562013-12-24 16:02:20 +05302828
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmReassocReq->sessionId)) == NULL)
2830 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302831 limLog(pMac, LOGE,FL("Session Does not exist for given sessionId %d"),
2832 pMlmReassocReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302833 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 return;
2835 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302836
2837 limLog(pMac, LOG1,FL("Process ReAssoc Req on sessionID %d Systemrole %d"
2838 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmReassocReq->sessionId,
2839 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2840 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
2841
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 if (((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) &&
2843 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
2844 {
2845 if (psessionEntry->pLimMlmReassocReq)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302846 vos_mem_free(psessionEntry->pLimMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002847
2848 /* Hold Re-Assoc request as part of Session, knock-out pMac */
2849 /// Hold onto Reassoc request parameters
2850 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
2851
2852 // See if we have pre-auth context with new AP
2853 pAuthNode = limSearchPreAuthList(pMac, psessionEntry->limReAssocbssId);
2854
2855 if (!pAuthNode &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302856 (!vos_mem_compare(pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 psessionEntry->bssId,
2858 sizeof(tSirMacAddr)) ))
2859 {
2860 // Either pre-auth context does not exist AND
2861 // we are not reassociating with currently
2862 // associated AP.
2863 // Return Reassoc confirm with not authenticated
2864 mlmReassocCnf.resultCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2865 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2866
2867 goto end;
2868 }
2869
2870 //assign the sessionId to the timer object
2871 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = pMlmReassocReq->sessionId;
2872
2873 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2874 psessionEntry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002875 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002876
2877#if 0
2878 // Update BSSID at CFG database
2879 if (wlan_cfgSetStr(pMac, WNI_CFG_BSSID,
2880 pMac->lim.gLimReassocBssId,
2881 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
2882 {
2883 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002884 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
2886#endif //TO SUPPORT BT-AMP
2887
2888 /* Copy Global Reassoc ID*/
2889 // sirCopyMacAddr(psessionEntry->reassocbssId,pMac->lim.gLimReAssocBssId);
2890
2891 /**
2892 * Derive channel from BSS description and
2893 * store it at CFG.
2894 */
2895
2896 chanNum = psessionEntry->limReassocChannelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07002897 secChannelOffset = psessionEntry->reAssocHtSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002898
2899 /* To Support BT-AMP .. read channel number from psessionEntry*/
2900 //chanNum = psessionEntry->currentOperChannel;
2901
2902 // Apply previously set configuration at HW
2903 limApplyConfiguration(pMac,psessionEntry);
2904
2905 //store the channel switch sessionEntry in the lim global var
2906 /* We have already saved the ReAssocreq Pointer abobe */
2907 //psessionEntry->pLimReAssocReq = (void *)pMlmReassocReq;
2908 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_REASSOC;
2909
Jeff Johnsone7245742012-09-05 17:12:55 -07002910 /** Switch channel to the new Operating channel for Reassoc*/
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302911
2912#ifdef FEATURE_WLAN_DIAG_SUPPORT
2913 limDiagEventReport(pMac, WLAN_PE_DIAG_CHANNEL_SWITCH_ANOUNCEMENT,
2914 psessionEntry, eSIR_SUCCESS, LIM_SWITCH_CHANNEL_REASSOC);
2915#endif
2916
Jeff Johnsone7245742012-09-05 17:12:55 -07002917 limSetChannel(pMac, chanNum, secChannelOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002918
2919 return;
2920 }
2921 else
2922 {
2923 /**
2924 * Received Reassoc request in invalid state or
2925 * in AP role.Return Reassoc confirm with Invalid
2926 * parameters code.
2927 */
2928
2929 // Log error
Abhishek Singhcd09b562013-12-24 16:02:20 +05302930 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302931 FL("received unexpected MLM_REASSOC_CNF in state %d for role=%d, "
Abhishek Singhcd09b562013-12-24 16:02:20 +05302932 "MAC addr= "
2933 MAC_ADDRESS_STR), psessionEntry->limMlmState,
2934 psessionEntry->limSystemRole,
2935 MAC_ADDR_ARRAY(pMlmReassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2937
2938 mlmReassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2939 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2940
2941 goto end;
2942 }
2943
2944end:
2945 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2946 /* Update PE sessio Id*/
2947 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
2948 /// Free up buffer allocated for reassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05302949 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 psessionEntry->pLimReAssocReq = NULL;
2951
2952 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2953} /*** limProcessMlmReassocReq() ***/
2954
2955
2956static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08002957limProcessMlmDisassocReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07002958{
2959 tANI_U16 aid;
2960 tSirMacAddr currentBssId;
2961 tpDphHashNode pStaDs;
2962 tLimMlmDisassocReq *pMlmDisassocReq;
2963 tLimMlmDisassocCnf mlmDisassocCnf;
2964 tpPESession psessionEntry;
2965 extern tANI_BOOLEAN sendDisassocFrame;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302966 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302967 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05302968 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07002969
2970 if(eHAL_STATUS_SUCCESS != suspendStatus)
2971 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002972 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002973#if 0
2974 //It can ignore the status and proceed with the disassoc processing.
2975 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
2976 goto end;
2977#endif
2978 }
2979
2980 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
2981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
2983 {
2984
Abhishek Singhcd09b562013-12-24 16:02:20 +05302985 limLog(pMac, LOGE,
2986 FL("session does not exist for given sessionId %d"),
2987 pMlmDisassocReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2989 goto end;
2990 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302991 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d Systemrole %d"
2992 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
2993 psessionEntry->limSystemRole, psessionEntry->limMlmState,
2994 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
2995
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 #if 0
2997 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2998 eSIR_SUCCESS)
2999 {
3000 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003001 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 }
3003 #endif //BT-AMP Support
3004 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3005
3006 switch (psessionEntry->limSystemRole)
3007 {
3008 case eLIM_STA_ROLE:
3009 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303010 if ( !vos_mem_compare(pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 currentBssId,
3012 sizeof(tSirMacAddr)) )
3013 {
3014 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303015 FL("received MLM_DISASSOC_REQ with invalid BSS id from: "
3016 MAC_ADDRESS_STR),
3017 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003018
3019 /// Prepare and Send LIM_MLM_DISASSOC_CNF
3020
3021 mlmDisassocCnf.resultCode =
3022 eSIR_SME_INVALID_PARAMETERS;
3023
3024 goto end;
3025 }
3026
3027 break;
3028
3029 case eLIM_STA_IN_IBSS_ROLE:
3030
3031 break;
3032
3033 default: // eLIM_AP_ROLE
3034
3035 // Fall through
3036 break;
3037
3038 } // end switch (psessionEntry->limSystemRole)
3039
3040 /**
3041 * Check if there exists a context for the peer entity
3042 * to be disassociated with.
3043 */
3044 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3045 if ((pStaDs == NULL) ||
3046 (pStaDs &&
3047 ((pStaDs->mlmStaContext.mlmState !=
3048 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3049 (pStaDs->mlmStaContext.mlmState !=
3050 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
3051 (pStaDs->mlmStaContext.mlmState !=
3052 eLIM_MLM_ASSOCIATED_STATE))))
3053 {
3054 /**
3055 * Received LIM_MLM_DISASSOC_REQ for STA that does not
3056 * have context or in some transit state.
3057 * Log error
3058 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303059 limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303060 FL("received MLM_DISASSOC_REQ for STA that either has no context "
3061 "or in some transit state, Addr= "
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303062 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3063 if (pStaDs != NULL)
3064 limLog(pMac, LOGE, FL("Sta MlmState : %d"),
3065 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003066
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303067 /*
3068 * Disassociation response due to
3069 * host triggered disassociation
3070 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003071
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303072 pSirSmeDisassocRsp = vos_mem_malloc(sizeof(tSirSmeDisassocRsp));
3073 if ( NULL == pSirSmeDisassocRsp )
3074 {
3075 // Log error
3076 limLog(pMac, LOGP,
3077 FL("call to AllocateMemory failed for eWNI_SME_DISASSOC_RSP"));
3078 return;
3079 }
3080 limLog(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
3081 "retCode: %d for "MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3082 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
3083 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
3084 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
3085 pSirSmeDisassocRsp->sessionId = pMlmDisassocReq->sessionId;
3086 pSirSmeDisassocRsp->transactionId = 0;
3087 pSirSmeDisassocRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303089 pBuf = (tANI_U8 *) pSirSmeDisassocRsp->peerMacAddr;
3090 vos_mem_copy( pBuf, pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr));
3091
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303092 msg.type = eWNI_SME_DISASSOC_RSP;
3093 msg.bodyptr = pSirSmeDisassocRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303094
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303095 if (pMac->lim.sme_msg_callback)
3096 pMac->lim.sme_msg_callback(pMac, &msg);
3097 else
3098 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
3099
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303100 return;
3101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 }
3103
3104 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3105 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3106 pMlmDisassocReq->reasonCode;
3107 pStaDs->mlmStaContext.cleanupTrigger = pMlmDisassocReq->disassocTrigger;
Mukul Sharma91947a22014-06-09 11:07:51 +05303108 /** Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3109 * This is to address the issue of race condition between
3110 * disconnect request from the HDD and deauth from AP
3111 */
3112 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003113
3114 /// Send Disassociate frame to peer entity
Jeff Johnsone7245742012-09-05 17:12:55 -07003115 if (sendDisassocFrame && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003117 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = pMlmDisassocReq;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303118 if (IS_FW_IN_TX_PATH_FEATURE_ENABLE)
Sandeep Puligilla25728282013-12-01 19:44:14 +05303119 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303120 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Sandeep Puligilla25728282013-12-01 19:44:14 +05303121 pMlmDisassocReq->peerMacAddr,
3122 psessionEntry, FALSE);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303123 /* Send Disassoc CNF and receive path cleanup */
3124 limSendDisassocCnf(pMac);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303125 }
3126 else
3127 {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05303128 limSendDisassocMgmtFrame(pMac, pMlmDisassocReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003129 pMlmDisassocReq->peerMacAddr,
3130 psessionEntry, TRUE);
Sandeep Puligilla25728282013-12-01 19:44:14 +05303131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 }
3133 else
3134 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003135 /* Disassoc frame is not sent OTA */
3136 sendDisassocFrame = 1;
3137 // Receive path cleanup with dummy packet
3138 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs,psessionEntry))
3139 {
3140 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3141 goto end;
3142 }
3143 // Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303144 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 }
3146
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 return;
3148
3149end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303150 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3151 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3152 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3154 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3155
3156 /* Update PE session ID*/
3157 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3158
3159 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303160 vos_mem_free(pMlmDisassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161
3162 limPostSmeMessage(pMac,
3163 LIM_MLM_DISASSOC_CNF,
3164 (tANI_U32 *) &mlmDisassocCnf);
3165}
3166
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003167tANI_BOOLEAN limCheckDisassocDeauthAckPending(tpAniSirGlobal pMac,
3168 tANI_U8 *staMac
3169 )
3170{
3171 tLimMlmDisassocReq *pMlmDisassocReq;
3172 tLimMlmDeauthReq *pMlmDeauthReq;
3173 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3174 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3175 if (
3176 (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303177 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003178 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3179 sizeof(tSirMacAddr))))
3180 ||
3181 (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303182 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003183 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303184 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003185 )
3186 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003187 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth ack pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003188 return eANI_BOOLEAN_TRUE;
3189 }
3190 else
3191 {
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -07003192 PELOG1(limLog(pMac, LOG1, FL("Disassoc/Deauth Ack not pending"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -08003193 return eANI_BOOLEAN_FALSE;
3194 }
3195}
3196
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003197void limCleanUpDisassocDeauthReq(tpAniSirGlobal pMac,
3198 tANI_U8 *staMac,
3199 tANI_BOOLEAN cleanRxPath)
3200{
3201 tLimMlmDisassocReq *pMlmDisassocReq;
3202 tLimMlmDeauthReq *pMlmDeauthReq;
3203 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3204 if (pMlmDisassocReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303205 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003206 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3207 sizeof(tSirMacAddr))))
3208 {
3209 if (cleanRxPath)
3210 {
3211 limProcessDisassocAckTimeout(pMac);
3212 }
3213 else
3214 {
3215 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3216 {
3217 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3218 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303219 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003220 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3221 }
3222 }
3223
3224 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3225 if (pMlmDeauthReq &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303226 (vos_mem_compare((tANI_U8 *) staMac,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003227 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
3228 sizeof(tSirMacAddr))))
3229 {
3230 if (cleanRxPath)
3231 {
3232 limProcessDeauthAckTimeout(pMac);
3233 }
3234 else
3235 {
3236 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3237 {
3238 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3239 }
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303240 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08003241 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3242 }
3243 }
3244}
3245
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003246void limProcessDisassocAckTimeout(tpAniSirGlobal pMac)
3247{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303248 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003249 limSendDisassocCnf(pMac);
3250}
3251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252/**
3253 * limProcessMlmDisassocReq()
3254 *
3255 *FUNCTION:
3256 * This function is called to process MLM_DISASSOC_REQ message
3257 * from SME
3258 *
3259 *LOGIC:
3260 *
3261 *ASSUMPTIONS:
3262 *
3263 *NOTE:
3264 *
3265 * @param pMac Pointer to Global MAC structure
3266 * @param *pMsgBuf A pointer to the MLM message buffer
3267 * @return None
3268 */
3269
3270static void
3271limProcessMlmDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3272{
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 tLimMlmDisassocReq *pMlmDisassocReq;
Jeff Johnson295189b2012-06-20 16:38:30 -07003274
3275 if(pMsgBuf == NULL)
3276 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003277 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 return;
3279 }
3280
3281 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05303282
Abhishek Singhcd09b562013-12-24 16:02:20 +05303283 limLog(pMac, LOG1,FL("Process DisAssoc Req on sessionID %d "
3284 "from: "MAC_ADDRESS_STR), pMlmDisassocReq->sessionId,
3285 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003286
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003287 limProcessMlmDisassocReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003288
Jeff Johnson295189b2012-06-20 16:38:30 -07003289} /*** limProcessMlmDisassocReq() ***/
3290
3291static void
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003292limProcessMlmDeauthReqNtf(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07003293{
3294 tANI_U16 aid;
3295 tSirMacAddr currentBssId;
3296 tpDphHashNode pStaDs;
3297 struct tLimPreAuthNode *pAuthNode;
3298 tLimMlmDeauthReq *pMlmDeauthReq;
3299 tLimMlmDeauthCnf mlmDeauthCnf;
3300 tpPESession psessionEntry;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303301 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
3302 tANI_U8 *pBuf;
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303303 vos_msg_t msg = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003304
3305 if(eHAL_STATUS_SUCCESS != suspendStatus)
3306 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003307 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X"), suspendStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003308#if 0
3309 //It can ignore the status and proceed with the disassoc processing.
3310 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
3311 goto end;
3312#endif
3313 }
3314
3315 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3316
3317 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3318 {
3319
Abhishek Singhcd09b562013-12-24 16:02:20 +05303320 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3321 pMlmDeauthReq->sessionId);
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303322 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 return;
3324 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303325 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d Systemrole %d"
3326 "mlmstate %d from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3327 psessionEntry->limSystemRole, psessionEntry->limMlmState,
3328 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 #if 0
3330 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3331 eSIR_SUCCESS)
3332 {
3333 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003334 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 }
3336 #endif //SUPPORT BT-AMP
3337 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3338
3339 switch (psessionEntry->limSystemRole)
3340 {
3341 case eLIM_STA_ROLE:
3342 case eLIM_BT_AMP_STA_ROLE:
3343 switch (psessionEntry->limMlmState)
3344 {
3345 case eLIM_MLM_IDLE_STATE:
3346 // Attempting to Deauthenticate
3347 // with a pre-authenticated peer.
3348 // Deauthetiate with peer if there
3349 // exists a pre-auth context below.
3350 break;
3351
3352 case eLIM_MLM_AUTHENTICATED_STATE:
3353 case eLIM_MLM_WT_ASSOC_RSP_STATE:
3354 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303355 if (!vos_mem_compare(pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 currentBssId,
3357 sizeof(tSirMacAddr)) )
3358 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05303359 limLog(pMac, LOGE,
3360 FL("received MLM_DEAUTH_REQ with invalid BSS id "
3361 "Peer MAC: "MAC_ADDRESS_STR " CFG BSSID Addr : "
3362 MAC_ADDRESS_STR),
3363 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr),
3364 MAC_ADDR_ARRAY(currentBssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003365
3366 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3367
3368 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3369
3370 goto end;
3371 }
3372
3373 if ((psessionEntry->limMlmState ==
3374 eLIM_MLM_AUTHENTICATED_STATE) ||
3375 (psessionEntry->limMlmState ==
3376 eLIM_MLM_WT_ASSOC_RSP_STATE))
3377 {
3378 // Send Deauthentication frame
3379 // to peer entity
3380 limSendDeauthMgmtFrame(
3381 pMac,
3382 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003383 pMlmDeauthReq->peerMacAddr,
3384 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385
3386 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3387 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3388 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003389 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 goto end;
3391 }
3392 else
3393 {
3394 // LINK_ESTABLISED_STATE
3395 // Cleanup RX & TX paths
3396 // below
3397 }
3398
3399 break;
3400
3401 default:
3402
3403 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303404 FL("received MLM_DEAUTH_REQ with in state %d for peer "MAC_ADDRESS_STR),
3405 psessionEntry->limMlmState,MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3407
3408 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3409 mlmDeauthCnf.resultCode =
3410 eSIR_SME_STA_NOT_AUTHENTICATED;
3411
3412 goto end;
3413 }
3414
3415 break;
3416
3417 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303418 limLog(pMac, LOGE,
3419 FL("received MLM_DEAUTH_REQ IBSS Mode "));
3420 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3421 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 default: // eLIM_AP_ROLE
3423 break;
3424
3425 } // end switch (psessionEntry->limSystemRole)
3426
3427 /**
3428 * Check if there exists a context for the peer entity
3429 * to be deauthenticated with.
3430 */
3431 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3432
3433 if (pStaDs == NULL)
3434 {
3435 /// Check if there exists pre-auth context for this STA
3436 pAuthNode = limSearchPreAuthList(pMac,
3437 pMlmDeauthReq->peerMacAddr);
3438
3439 if (pAuthNode == NULL)
3440 {
3441 /**
3442 * Received DEAUTH REQ for a STA that is neither
3443 * Associated nor Pre-authenticated. Log error,
3444 * Prepare and Send LIM_MLM_DEAUTH_CNF
3445 */
3446 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303447 FL("received MLM_DEAUTH_REQ in mlme state %d for STA that "
3448 "does not have context, Addr="MAC_ADDRESS_STR),
3449 psessionEntry->limMlmState,
3450 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003451
3452 mlmDeauthCnf.resultCode =
3453 eSIR_SME_STA_NOT_AUTHENTICATED;
3454 }
3455 else
3456 {
3457 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3458
3459 /// Delete STA from pre-auth STA list
3460 limDeletePreAuthNode(pMac, pMlmDeauthReq->peerMacAddr);
3461
3462 /// Send Deauthentication frame to peer entity
3463 limSendDeauthMgmtFrame(pMac,
3464 pMlmDeauthReq->reasonCode,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003465 pMlmDeauthReq->peerMacAddr,
3466 psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }
3468
3469 goto end;
3470 }
3471 else if ((pStaDs->mlmStaContext.mlmState !=
3472 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3473 (pStaDs->mlmStaContext.mlmState !=
3474 eLIM_MLM_WT_ASSOC_CNF_STATE))
3475 {
3476 /**
3477 * Received LIM_MLM_DEAUTH_REQ for STA that is n
3478 * some transit state. Log error.
3479 */
3480 PELOGW(limLog(pMac, LOGW,
Abhishek Singhcd09b562013-12-24 16:02:20 +05303481 FL("received MLM_DEAUTH_REQ for STA that either has no context or in some transit state, Addr="
3482 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003483
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303484 /*
3485 * Deauthentication response to host triggered
3486 * deauthentication.
3487 */
3488 pSirSmeDeauthRsp = vos_mem_malloc(sizeof(tSirSmeDeauthRsp));
3489 if ( NULL == pSirSmeDeauthRsp )
3490 {
3491 // Log error
3492 limLog(pMac, LOGP,
3493 FL("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003494
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303495 return;
3496 }
3497 limLog(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
3498 "retCode: %d for"MAC_ADDRESS_STR),eSIR_SME_DEAUTH_STATUS,
3499 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3500 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
3501 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
3502 pSirSmeDeauthRsp->statusCode = eSIR_SME_DEAUTH_STATUS;
3503 pSirSmeDeauthRsp->sessionId = pMlmDeauthReq->sessionId;
3504 pSirSmeDeauthRsp->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303506 pBuf = (tANI_U8 *) pSirSmeDeauthRsp->peerMacAddr;
3507 vos_mem_copy( pBuf, pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr));
3508
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303509 msg.type = eWNI_SME_DEAUTH_RSP;
3510 msg.bodyptr = pSirSmeDeauthRsp;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303511
Yeshwanth Sriram Guntuka802101a2018-06-29 16:41:02 +05303512 if (pMac->lim.sme_msg_callback)
3513 pMac->lim.sme_msg_callback(pMac, &msg);
3514 else
3515 limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303516
3517 return;
3518
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 }
3520
3521 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3522 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3523 pMlmDeauthReq->reasonCode;
3524 pStaDs->mlmStaContext.cleanupTrigger = pMlmDeauthReq->deauthTrigger;
3525
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003526 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = pMlmDeauthReq;
Abhishek Singh94152932014-01-16 19:04:51 +05303527
3528 /* Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
3529 * This is to address the issue of race condition between
3530 * disconnect request from the HDD and disassoc from
3531 * inactivity timer. This will make sure that we will not
3532 * process disassoc if deauth is in progress for the station
3533 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
3534 */
3535 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
3536
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 /// Send Deauthentication frame to peer entity
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303538 /* If FW_IN_TX_PATH feature is enabled
3539 do not wait for ACK */
3540 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3541 {
3542 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3543 pMlmDeauthReq->peerMacAddr,
3544 psessionEntry, FALSE);
3545
3546 /* Send Deauth CNF and receive path cleanup */
3547 limSendDeauthCnf(pMac);
3548 }
3549 else
3550 {
3551 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3552 pMlmDeauthReq->peerMacAddr,
3553 psessionEntry, TRUE);
3554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003555
3556 return;
3557
3558end:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303559 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3560 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3561 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3563 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3564 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3565
3566 // Free up buffer allocated
3567 // for mlmDeauthReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303568 vos_mem_free(pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003569
3570 limPostSmeMessage(pMac,
3571 LIM_MLM_DEAUTH_CNF,
3572 (tANI_U32 *) &mlmDeauthCnf);
3573
3574}
3575
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003576
3577void limProcessDeauthAckTimeout(tpAniSirGlobal pMac)
3578{
Abhishek Singhcd09b562013-12-24 16:02:20 +05303579 limLog(pMac, LOG1, FL(""));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003580 limSendDeauthCnf(pMac);
3581}
3582
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303583void lim_process_ap_ecsa_timeout(tpAniSirGlobal mac_ctx)
3584{
3585 tSirMsgQ msg = {0};
3586 struct sir_ecsa_ie_complete_ind *ecsa_ie_cmp_ind;
3587 tpPESession session;
3588
3589 session = peFindSessionBySessionId(mac_ctx,
3590 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3591
3592 if(!session)
3593 {
3594 limLog(mac_ctx, LOGE, FL("session does not exist for given sessionId %d"),
3595 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId);
3596 return;
3597 }
3598 limLog(mac_ctx, LOG1, FL("session id %d switch count %d"),
3599 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId,
3600 session->gLimChannelSwitch.switchCount);
3601 /*
3602 * For each beacon interval decrement switch count to use proper value
3603 * in probe resp sent by host. Once it becomes 0 send tx complete
3604 * indication to SME.
3605 */
3606 if (session->gLimChannelSwitch.switchCount > 0) {
3607 session->gLimChannelSwitch.switchCount--;
Abhishek Singh449c5372017-12-19 17:21:20 +05303608 lim_send_chan_switch_action_frame(mac_ctx,
3609 session->gLimChannelSwitch.primaryChannel, session);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05303610 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
3611 session->peSessionId;
3612 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
3613
3614 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
3615 TX_SUCCESS)
3616 {
3617 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
3618 lim_process_ap_ecsa_timeout(mac_ctx);
3619 }
3620 return;
3621 }
3622
3623 session->include_ecsa_ie = false;
3624 session->include_wide_ch_bw_ie = false;
3625
3626 ecsa_ie_cmp_ind = vos_mem_malloc(sizeof(*ecsa_ie_cmp_ind));
3627 if(!ecsa_ie_cmp_ind)
3628 {
3629 limLog(mac_ctx, LOGE, FL("failed to allocate ecsa_ie_cmp_ind"));
3630 return;
3631 }
3632 ecsa_ie_cmp_ind->session_id = session->smeSessionId;
3633
3634 msg.type = eWNI_SME_ECSA_IE_BEACON_COMP_IND;
3635 msg.bodyptr = ecsa_ie_cmp_ind;
3636 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3637 return;
3638}
3639
3640void lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal mac_ctx,
3641 tpPESession session, tpSwitchChannelParams chan_params)
3642{
3643 tSirMsgQ msg = {0};
3644 struct sir_channel_chanege_rsp *params;
3645
3646 params = vos_mem_malloc(sizeof(*params));
3647 if (!params) {
3648 limLog(mac_ctx, LOGE, FL("AllocateMemory failed for pSmeSwithChnlParams"));
3649 return;
3650 }
3651
3652 params->sme_session_id = session->smeSessionId;
3653 params->new_channel = chan_params->channelNumber;
3654 params->status = chan_params->status;
3655
3656 msg.type = eWNI_SME_ECSA_CHAN_CHANGE_RSP;
3657 msg.bodyptr = params;
3658 msg.bodyval = 0;
3659 limSysProcessMmhMsgApi(mac_ctx, &msg, ePROT);
3660
3661 if (chan_params->channelNumber == session->currentOperChannel) {
3662 limApplyConfiguration(mac_ctx, session);
3663 limSendBeaconInd(mac_ctx, session);
3664 } else {
3665 limLog(mac_ctx, LOGE, FL("channel switch resp chan %d and session channel doesnt match %d"),
3666 chan_params->channelNumber, session->currentOperChannel);
3667 }
3668
3669 return;
3670}
3671
3672
Jeff Johnson295189b2012-06-20 16:38:30 -07003673/**
3674 * limProcessMlmDeauthReq()
3675 *
3676 *FUNCTION:
3677 * This function is called to process MLM_DEAUTH_REQ message
3678 * from SME
3679 *
3680 *LOGIC:
3681 *
3682 *ASSUMPTIONS:
3683 *
3684 *NOTE:
3685 *
3686 * @param pMac Pointer to Global MAC structure
3687 * @param *pMsgBuf A pointer to the MLM message buffer
3688 * @return None
3689 */
3690
3691static void
3692limProcessMlmDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3693{
3694// tANI_U16 aid;
3695// tSirMacAddr currentBssId;
3696// tpDphHashNode pStaDs;
3697// struct tLimPreAuthNode *pAuthNode;
3698 tLimMlmDeauthReq *pMlmDeauthReq;
3699// tLimMlmDeauthCnf mlmDeauthCnf;
3700 tpPESession psessionEntry;
3701
3702 if(pMsgBuf == NULL)
3703 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003704 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 return;
3706 }
3707
3708 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3709
Abhishek Singhcd09b562013-12-24 16:02:20 +05303710 limLog(pMac, LOG1,FL("Process Deauth Req on sessionID %d "
3711 "from: "MAC_ADDRESS_STR), pMlmDeauthReq->sessionId,
3712 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3715 {
3716
Abhishek Singhcd09b562013-12-24 16:02:20 +05303717 limLog(pMac, LOGE, FL("session does not exist for given sessionId %d"),
3718 pMlmDeauthReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 return;
3720 }
Madan Mohan Koyyalamudi27ecc282012-11-06 15:07:28 -08003721 limProcessMlmDeauthReqNtf( pMac, eHAL_STATUS_SUCCESS, (tANI_U32*) pMsgBuf );
3722
Jeff Johnson295189b2012-06-20 16:38:30 -07003723} /*** limProcessMlmDeauthReq() ***/
3724
3725
3726
3727/**
3728 * @function : limProcessMlmSetKeysReq()
3729 *
3730 * @brief : This function is called to process MLM_SETKEYS_REQ message
3731 * from SME
3732 *
3733 *LOGIC:
3734 *
3735 *ASSUMPTIONS:
3736 *
3737 *NOTE:
3738 *
3739 * @param pMac Pointer to Global MAC structure
3740 * @param *pMsgBuf A pointer to the MLM message buffer
3741 * @return None
3742 */
3743
3744static void
3745limProcessMlmSetKeysReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3746{
3747tANI_U16 aid;
3748tANI_U16 staIdx = 0;
3749tANI_U32 defaultKeyId = 0;
3750tSirMacAddr currentBssId;
3751tpDphHashNode pStaDs;
3752tLimMlmSetKeysReq *pMlmSetKeysReq;
3753tLimMlmSetKeysCnf mlmSetKeysCnf;
3754tpPESession psessionEntry;
3755
3756 if(pMsgBuf == NULL)
3757 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003758 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 return;
3760 }
3761
3762
3763 pMlmSetKeysReq = (tLimMlmSetKeysReq *) pMsgBuf;
3764 // Hold onto the SetKeys request parameters
3765 pMac->lim.gpLimMlmSetKeysReq = (void *) pMlmSetKeysReq;
3766
3767 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmSetKeysReq->sessionId))== NULL)
3768 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003769 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 return;
3771 }
3772
3773 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003774 FL( "Received MLM_SETKEYS_REQ with parameters:"
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "),
3776 pMlmSetKeysReq->aid,
3777 pMlmSetKeysReq->edType,
3778 pMlmSetKeysReq->numKeys );
3779 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3780
3781 #if 0
3782 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, currentBssId, &cfg )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003783 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 return;
3785 }
3786 #endif //TO SUPPORT BT-AMP
3787 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3788
3789 switch( psessionEntry->limSystemRole ) {
3790 case eLIM_STA_ROLE:
3791 case eLIM_BT_AMP_STA_ROLE:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003792 //In case of TDLS, peerMac address need not be BssId. Skip this check
3793 //if TDLS is enabled.
3794#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 if((!limIsAddrBC( pMlmSetKeysReq->peerMacAddr ) ) &&
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303796 (!vos_mem_compare(pMlmSetKeysReq->peerMacAddr,
3797 currentBssId, sizeof(tSirMacAddr))) ){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003798 limLog( pMac, LOGW, FL("Received MLM_SETKEYS_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3800
3801 // Prepare and Send LIM_MLM_SETKEYS_CNF with error code
3802 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3803 goto end;
3804 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003805#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 // Fall thru' & 'Plumb' keys below
3807 break;
3808 case eLIM_STA_IN_IBSS_ROLE:
3809 default: // others
3810 // Fall thru...
3811 break;
3812 }
3813
3814 /**
3815 * Use the "unicast" parameter to determine if the "Group Keys"
3816 * are being set.
3817 * pMlmSetKeysReq->key.unicast = 0 -> Multicast/broadcast
3818 * pMlmSetKeysReq->key.unicast - 1 -> Unicast keys are being set
3819 */
3820 if( limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003821 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "), pMlmSetKeysReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 /** When trying to set Group Keys for any
3823 * security mode other than WEP, use the
3824 * STA Index corresponding to the AP...
3825 */
3826 switch( pMlmSetKeysReq->edType ) {
3827 case eSIR_ED_CCMP:
3828
3829#ifdef WLAN_FEATURE_11W
3830 case eSIR_ED_AES_128_CMAC:
3831#endif
3832 staIdx = psessionEntry->staId;
3833 break;
3834
3835 default:
3836 break;
3837 }
3838 }else {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003839 limLog( pMac, LOG1, FL("Trying to set Unicast Keys..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 /**
3841 * Check if there exists a context for the
3842 * peer entity for which keys need to be set.
3843 */
3844
3845
3846 pStaDs = dphLookupHashEntry( pMac, pMlmSetKeysReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
3847
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 if ((pStaDs == NULL) ||
3849 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) && (psessionEntry->limSystemRole != eLIM_AP_ROLE))) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 /**
3851 * Received LIM_MLM_SETKEYS_REQ for STA
3852 * that does not have context or in some
3853 * transit state. Log error.
3854 */
3855 limLog( pMac, LOG1,
3856 FL("Received MLM_SETKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3857 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3858
3859 // Prepare and Send LIM_MLM_SETKEYS_CNF
3860 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3861 goto end;
3862 } else
3863 staIdx = pStaDs->staIndex;
3864 }
3865
3866 if ((pMlmSetKeysReq->numKeys == 0) && (pMlmSetKeysReq->edType != eSIR_ED_NONE)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003867 //
3868 // Broadcast/Multicast Keys (for WEP!!) are NOT sent
3869 // via this interface!!
3870 //
3871 // This indicates to HAL that the WEP Keys need to be
3872 // extracted from the CFG and applied to hardware
3873 defaultKeyId = 0xff;
3874 }else if(pMlmSetKeysReq->key[0].keyId &&
3875 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
3876 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))){
3877 /* If the Key Id is non zero and encryption mode is WEP,
3878 * the key index is coming from the upper layers so that key only
3879 * need to be used as the default tx key, This is being used only
3880 * in case of WEP mode in HAL */
3881 defaultKeyId = pMlmSetKeysReq->key[0].keyId;
3882 }else
3883 defaultKeyId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003884
3885 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003886 FL( "Trying to set keys for STA Index [%d], using defaultKeyId [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 staIdx,
3888 defaultKeyId );
3889
3890 if(limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
3891 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3892 psessionEntry->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003893 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003894 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 psessionEntry->peSessionId);
3896
3897 // Package WDA_SET_BSSKEY_REQ message parameters
3898 limSendSetBssKeyReq(pMac, pMlmSetKeysReq,psessionEntry);
3899 return;
3900 }else {
3901 // Package WDA_SET_STAKEY_REQ / WDA_SET_STA_BCASTKEY_REQ message parameters
3902 limSendSetStaKeyReq(pMac, pMlmSetKeysReq, staIdx, (tANI_U8) defaultKeyId,psessionEntry);
3903 return;
3904 }
3905
3906end:
3907 mlmSetKeysCnf.sessionId= pMlmSetKeysReq->sessionId;
3908 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
3909
3910} /*** limProcessMlmSetKeysReq() ***/
3911
3912/**
3913 * limProcessMlmRemoveKeyReq()
3914 *
3915 *FUNCTION:
3916 * This function is called to process MLM_REMOVEKEY_REQ message
3917 * from SME
3918 *
3919 *LOGIC:
3920 *
3921 *ASSUMPTIONS:
3922 *
3923 *NOTE:
3924 *
3925 * @param pMac Pointer to Global MAC structure
3926 * @param *pMsgBuf A pointer to the MLM message buffer
3927 * @return None
3928 */
3929
3930static void
3931limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3932{
3933tANI_U16 aid;
3934tANI_U16 staIdx = 0;
3935tSirMacAddr currentBssId;
3936tpDphHashNode pStaDs;
3937tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3938tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
3939 tpPESession psessionEntry;
3940
3941 if(pMsgBuf == NULL)
3942 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003943 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 return;
3945 }
3946
3947 pMlmRemoveKeyReq = (tLimMlmRemoveKeyReq *) pMsgBuf;
3948
3949
3950 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyReq->sessionId))== NULL)
3951 {
3952 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003953 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303954 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 return;
3956 }
3957
3958
3959 if( pMac->lim.gpLimMlmRemoveKeyReq != NULL )
3960 {
3961 // Free any previous requests.
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303962 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
3964 }
3965 // Hold onto the RemoveKeys request parameters
3966 pMac->lim.gpLimMlmRemoveKeyReq = (void *) pMlmRemoveKeyReq;
3967
3968 #if 0
3969 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
3970 WNI_CFG_BSSID,
3971 currentBssId,
3972 &cfg ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003973 limLog( pMac, LOGP, FL("Could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 #endif //TO-SUPPORT BT-AMP
3975 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3976
3977 switch( psessionEntry->limSystemRole )
3978 {
3979 case eLIM_STA_ROLE:
3980 case eLIM_BT_AMP_STA_ROLE:
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05303981 if (( limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr ) != true ) &&
3982 (!vos_mem_compare(pMlmRemoveKeyReq->peerMacAddr,
3983 currentBssId,
3984 sizeof(tSirMacAddr))))
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 {
3986 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003987 FL("Received MLM_REMOVEKEY_REQ with invalid BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
3989
3990 // Prepare and Send LIM_MLM_REMOVEKEY_CNF with error code
3991 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3992 goto end;
3993 }
3994 break;
3995
3996 case eLIM_STA_IN_IBSS_ROLE:
3997 default: // eLIM_AP_ROLE
3998 // Fall thru...
3999 break;
4000 }
4001
4002
4003 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
4004 if(limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr )) //Second condition for IBSS or AP role.
4005 {
4006 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004007 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 // Package WDA_REMOVE_BSSKEY_REQ message parameters
4009 limSendRemoveBssKeyReq( pMac,pMlmRemoveKeyReq,psessionEntry);
4010 return;
4011 }
4012
4013 /**
4014 * Check if there exists a context for the
4015 * peer entity for which keys need to be removed.
4016 */
4017 pStaDs = dphLookupHashEntry( pMac, pMlmRemoveKeyReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4018 if ((pStaDs == NULL) ||
4019 (pStaDs &&
4020 (pStaDs->mlmStaContext.mlmState !=
4021 eLIM_MLM_LINK_ESTABLISHED_STATE)))
4022 {
4023 /**
4024 * Received LIM_MLM_REMOVEKEY_REQ for STA
4025 * that does not have context or in some
4026 * transit state. Log error.
4027 */
4028 limLog( pMac, LOGW,
4029 FL("Received MLM_REMOVEKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
4030 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
4031
4032 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
4033 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4034 mlmRemoveKeyCnf.sessionId = pMlmRemoveKeyReq->sessionId;
4035
4036
4037 goto end;
4038 }
4039 else
4040 staIdx = pStaDs->staIndex;
4041
4042
4043
4044 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004045 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004046
4047 // Package WDA_REMOVE_STAKEY_REQ message parameters
4048 limSendRemoveStaKeyReq( pMac,pMlmRemoveKeyReq,staIdx,psessionEntry);
4049 return;
4050
4051end:
4052 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07004053 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 pMlmRemoveKeyReq,
4055 &mlmRemoveKeyCnf );
4056
4057} /*** limProcessMlmRemoveKeyReq() ***/
4058
4059
4060/**
4061 * limProcessMinChannelTimeout()
4062 *
4063 *FUNCTION:
4064 * This function is called to process Min Channel Timeout
4065 * during channel scan.
4066 *
4067 *LOGIC:
4068 *
4069 *ASSUMPTIONS:
4070 *
4071 *NOTE:
4072 *
4073 * @param pMac Pointer to Global MAC structure
4074 * @return None
4075 */
4076
4077static void
4078limProcessMinChannelTimeout(tpAniSirGlobal pMac)
4079{
4080 tANI_U8 channelNum;
4081
4082#ifdef GEN6_TODO
4083 //if the min Channel is maintained per session, then use the below seesionEntry
4084 //priority - LOW/might not be needed
4085
4086 //TBD-RAJESH HOW TO GET sessionEntry?????
4087 tpPESession psessionEntry;
4088
4089 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimMinChannelTimer.sessionId))== NULL)
4090 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004091 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 return;
4093 }
4094#endif
4095
Abhishek Singh89e1d672013-11-28 15:13:42 +05304096 /*do not process if we are in finish scan wait state i.e.
4097 scan is aborted or finished*/
4098 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE &&
4099 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 /// Min channel timer timed out
4102 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
4103 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
4104 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05304105 /*
4106 * Deactivate Max Channel timer as well since no probe resp/beacons
4107 * are received.
4108 */
4109 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004110 pMac->lim.probeCounter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 if (pMac->lim.gLimCurrentScanChannelId <=
4112 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4113 {
4114 channelNum = (tANI_U8)limGetCurrentScanChannel(pMac);
4115 }
4116 else
4117 {
4118 // This shouldn't be the case, but when this happens, this timeout should be for the last channelId.
4119 // Get the channelNum as close to correct as possible.
4120 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
4121 {
4122 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
4123 }
4124 else
4125 {
4126 channelNum = 1;
4127 }
4128 }
4129
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004130 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304131 FL("Sending End Scan req from MIN_CH_TIMEOUT in state %d ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004132 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4134 }
4135 else
4136 {
4137 /**
4138 * MIN channel timer should not have timed out
4139 * in states other than wait_probe_response.
4140 * Log error.
4141 */
4142 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304143 FL("received unexpected MIN channel timeout in mlme state %d and hal scan State %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304144 pMac->lim.gLimMlmState,pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 limPrintMlmState(pMac, LOGE, pMac->lim.gLimMlmState);
4146 }
4147} /*** limProcessMinChannelTimeout() ***/
4148
4149
4150
4151/**
4152 * limProcessMaxChannelTimeout()
4153 *
4154 *FUNCTION:
4155 * This function is called to process Max Channel Timeout
4156 * during channel scan.
4157 *
4158 *LOGIC:
4159 *
4160 *ASSUMPTIONS:
4161 *
4162 *NOTE:
4163 *
4164 * @param pMac Pointer to Global MAC structure
4165 * @return None
4166 */
4167
4168static void
4169limProcessMaxChannelTimeout(tpAniSirGlobal pMac)
4170{
4171 tANI_U8 channelNum;
4172
Abhishek Singh89e1d672013-11-28 15:13:42 +05304173 /*do not process if we are in finish scan wait state i.e.
4174 scan is aborted or finished*/
4175 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE ||
4176 pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE) &&
4177 pMac->lim.gLimHalScanState != eLIM_HAL_FINISH_SCAN_WAIT_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304179 limLog(pMac, LOG1, FL("Scanning : Max channel timed out"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 /**
4181 * MAX channel timer timed out
4182 * Continue channel scan.
4183 */
4184 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
4185 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
4186 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004187 pMac->lim.probeCounter = 0;
4188
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004189 if (pMac->lim.gLimCurrentScanChannelId <=
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
4191 {
4192 channelNum = limGetCurrentScanChannel(pMac);
4193 }
4194 else
4195 {
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 }
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004205 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304206 FL("Sending End Scan req from MAX_CH_TIMEOUT in state %d on ch-%d"),
Praveen Kumar Sirisillaac600a82013-10-18 11:07:47 -07004207 pMac->lim.gLimMlmState,channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
4209 }
4210 else
4211 {
4212 /**
4213 * MAX channel timer should not have timed out
4214 * in states other than wait_scan.
4215 * Log error.
4216 */
4217 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304218 FL("received unexpected MAX channel timeout in mlme state %d and hal scan state %d"),
Abhishek Singh89e1d672013-11-28 15:13:42 +05304219 pMac->lim.gLimMlmState, pMac->lim.gLimHalScanState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
4221 }
4222} /*** limProcessMaxChannelTimeout() ***/
4223
4224/**
4225 * limProcessPeriodicProbeReqTimer()
4226 *
4227 *FUNCTION:
4228 * This function is called to process periodic probe request
4229 * to send during scan.
4230 *
4231 *LOGIC:
4232 *
4233 *ASSUMPTIONS:
4234 *
4235 *NOTE:
4236 *
4237 * @param pMac Pointer to Global MAC structure
4238 * @return None
4239 */
4240
4241static void
4242limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac)
4243{
4244 tANI_U8 channelNum;
4245 tANI_U8 i = 0;
4246 tSirRetStatus status = eSIR_SUCCESS;
4247 TX_TIMER *pPeriodicProbeReqTimer;
4248 pPeriodicProbeReqTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
4249
4250 if(vos_timer_getCurrentState(&pPeriodicProbeReqTimer->vosTimer)
4251 != VOS_TIMER_STATE_STOPPED)
4252 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304253 limLog(pMac, LOG1, FL("Invalid state of timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 return;
4255 }
4256
4257 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004258 (pPeriodicProbeReqTimer->sessionId != 0xff) && (pMac->lim.probeCounter < pMac->lim.maxProbe))
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 {
4260 tLimMlmScanReq *pLimMlmScanReq = pMac->lim.gpLimMlmScanReq;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -08004261 pMac->lim.probeCounter++;
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 /**
4263 * Periodic channel timer timed out
4264 * to send probe request.
4265 */
4266 channelNum = limGetCurrentScanChannel(pMac);
Abhishek Singh795e1b82015-09-25 15:35:03 +05304267 /* Prepare and send Probe Request frame for all the SSIDs
4268 * present in the saved MLM
4269 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 do
4271 {
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304272 tSirMacAddr gSelfMacAddr;
4273 bool spoof = lim_is_spoofing_needed(pMac);
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304274
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05304275 if (spoof)
4276 vos_mem_copy(gSelfMacAddr, pMac->lim.spoofMacAddr,
4277 VOS_MAC_ADDRESS_LEN);
4278 else
4279 vos_mem_copy(gSelfMacAddr, pMac->lim.gSelfMacAddr,
4280 VOS_MAC_ADDRESS_LEN);
4281
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304282 limLog( pMac, LOG1, FL("Mac Addr used in Probe Req is :"MAC_ADDRESS_STR),
4283 MAC_ADDR_ARRAY(gSelfMacAddr));
4284
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 /*
4286 * PELOGE(limLog(pMac, LOGW, FL("sending ProbeReq number %d,"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004287 * " for SSID %s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 * i, pLimMlmScanReq->ssId[i].ssId,
4289 * channelNum);)
4290 */
4291 status = limSendProbeReqMgmtFrame( pMac, &pLimMlmScanReq->ssId[i],
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05304292 pLimMlmScanReq->bssId, channelNum, gSelfMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 pLimMlmScanReq->dot11mode, pLimMlmScanReq->uIEFieldLen,
4294 (tANI_U8 *)(pLimMlmScanReq) + pLimMlmScanReq->uIEFieldOffset);
4295
4296
4297 if ( status != eSIR_SUCCESS)
4298 {
4299 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID "
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004300 "%s on channel: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 pLimMlmScanReq->ssId[i].ssId,
4302 channelNum);)
4303 return;
4304 }
4305 i++;
4306 } while (i < pLimMlmScanReq->numSsid);
4307
4308 /* Activate timer again */
4309 if (tx_timer_activate(pPeriodicProbeReqTimer) != TX_SUCCESS)
4310 {
4311 limLog(pMac, LOGP, FL("could not start periodic probe"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004312 " req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 return;
4314 }
4315 }
4316 else
4317 {
4318 /**
4319 * Periodic scan is timeout is happening in
4320 * in states other than wait_scan.
4321 * Log error.
4322 */
Mohit Khanna23863762012-09-11 17:40:09 -07004323 limLog(pMac, LOG1,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304324 FL("received unexpected Periodic scan timeout in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 pMac->lim.gLimMlmState);
4326 }
4327} /*** limProcessPeriodicProbeReqTimer() ***/
4328
4329/**
4330 * limProcessJoinFailureTimeout()
4331 *
4332 *FUNCTION:
4333 * This function is called to process JoinFailureTimeout
4334 *
4335 *LOGIC:
4336 *
4337 *ASSUMPTIONS:
4338 *
4339 *NOTE:
4340 *
4341 * @param pMac Pointer to Global MAC structure
4342 * @return None
4343 */
4344
4345static void
4346limProcessJoinFailureTimeout(tpAniSirGlobal pMac)
4347{
4348 tLimMlmJoinCnf mlmJoinCnf;
4349 tSirMacAddr bssid;
4350 tANI_U32 len;
krunal soni8d13b092013-07-19 13:23:29 -07004351#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4352 vos_log_rssi_pkt_type *pRssiLog = NULL;
4353#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004354
4355 //fetch the sessionEntry based on the sessionId
4356 tpPESession psessionEntry;
4357
4358 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimJoinFailureTimer.sessionId))== NULL)
4359 {
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07004360 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 return;
4362 }
krunal soni8d13b092013-07-19 13:23:29 -07004363
4364#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4365 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4366 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4367 if (pRssiLog)
4368 {
4369 pRssiLog->rssi = psessionEntry->rssi;
4370 }
4371 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4372#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4373
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
4375 {
4376 len = sizeof(tSirMacAddr);
4377
4378 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, bssid, &len) !=
4379 eSIR_SUCCESS)
4380 {
4381 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004382 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 return;
4384 }
4385
4386 // 'Change' timer for future activations
4387 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004388 // Change Periodic probe req timer for future activation
4389 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 /**
4391 * Issue MLM join confirm with timeout reason code
4392 */
Kiet Lam82004c62013-11-11 13:24:28 +05304393 PELOGE(limLog(pMac, LOGE, FL(" In state eLIM_MLM_WT_JOIN_BEACON_STATE."));)
4394 PELOGE(limLog(pMac, LOGE, FL(" Join Failure Timeout occurred for session %d with BSS "),
4395 psessionEntry->peSessionId);
4396 limPrintMacAddr(pMac, psessionEntry->bssId, LOGE);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004397
4398 mlmJoinCnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
4399 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4400
4401 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004402 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
4404 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004405 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 /* Update PE session Id */
4407 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
4408
4409
4410 // Freeup buffer allocated to join request
4411 if (psessionEntry->pLimMlmJoinReq)
4412 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304413 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 psessionEntry->pLimMlmJoinReq = NULL;
4415 }
4416
4417 limPostSmeMessage(pMac,
4418 LIM_MLM_JOIN_CNF,
4419 (tANI_U32 *) &mlmJoinCnf);
4420
4421 return;
4422 }
4423 else
4424 {
4425 /**
4426 * Join failure timer should not have timed out
4427 * in states other than wait_join_beacon state.
4428 * Log error.
4429 */
4430 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304431 FL("received unexpected JOIN failure timeout in state %d"),psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4433 }
4434} /*** limProcessJoinFailureTimeout() ***/
4435
4436
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004437/**
4438 * limProcessPeriodicJoinProbeReqTimer()
4439 *
4440 *FUNCTION:
4441 * This function is called to process periodic probe request
4442 * send during joining process.
4443 *
4444 *LOGIC:
4445 *
4446 *ASSUMPTIONS:
4447 *
4448 *NOTE:
4449 *
4450 * @param pMac Pointer to Global MAC structure
4451 * @return None
4452 */
4453
4454static void limProcessPeriodicJoinProbeReqTimer(tpAniSirGlobal pMac)
4455{
4456 tpPESession psessionEntry;
4457 tSirMacSSid ssId;
4458
4459 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId))== NULL)
4460 {
Kiet Lam82004c62013-11-11 13:24:28 +05304461 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4462 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004463 return;
4464 }
4465
4466 if((VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)) &&
4467 (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE))
4468 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304469 vos_mem_copy(ssId.ssId,
4470 psessionEntry->ssId.ssId,
4471 psessionEntry->ssId.length);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004472 ssId.length = psessionEntry->ssId.length;
4473
4474 limSendProbeReqMgmtFrame( pMac, &ssId,
4475 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
4476 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
4477 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
4478
4479 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
4480
4481 // Activate Join Periodic Probe Req timer
4482 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
4483 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004484 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer"));
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08004485 return;
4486 }
4487 }
4488 return;
4489} /*** limProcessPeriodicJoinProbeReqTimer() ***/
4490
Sushant Kaushik9e923872015-04-02 17:09:31 +05304491/**
4492 * limProcessAuthRetryTimer()
4493 *
4494 *FUNCTION:
4495 * This function is called to process Auth Retry request
4496 * send during joining process.
4497 *
4498 *LOGIC:
4499 *
4500 *ASSUMPTIONS:
4501 *
4502 *NOTE:
4503 *
4504 * @param pMac Pointer to Global MAC structure
4505 * @return None
4506 */
4507
4508static void limProcessAuthRetryTimer(tpAniSirGlobal pMac)
4509{
4510 tpPESession psessionEntry;
4511 limLog(pMac, LOG1, FL(" ENTER "));
4512 if ((psessionEntry =
4513 peFindSessionBySessionId(pMac,
4514 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId)) == NULL)
4515 {
4516 limLog(pMac, LOGE,FL("session does not exist for given SessionId : %d"),
4517 pMac->lim.limTimers.gLimPeriodicAuthRetryTimer.sessionId);
4518 return;
4519 }
4520
4521 if ((VOS_TRUE ==
4522 tx_timer_running(&pMac->lim.limTimers.gLimAuthFailureTimer)) &&
4523 (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
4524 (LIM_AUTH_ACK_RCD_SUCCESS != pMac->authAckStatus))
4525 {
4526 tSirMacAuthFrameBody authFrameBody;
4527
4528 /* Send the auth retry only in case we have received ack failure
4529 * else just restart the retry timer.
4530 */
4531 if (LIM_AUTH_ACK_RCD_FAILURE == pMac->authAckStatus)
4532 {
4533 /// Prepare & send Authentication frame
4534 authFrameBody.authAlgoNumber =
4535 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
4536 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
4537 authFrameBody.authStatusCode = 0;
4538 limLog(pMac, LOGW, FL("Retry Auth "));
4539 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
4540 limSendAuthMgmtFrame(pMac,
4541 &authFrameBody,
4542 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
4543 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_TRUE);
4544 }
4545
4546 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
4547
4548 // Activate Auth Retry timer
4549 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicAuthRetryTimer)
4550 != TX_SUCCESS)
4551 {
4552 limLog(pMac, LOGE,
4553 FL("could not activate Auth Retry failure timer"));
4554 return;
4555 }
4556 }
4557 return;
4558} /*** limProcessAuthRetryTimer() ***/
4559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560
4561/**
4562 * limProcessAuthFailureTimeout()
4563 *
4564 *FUNCTION:
4565 * This function is called to process Min Channel Timeout
4566 * during channel scan.
4567 *
4568 *LOGIC:
4569 *
4570 *ASSUMPTIONS:
4571 *
4572 *NOTE:
4573 *
4574 * @param pMac Pointer to Global MAC structure
4575 * @return None
4576 */
4577
4578static void
4579limProcessAuthFailureTimeout(tpAniSirGlobal pMac)
4580{
4581 //fetch the sessionEntry based on the sessionId
4582 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004583#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4584 vos_log_rssi_pkt_type *pRssiLog = NULL;
4585#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAuthFailureTimer.sessionId))== NULL)
4587 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004588 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 return;
4590 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304591 limLog(pMac, LOGE, FL("received AUTH failure timeout in sessionid %d "
Sushant Kaushik1b645382014-10-13 16:39:36 +05304592 "limMlmstate %d limSmeState %d"), psessionEntry->peSessionId,
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304593 psessionEntry->limMlmState, psessionEntry->limSmeState);
krunal soni8d13b092013-07-19 13:23:29 -07004594#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4595 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4596 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4597 if (pRssiLog)
4598 {
4599 pRssiLog->rssi = psessionEntry->rssi;
4600 }
4601 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4602#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4603
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 switch (psessionEntry->limMlmState)
4605 {
4606 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
4607 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
4608 /**
4609 * Requesting STA did not receive next auth frame
4610 * before Auth Failure timeout.
4611 * Issue MLM auth confirm with timeout reason code
4612 */
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08004613 //Restore default failure timeout
4614 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
4615 {
4616 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
4617 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
4618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 limRestoreFromAuthState(pMac,eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
4620 break;
4621
4622 default:
4623 /**
4624 * Auth failure timer should not have timed out
4625 * in states other than wt_auth_frame2/4
4626 * Log error.
4627 */
Sushant Kaushik1b645382014-10-13 16:39:36 +05304628 PELOGE(limLog(pMac, LOGE, FL("received unexpected AUTH failure timeout in state %d"), psessionEntry->limMlmState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
4630
4631 break;
4632 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304633 /* Reinit scan results to remove the unreachable BSS */
4634 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004635} /*** limProcessAuthFailureTimeout() ***/
4636
4637
4638
4639/**
4640 * limProcessAuthRspTimeout()
4641 *
4642 *FUNCTION:
4643 * This function is called to process Min Channel Timeout
4644 * during channel scan.
4645 *
4646 *LOGIC:
4647 *
4648 *ASSUMPTIONS:
4649 *
4650 *NOTE:
4651 *
4652 * @param pMac Pointer to Global MAC structure
4653 * @return None
4654 */
4655
4656static void
4657limProcessAuthRspTimeout(tpAniSirGlobal pMac, tANI_U32 authIndex)
4658{
4659 struct tLimPreAuthNode *pAuthNode;
4660 tpPESession psessionEntry;
4661 tANI_U8 sessionId;
4662
4663 pAuthNode = limGetPreAuthNodeFromIndex(pMac, &pMac->lim.gLimPreAuthTimerTable, authIndex);
4664
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304665 if (NULL == pAuthNode)
4666 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004667 limLog(pMac, LOGW, FL("Invalid auth node"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304668 return;
4669 }
4670
4671 if ((psessionEntry = peFindSessionByBssid(pMac, pAuthNode->peerMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004673 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 return;
4675 }
4676
4677 if (psessionEntry->limSystemRole == eLIM_AP_ROLE ||
4678 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
4679 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304680 if (pAuthNode->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 {
4682 /**
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304683 * Authentication response timer timedout
4684 * in unexpected state. Log error
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 */
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304686 PELOGE(limLog(pMac, LOGE,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304687 FL("received AUTH rsp timeout in unexpected state "
4688 "for MAC address: "MAC_ADDRESS_STR),
4689 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 }
4691 else
4692 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304693 // Authentication response timer
4694 // timedout for an STA.
4695 pAuthNode->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
4696 pAuthNode->fTimerStarted = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304697 limLog(pMac, LOG1,
Abhishek Singhcd09b562013-12-24 16:02:20 +05304698 FL("AUTH rsp timedout for MAC address "MAC_ADDRESS_STR),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304699 MAC_ADDR_ARRAY(pAuthNode->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004700
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304701 // Change timer to reactivate it in future
4702 limDeactivateAndChangePerStaIdTimer(pMac,
4703 eLIM_AUTH_RSP_TIMER,
4704 pAuthNode->authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004705
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304706 limDeletePreAuthNode(pMac, pAuthNode->peerMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 }
4708 }
4709} /*** limProcessAuthRspTimeout() ***/
4710
4711
4712/**
4713 * limProcessAssocFailureTimeout()
4714 *
4715 *FUNCTION:
4716 * This function is called to process Min Channel Timeout
4717 * during channel scan.
4718 *
4719 *LOGIC:
4720 *
4721 *ASSUMPTIONS:
4722 *
4723 *NOTE:
4724 *
4725 * @param pMac Pointer to Global MAC structure
4726 * @return None
4727 */
4728
4729static void
4730limProcessAssocFailureTimeout(tpAniSirGlobal pMac, tANI_U32 MsgType)
4731{
4732
4733 tLimMlmAssocCnf mlmAssocCnf;
4734 tpPESession psessionEntry;
krunal soni8d13b092013-07-19 13:23:29 -07004735#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4736 vos_log_rssi_pkt_type *pRssiLog = NULL;
4737#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
Jeff Johnson295189b2012-06-20 16:38:30 -07004738
4739 //to fetch the lim/mlm state based on the sessionId, use the below sessionEntry
4740 tANI_U8 sessionId;
4741
4742 if(MsgType == LIM_ASSOC)
4743 {
4744 sessionId = pMac->lim.limTimers.gLimAssocFailureTimer.sessionId;
4745 }
4746 else
4747 {
4748 sessionId = pMac->lim.limTimers.gLimReassocFailureTimer.sessionId;
4749 }
4750
4751 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
4752 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004753 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 return;
4755 }
krunal soni8d13b092013-07-19 13:23:29 -07004756#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT_LIM
4757 WLAN_VOS_DIAG_LOG_ALLOC(pRssiLog,
4758 vos_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
4759 if (pRssiLog)
4760 {
4761 pRssiLog->rssi = psessionEntry->rssi;
4762 }
4763 WLAN_VOS_DIAG_LOG_REPORT(pRssiLog);
4764#endif //FEATURE_WLAN_DIAG_SUPPORT_LIM
4765
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 /**
4767 * Expected Re/Association Response frame
4768 * not received within Re/Association Failure Timeout.
4769 */
4770
4771
4772
4773
Abhishek Singh70af9c72016-03-09 17:23:30 +05304774 /*
4775 * CR: vos packet memory is leaked when assoc rsp timeouted/failed.
4776 * notify TL that association is failed so that TL can flush the
4777 * cached frame
4778 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 WLANTL_AssocFailed (psessionEntry->staId);
4780
Abhishek Singh70af9c72016-03-09 17:23:30 +05304781 /* Log error */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304782 limLog(pMac, LOG1,
4783 FL("Re/Association Response not received before timeout "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004784
Abhishek Singh70af9c72016-03-09 17:23:30 +05304785 /*
4786 * Send Deauth to handle the scenareo where association timeout happened
4787 * when device has missed the assoc resp sent by peer.
4788 * By sending deauth try to clear the session created on peer device.
4789 */
4790 limLog(pMac, LOGE,
4791 FL("Sessionid: %d try sending Send deauth on channel %d to BSSID: "
4792 MAC_ADDRESS_STR ), psessionEntry->peSessionId,
4793 psessionEntry->currentOperChannel,
4794 MAC_ADDR_ARRAY(psessionEntry->bssId));
4795
4796 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
4797 psessionEntry->bssId,
4798 psessionEntry, FALSE);
4799
4800 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4801 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )||
4802 ((psessionEntry->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
4803 (psessionEntry->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 (psessionEntry->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4805 {
4806 /**
4807 * Re/Assoc failure timer should not have timedout on AP
4808 * or in a state other than wt_re/assoc_response.
4809 */
4810
4811 // Log error
4812 limLog(pMac, LOGW,
Sushant Kaushik1b645382014-10-13 16:39:36 +05304813 FL("received unexpected REASSOC failure timeout in state %d for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 psessionEntry->limMlmState, psessionEntry->limSystemRole);
4815 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4816 }
4817 else
4818 {
4819
4820 if ((MsgType == LIM_ASSOC) ||
4821 ((MsgType == LIM_REASSOC) && (psessionEntry->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4822 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004823 PELOGE(limLog(pMac, LOGE, FL("(Re)Assoc Failure Timeout occurred."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004824
4825 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004826 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4827
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 // 'Change' timer for future activations
4829 limDeactivateAndChangeTimer(pMac, eLIM_ASSOC_FAIL_TIMER);
4830
4831 // Free up buffer allocated for JoinReq held by
4832 // MLM state machine
4833 if (psessionEntry->pLimMlmJoinReq)
4834 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304835 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 psessionEntry->pLimMlmJoinReq = NULL;
4837 }
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 //To remove the preauth node in case of fail to associate
4840 if (limSearchPreAuthList(pMac, psessionEntry->bssId))
4841 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304842 limLog(pMac, LOG1, FL(" delete pre auth node for "
4843 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 limDeletePreAuthNode(pMac, psessionEntry->bssId);
4845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004846
4847 mlmAssocCnf.resultCode =
4848 eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
4849 mlmAssocCnf.protStatusCode =
4850 eSIR_MAC_UNSPEC_FAILURE_STATUS;
4851
4852 /* Update PE session Id*/
4853 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
4854 if (MsgType == LIM_ASSOC)
4855 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4856 else
4857 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004858 /* Will come here only in case of 11r, ESE, FT when reassoc rsp
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 is not received and we receive a reassoc - timesout */
4860 mlmAssocCnf.resultCode = eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
4861 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4862 }
4863 }
4864 else
4865 {
4866 /**
4867 * Restore pre-reassoc req state.
4868 * Set BSSID to currently associated AP address.
4869 */
4870 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004871 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004872
4873 limRestorePreReassocState(pMac,
4874 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry);
4875 }
4876 }
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05304877 /* Reinit scan results to remove the unreachable BSS */
4878 limReInitScanResults(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879} /*** limProcessAssocFailureTimeout() ***/
4880
4881
4882
4883/**
4884 * limCompleteMlmScan()
4885 *
4886 *FUNCTION:
4887 * This function is called to send MLM_SCAN_CNF message
4888 * to SME state machine.
4889 *
4890 *LOGIC:
4891 *
4892 *ASSUMPTIONS:
4893 *
4894 *NOTE:
4895 *
4896 * @param pMac Pointer to Global MAC structure
4897 * @param retCode Result code to be sent
4898 * @return None
4899 */
4900
4901void
4902limCompleteMlmScan(tpAniSirGlobal pMac, tSirResultCodes retCode)
4903{
4904 tLimMlmScanCnf mlmScanCnf;
4905
4906 /// Restore previous MLM state
4907 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004908 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 limRestorePreScanState(pMac);
4910
4911 // Free up pMac->lim.gLimMlmScanReq
4912 if( NULL != pMac->lim.gpLimMlmScanReq )
4913 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304914 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 pMac->lim.gpLimMlmScanReq = NULL;
4916 }
4917
4918 mlmScanCnf.resultCode = retCode;
4919 mlmScanCnf.scanResultLength = pMac->lim.gLimMlmScanResultLength;
4920
4921 limPostSmeMessage(pMac, LIM_MLM_SCAN_CNF, (tANI_U32 *) &mlmScanCnf);
4922
4923} /*** limCompleteMlmScan() ***/
4924
4925/**
4926 * \brief Setup an A-MPDU/BA session
4927 *
4928 * \sa limProcessMlmAddBAReq
4929 *
4930 * \param pMac The global tpAniSirGlobal object
4931 *
4932 * \param pMsgBuf The MLME ADDBA Req message buffer
4933 *
4934 * \return none
4935 */
4936void limProcessMlmAddBAReq( tpAniSirGlobal pMac,
4937 tANI_U32 *pMsgBuf )
4938{
4939tSirRetStatus status = eSIR_SUCCESS;
4940tpLimMlmAddBAReq pMlmAddBAReq;
4941tpLimMlmAddBACnf pMlmAddBACnf;
4942 tpPESession psessionEntry;
4943
4944 if(pMsgBuf == NULL)
4945 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004946 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 return;
4948 }
4949
4950 pMlmAddBAReq = (tpLimMlmAddBAReq) pMsgBuf;
4951 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBAReq->sessionId))== NULL)
4952 {
4953 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004954 FL("session does not exist for given sessionId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304955 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 return;
4957 }
4958
4959
4960 // Send ADDBA Req over the air
4961 status = limSendAddBAReq( pMac, pMlmAddBAReq,psessionEntry);
4962
4963 //
4964 // Respond immediately to LIM, only if MLME has not been
4965 // successfully able to send WDA_ADDBA_REQ to HAL.
4966 // Else, LIM_MLM_ADDBA_CNF will be sent after receiving
4967 // ADDBA Rsp from peer entity
4968 //
4969 if( eSIR_SUCCESS != status )
4970 {
4971 // Allocate for LIM_MLM_ADDBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304972
4973 pMlmAddBACnf = vos_mem_malloc(sizeof( tLimMlmAddBACnf ));
4974 if ( NULL == pMlmAddBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 {
4976 limLog( pMac, LOGP,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004977 FL("AllocateMemory failed"));
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304978 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 return;
4980 }
4981 else
4982 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05304983 vos_mem_set((void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ), 0);
4984 vos_mem_copy((void *) pMlmAddBACnf->peerMacAddr,
4985 (void *) pMlmAddBAReq->peerMacAddr,
4986 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004987
4988 pMlmAddBACnf->baDialogToken = pMlmAddBAReq->baDialogToken;
4989 pMlmAddBACnf->baTID = pMlmAddBAReq->baTID;
4990 pMlmAddBACnf->baPolicy = pMlmAddBAReq->baPolicy;
4991 pMlmAddBACnf->baBufferSize = pMlmAddBAReq->baBufferSize;
4992 pMlmAddBACnf->baTimeout = pMlmAddBAReq->baTimeout;
4993 pMlmAddBACnf->sessionId = pMlmAddBAReq->sessionId;
4994
4995 // Update the result code
4996 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4997
4998 limPostSmeMessage( pMac,
4999 LIM_MLM_ADDBA_CNF,
5000 (tANI_U32 *) pMlmAddBACnf );
5001 }
5002
5003 // Restore MLME state
5004 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07005005 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005006
5007 }
5008
5009 // Free the buffer allocated for tLimMlmAddBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305010 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011
5012}
5013
5014/**
5015 * \brief Send an ADDBA Rsp to peer STA in response
5016 * to an ADDBA Req received earlier
5017 *
5018 * \sa limProcessMlmAddBARsp
5019 *
5020 * \param pMac The global tpAniSirGlobal object
5021 *
5022 * \param pMsgBuf The MLME ADDBA Rsp message buffer
5023 *
5024 * \return none
5025 */
5026void limProcessMlmAddBARsp( tpAniSirGlobal pMac,
5027 tANI_U32 *pMsgBuf )
5028{
5029tpLimMlmAddBARsp pMlmAddBARsp;
5030 tANI_U16 aid;
5031 tpDphHashNode pSta;
5032 tpPESession psessionEntry;
5033
5034
5035 if(pMsgBuf == NULL)
5036 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005037 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 return;
5039 }
5040
5041 pMlmAddBARsp = (tpLimMlmAddBARsp) pMsgBuf;
5042
5043 if(( psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBARsp->sessionId))== NULL)
5044 {
5045 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005046 FL("session does not exist for given session ID"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305047 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 return;
5049 }
5050
5051
5052 // Send ADDBA Rsp over the air
5053 if( eSIR_SUCCESS != limSendAddBARsp( pMac,pMlmAddBARsp,psessionEntry))
5054 {
5055 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005056 FL("Failed to send ADDBA Rsp to peer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGE );
5058 /* Clean the BA context maintained by HAL and TL on failure */
5059 pSta = dphLookupHashEntry( pMac, pMlmAddBARsp->peerMacAddr, &aid,
5060 &psessionEntry->dph.dphHashTable);
5061 if( NULL != pSta )
5062 {
5063 limPostMsgDelBAInd( pMac, pSta, pMlmAddBARsp->baTID, eBA_RECIPIENT,
5064 psessionEntry);
5065 }
5066 }
5067
5068 // Time to post a WDA_DELBA_IND to HAL in order
5069 // to cleanup the HAL and SoftMAC entries
5070
5071
5072 // Free the buffer allocated for tLimMlmAddBARsp
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305073 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005074
5075}
5076
5077/**
5078 * \brief Setup an A-MPDU/BA session
5079 *
5080 * \sa limProcessMlmDelBAReq
5081 *
5082 * \param pMac The global tpAniSirGlobal object
5083 *
5084 * \param pMsgBuf The MLME DELBA Req message buffer
5085 *
5086 * \return none
5087 */
5088void limProcessMlmDelBAReq( tpAniSirGlobal pMac,
5089 tANI_U32 *pMsgBuf )
5090{
5091 tSirRetStatus status = eSIR_SUCCESS;
5092 tpLimMlmDelBAReq pMlmDelBAReq;
5093 tpLimMlmDelBACnf pMlmDelBACnf;
5094 tpPESession psessionEntry;
5095
5096
5097 if(pMsgBuf == NULL)
5098 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005099 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 return;
5101 }
5102
5103 // TODO - Need to validate MLME state
5104 pMlmDelBAReq = (tpLimMlmDelBAReq) pMsgBuf;
5105
5106 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDelBAReq->sessionId))== NULL)
5107 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005108 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305109 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 return;
5111 }
5112
5113 // Send DELBA Ind over the air
5114 if( eSIR_SUCCESS !=
5115 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
5116 status = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
5117 else
5118 {
5119 tANI_U16 aid;
5120 tpDphHashNode pSta;
5121
5122 // Time to post a WDA_DELBA_IND to HAL in order
5123 // to cleanup the HAL and SoftMAC entries
5124 pSta = dphLookupHashEntry( pMac, pMlmDelBAReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
5125 if( NULL != pSta )
5126 {
5127 status = limPostMsgDelBAInd( pMac,
5128 pSta,
5129 pMlmDelBAReq->baTID,
5130 pMlmDelBAReq->baDirection,psessionEntry);
5131
5132 }
5133 }
5134
5135 //
5136 // Respond immediately to SME with DELBA CNF using
5137 // LIM_MLM_DELBA_CNF with appropriate status
5138 //
5139
5140 // Allocate for LIM_MLM_DELBA_CNF
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305141
5142 pMlmDelBACnf = vos_mem_malloc(sizeof( tLimMlmDelBACnf ));
5143 if ( NULL == pMlmDelBACnf )
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305145 limLog( pMac, LOGP, FL("AllocateMemory failed"));
5146 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 return;
5148 }
5149 else
5150 {
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305151 vos_mem_set((void *) pMlmDelBACnf, sizeof( tLimMlmDelBACnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005152
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305153 vos_mem_copy((void *) pMlmDelBACnf,
5154 (void *) pMlmDelBAReq,
5155 sizeof( tLimMlmDelBAReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005156
5157 // Update DELBA result code
5158 pMlmDelBACnf->delBAReasonCode = pMlmDelBAReq->delBAReasonCode;
5159
5160 /* Update PE session Id*/
5161 pMlmDelBACnf->sessionId = pMlmDelBAReq->sessionId;
5162
5163 limPostSmeMessage( pMac,
5164 LIM_MLM_DELBA_CNF,
5165 (tANI_U32 *) pMlmDelBACnf );
5166 }
5167
5168 // Free the buffer allocated for tLimMlmDelBAReq
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305169 vos_mem_free(pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005170
5171}
5172
5173/**
5174 * @function : limSMPowerSaveStateInd( )
5175 *
5176 * @brief : This function is called upon receiving the PMC Indication to update the STA's MimoPs State.
5177 *
5178 * LOGIC:
5179 *
5180 * ASSUMPTIONS:
5181 * NA
5182 *
5183 * NOTE:
5184 * NA
5185 *
5186 * @param pMac - Pointer to Global MAC structure
5187 * @param limMsg - Lim Message structure object with the MimoPSparam in body
5188 * @return None
5189 */
5190
5191tSirRetStatus
5192limSMPowerSaveStateInd(tpAniSirGlobal pMac, tSirMacHTMIMOPowerSaveState state)
5193{
5194#if 0
5195 tSirRetStatus retStatus = eSIR_SUCCESS;
5196#if 0
5197 tANI_U32 cfgVal1;
5198 tANI_U16 cfgVal2;
5199 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
5200 tpDphHashNode pSta = NULL;
5201
5202 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5203 /** Verify the Mode of operation */
5204 if (pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005205 PELOGE(limLog(pMac, LOGE, FL("Got PMC indication when System not in the STA Role"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 return eSIR_FAILURE;
5207 }
5208
5209 if ((pMac->lim.gHTMIMOPSState == state) || (state == eSIR_HT_MIMO_PS_NA )) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005210 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 -07005211 return eSIR_FAILURE;
5212 }
5213
5214 if (!pMac->lim.htCapability){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005215 PELOGW(limLog(pMac, LOGW, FL(" Not in 11n or HT capable mode"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 return eSIR_FAILURE;
5217 }
5218
5219 /** Update the CFG about the default MimoPS State */
5220 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &cfgVal1) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005221 limLog(pMac, LOGP, FL("could not retrieve HT Cap CFG "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 return eSIR_FAILURE;
5223 }
5224
5225 cfgVal2 = (tANI_U16)cfgVal1;
5226 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &cfgVal2;
5227 pHTCapabilityInfo->mimoPowerSave = state;
5228
5229 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005230 limLog(pMac, LOGP, FL("could not update HT Cap Info CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 return eSIR_FAILURE;
5232 }
5233
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005234 PELOG2(limLog(pMac, LOG2, FL(" The HT Capability for Mimo Pwr is updated to State: %u "),state);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005236 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 -07005237 /** Update in the LIM the MIMO PS state of the SELF */
5238 pMac->lim.gHTMIMOPSState = state;
5239 return eSIR_SUCCESS;
5240 }
5241
5242 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5243 if (!pSta->mlmStaContext.htCapability) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005244 limLog( pMac, LOGE,FL( "limSendSMPowerState: Peer is not HT Capable " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 return eSIR_FAILURE;
5246 }
5247
5248 if (isEnteringMimoPS(pMac->lim.gHTMIMOPSState, state)) {
5249 tSirMacAddr macAddr;
5250 /** Obtain the AP's Mac Address */
Bansidhar Gopalachari1d9c6162013-07-11 10:24:30 +05305251 vos_mem_copy((tANI_U8 *)macAddr, psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 /** Send Action Frame with the corresponding mode */
5253 retStatus = limSendSMPowerStateFrame(pMac, macAddr, state);
5254 if (retStatus != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005255 PELOGE(limLog(pMac, LOGE, "Update SM POWER: Sending Action Frame has failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 return retStatus;
5257 }
5258 }
5259
5260 /** Update MlmState about the SetMimoPS State */
5261 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
5262 pMac->lim.gLimMlmState = eLIM_MLM_WT_SET_MIMOPS_STATE;
5263 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
5264
5265 /** Update the HAL and s/w mac about the mode to be set */
5266 retStatus = limPostSMStateUpdate( pMac,psessionEntry->staId, state);
5267
5268 PELOG2(limLog(pMac, LOG2, " Updated the New SMPS State");)
5269 /** Update in the LIM the MIMO PS state of the SELF */
5270 pMac->lim.gHTMIMOPSState = state;
5271#endif
5272 return retStatus;
5273#endif
5274return eSIR_SUCCESS;
5275}
5276
Jeff Johnsone7245742012-09-05 17:12:55 -07005277#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005278ePhyChanBondState limGet11ACPhyCBState(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 htSecondaryChannelOffset,tANI_U8 peerCenterChan, tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07005279{
5280 ePhyChanBondState cbState = PHY_SINGLE_CHANNEL_CENTERED;
5281
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005282 if(!psessionEntry->apChanWidth)
Jeff Johnsone7245742012-09-05 17:12:55 -07005283 {
5284 return htSecondaryChannelOffset;
5285 }
5286
5287 if ( (htSecondaryChannelOffset
5288 == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
5289 )
5290 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005291 if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005292 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005293 else if ((channel + 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005294 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005295 else if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005296 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
5297 else
5298 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005299 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005300 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005301 }
5302 if ( (htSecondaryChannelOffset
5303 == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
5304 )
5305 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005306 if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005307 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005308 else if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005309 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005310 else if ((channel - 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07005311 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
5312 else
5313 limLog (pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005314 FL("Invalid Channel Number = %d Center Chan = %d "),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005315 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07005316 }
5317 return cbState;
5318}
5319
5320#endif
5321
Jeff Johnson295189b2012-06-20 16:38:30 -07005322void
Jeff Johnsone7245742012-09-05 17:12:55 -07005323limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005324{
5325#if !defined WLAN_FEATURE_VOWIFI
5326 tANI_U32 localPwrConstraint;
5327#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005328 tpPESession peSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07005329
Jeff Johnsone7245742012-09-05 17:12:55 -07005330 peSession = peFindSessionBySessionId (pMac, peSessionId);
5331
5332 if ( NULL == peSession)
5333 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005334 limLog (pMac, LOGP, FL("Invalid PE session = %d"), peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005335 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005337#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07005338#ifdef WLAN_FEATURE_11AC
5339 if ( peSession->vhtCapability )
5340 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005341 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005342 }
5343 else
5344#endif
5345 {
5346 limSendSwitchChnlParams( pMac, channel, secChannelOffset, maxTxPower, peSessionId);
5347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005348#else
5349 if (wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005350 limLog(pMac, LOGP, FL("could not read WNI_CFG_LOCAL_POWER_CONSTRAINT from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 return;
5352 }
5353 // Send WDA_CHNL_SWITCH_IND to HAL
Jeff Johnsone7245742012-09-05 17:12:55 -07005354#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005355 if ( peSession->vhtCapability && peSession->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07005356 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005357 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07005358 }
5359 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005360#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005361 {
5362 limSendSwitchChnlParams( pMac, channel, secChannelOffset, (tPowerdBm)localPwrConstraint, peSessionId);
5363 }
5364#endif
5365
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 }