blob: 413fb2910110acf2cd79ec21f57b5c3ab1d24ed3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * 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/*
29 * This file lim_timer_utils.cc contains the utility functions
30 * LIM uses for handling various timers.
31 * Author: Chandra Modumudi
32 * Date: 02/13/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 */
37
38#include "lim_types.h"
39#include "lim_utils.h"
40#include "lim_assoc_utils.h"
41#include "lim_security_utils.h"
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +053042#include <lim_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043
44/* channel Switch Timer in ticks */
45#define LIM_CHANNEL_SWITCH_TIMER_TICKS 1
46/* Lim Quite timer in ticks */
47#define LIM_QUIET_TIMER_TICKS 100
48/* Lim Quite BSS timer interval in ticks */
49#define LIM_QUIET_BSS_TIMER_TICK 100
50/* Lim KeepAlive timer default (3000)ms */
51#define LIM_KEEPALIVE_TIMER_MS 3000
52/* Lim JoinProbeRequest Retry timer default (200)ms */
53#define LIM_JOIN_PROBE_REQ_TIMER_MS 200
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +053054/* Lim Periodic Auth Retry timer default 60 ms */
55#define LIM_AUTH_RETRY_TIMER_MS 60
56
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +053057/*
58 * SAE auth timer of 5secs. This is required for duration of entire SAE
59 * authentication.
60 */
61#define LIM_AUTH_SAE_TIMER_MS 5000
62
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64/* This timer is a periodic timer which expires at every 1 sec to
65 convert ACTIVE DFS channel to DFS channels */
66#define ACTIVE_TO_PASSIVE_CONVERISON_TIMEOUT 1000
67
Varun Reddy Yeturu32de0e42016-04-15 14:25:59 +053068static bool lim_create_non_ap_timers(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069{
70 uint32_t cfgValue;
71 /* Create Channel Switch Timer */
Naveen Rawat22b1a932015-08-26 12:13:18 -070072 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimChannelSwitchTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 "CHANNEL SWITCH TIMER",
74 lim_channel_switch_timer_handler, 0,
75 LIM_CHANNEL_SWITCH_TIMER_TICKS,
76 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +053077 pe_err("failed to create Ch Switch timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078 return false;
79 }
80 /* Create Quiet Timer
81 * This is used on the STA to go and shut-off Tx/Rx "after" the
82 * specified quiteInterval
83 */
Naveen Rawat22b1a932015-08-26 12:13:18 -070084 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimQuietTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 "QUIET TIMER", lim_quiet_timer_handler,
86 SIR_LIM_QUIET_TIMEOUT, LIM_QUIET_TIMER_TICKS,
87 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +053088 pe_err("failed to create Quiet Begin Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 return false;
90 }
91 /* Create Quiet BSS Timer
92 * After the specified quiteInterval, determined by gLimQuietTimer, this
93 * timer, gLimQuietBssTimer, trigger and put the STA to sleep for the
94 * specified gLimQuietDuration
95 */
Naveen Rawat22b1a932015-08-26 12:13:18 -070096 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimQuietBssTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 "QUIET BSS TIMER", lim_quiet_bss_timer_handler,
98 SIR_LIM_QUIET_BSS_TIMEOUT, LIM_QUIET_BSS_TIMER_TICK,
99 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530100 pe_err("failed to create Quiet Bss Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 return false;
102 }
103
104 if (wlan_cfg_get_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
105 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530106 pe_err("could not retrieve JoinFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107 cfgValue = SYS_MS_TO_TICKS(cfgValue);
108 /* Create Join failure timer and activate it later */
Naveen Rawat22b1a932015-08-26 12:13:18 -0700109 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimJoinFailureTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110 "JOIN FAILURE TIMEOUT",
111 lim_timer_handler, SIR_LIM_JOIN_FAIL_TIMEOUT,
112 cfgValue, 0,
113 TX_NO_ACTIVATE) != TX_SUCCESS) {
114 /* / Could not create Join failure timer. */
115 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530116 pe_err("could not create Join failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 return false;
118 }
119 /* Send unicast probe req frame every 200 ms */
Naveen Rawat22b1a932015-08-26 12:13:18 -0700120 if (tx_timer_create(pMac,
121 &pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122 "Periodic Join Probe Request Timer",
123 lim_timer_handler,
124 SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT,
125 SYS_MS_TO_TICKS(LIM_JOIN_PROBE_REQ_TIMER_MS), 0,
126 TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530127 pe_err("could not create Periodic Join Probe Request tmr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 return false;
129 }
130
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530131 /* Send Auth frame every 60 ms */
132 if ((tx_timer_create(pMac,
133 &pMac->lim.limTimers.g_lim_periodic_auth_retry_timer,
134 "Periodic AUTH Timer",
135 lim_timer_handler, SIR_LIM_AUTH_RETRY_TIMEOUT,
136 SYS_MS_TO_TICKS(LIM_AUTH_RETRY_TIMER_MS), 0,
137 TX_NO_ACTIVATE)) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530138 pe_err("could not create Periodic AUTH Timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530139 return false;
140 }
141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT,
143 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530144 pe_err("could not retrieve AssocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145
146 cfgValue = SYS_MS_TO_TICKS(cfgValue);
147 /* Create Association failure timer and activate it later */
Naveen Rawat22b1a932015-08-26 12:13:18 -0700148 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimAssocFailureTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 "ASSOC FAILURE TIMEOUT",
150 lim_assoc_failure_timer_handler, LIM_ASSOC,
151 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530152 pe_err("could not create Association failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 return false;
154 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155
156 if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &cfgValue)
157 != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530158 pe_err("Fail to get WNI_CFG_ADDTS_RSP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
160 cfgValue = SYS_MS_TO_TICKS(cfgValue);
161
162 /* Create Addts response timer and activate it later */
Naveen Rawat22b1a932015-08-26 12:13:18 -0700163 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimAddtsRspTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 "ADDTS RSP TIMEOUT",
165 lim_addts_response_timer_handler,
166 SIR_LIM_ADDTS_RSP_TIMEOUT,
167 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530168 pe_err("could not create Addts response timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 return false;
170 }
171
172 if (wlan_cfg_get_int(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
173 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530174 pe_err("could not retrieve AuthFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175
176 cfgValue = SYS_MS_TO_TICKS(cfgValue);
177 /* Create Auth failure timer and activate it later */
Naveen Rawat22b1a932015-08-26 12:13:18 -0700178 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimAuthFailureTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 "AUTH FAILURE TIMEOUT",
180 lim_timer_handler,
181 SIR_LIM_AUTH_FAIL_TIMEOUT,
182 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530183 pe_err("could not create Auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 return false;
185 }
186
187 if (wlan_cfg_get_int(pMac, WNI_CFG_PROBE_AFTER_HB_FAIL_TIMEOUT,
188 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530189 pe_err("could not retrieve PROBE_AFTER_HB_FAIL_TIMEOUT value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190
191 /* Change timer to reactivate it in future */
192 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700193 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimProbeAfterHBTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194 "Probe after Heartbeat TIMEOUT",
195 lim_timer_handler,
196 SIR_LIM_PROBE_HB_FAILURE_TIMEOUT,
197 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530198 pe_err("unable to create ProbeAfterHBTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 return false;
200 }
201
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530202 /*
203 * SAE auth timer of 5secs. This is required for duration of entire SAE
204 * authentication.
205 */
206 if ((tx_timer_create(pMac,
207 &pMac->lim.limTimers.sae_auth_timer,
208 "SAE AUTH Timer",
209 lim_timer_handler, SIR_LIM_AUTH_SAE_TIMEOUT,
210 SYS_MS_TO_TICKS(LIM_AUTH_SAE_TIMER_MS), 0,
211 TX_NO_ACTIVATE)) != TX_SUCCESS) {
212 pe_err("could not create SAE AUTH Timer");
213 return false;
214 }
215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 return true;
217}
218/**
219 * lim_create_timers()
220 *
221 * @pMac : Pointer to Global MAC structure
222 *
223 * This function is called upon receiving
224 * 1. SME_START_REQ for STA in ESS role
225 * 2. SME_START_BSS_REQ for AP role & STA in IBSS role
226 *
227 * @return : status of operation
228 */
229
230uint32_t lim_create_timers(tpAniSirGlobal pMac)
231{
232 uint32_t cfgValue, i = 0;
233 uint32_t cfgValue1;
234
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530235 pe_debug("Creating Timers used by LIM module in Role: %d",
Varun Reddy Yeturu32de0e42016-04-15 14:25:59 +0530236 pMac->lim.gLimSystemRole);
237 /* Create timers required for host roaming feature */
238 if (TX_SUCCESS != lim_create_timers_host_roam(pMac))
239 return TX_TIMER_ERROR;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240
241 if (wlan_cfg_get_int(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
242 &cfgValue) != eSIR_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530243 pe_err("could not retrieve MinChannelTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 }
245 cfgValue = SYS_MS_TO_TICKS(cfgValue);
246 /* Periodic probe request timer value is half of the Min channel
247 * timer. Probe request sends periodically till min/max channel
248 * timer expires
249 */
250 cfgValue1 = cfgValue / 2;
251 /* Create periodic probe request timer and activate them later */
252 if (cfgValue1 >= 1
Naveen Rawat22b1a932015-08-26 12:13:18 -0700253 && (tx_timer_create(pMac,
254 &pMac->lim.limTimers.gLimPeriodicProbeReqTimer,
255 "Periodic Probe Request Timer", lim_timer_handler,
256 SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT, cfgValue1, 0,
257 TX_NO_ACTIVATE) != TX_SUCCESS)) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530258 pe_err("could not create periodic probe timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 goto err_timer;
260 }
261
262 if (wlan_cfg_get_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
263 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530264 pe_err("could not retrieve MAXChannelTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265
266 cfgValue = SYS_MS_TO_TICKS(cfgValue);
267 /* Limiting max numm of probe req for each channel scan */
268 pMac->lim.maxProbe = (cfgValue / cfgValue1);
269
270 if (pMac->lim.gLimSystemRole != eLIM_AP_ROLE)
271 if (false == lim_create_non_ap_timers(pMac))
272 goto err_timer;
273
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 /* Create all CNF_WAIT Timers upfront */
275 if (wlan_cfg_get_int(pMac, WNI_CFG_WT_CNF_TIMEOUT, &cfgValue)
276 != eSIR_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530277 pe_err("could not retrieve CNF timeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 }
279
280 cfgValue = SYS_MS_TO_TICKS(cfgValue);
281 for (i = 0; i < (pMac->lim.maxStation + 1); i++) {
Naveen Rawat22b1a932015-08-26 12:13:18 -0700282 if (tx_timer_create(pMac,
283 &pMac->lim.limTimers.gpLimCnfWaitTimer[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 "CNF_MISS_TIMEOUT",
285 lim_cnf_wait_tmer_handler,
286 (uint32_t) i, cfgValue,
287 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530288 pe_err("Cannot create CNF wait timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 goto err_timer;
290 }
291 }
292
293 /* Alloc and init table for the preAuth timer list */
294 if (wlan_cfg_get_int(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
295 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530296 pe_err("could not retrieve mac preauth value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 pMac->lim.gLimPreAuthTimerTable.numEntry = cfgValue;
298 pMac->lim.gLimPreAuthTimerTable.pTable =
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800299 qdf_mem_malloc(cfgValue * sizeof(tLimPreAuthNode *));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
301 if (pMac->lim.gLimPreAuthTimerTable.pTable == NULL) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530302 pe_err("AllocateMemory failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 goto err_timer;
304 }
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800305
306 for (i = 0; i < cfgValue; i++) {
307 pMac->lim.gLimPreAuthTimerTable.pTable[i] =
308 qdf_mem_malloc(sizeof(tLimPreAuthNode));
309 if (pMac->lim.gLimPreAuthTimerTable.pTable[i] == NULL) {
310 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530311 pe_err("AllocateMemory failed!");
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800312 goto err_timer;
313 }
314 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315
316 lim_init_pre_auth_timer_table(pMac, &pMac->lim.gLimPreAuthTimerTable);
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530317 pe_debug("alloc and init table for preAuth timers");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318
319 if (wlan_cfg_get_int(pMac, WNI_CFG_OLBC_DETECT_TIMEOUT,
320 &cfgValue) != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530321 pe_err("could not retrieve OLBD detect timeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322
323 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700324 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimUpdateOlbcCacheTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 "OLBC UPDATE CACHE TIMEOUT",
326 lim_update_olbc_cache_timer_handler,
327 SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT, cfgValue,
328 cfgValue, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530329 pe_err("Cannot create update OLBC cache tmr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 goto err_timer;
331 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332
333 cfgValue = 1000;
334 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700335 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimDisassocAckTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 "DISASSOC ACK TIMEOUT",
337 lim_timer_handler, SIR_LIM_DISASSOC_ACK_TIMEOUT,
338 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530339 pe_err("could not DISASSOC ACK TIMEOUT timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 goto err_timer;
341 }
342
343 cfgValue = 1000;
344 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700345 if (tx_timer_create(pMac, &pMac->lim.limTimers.gLimDeauthAckTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 "DISASSOC ACK TIMEOUT",
347 lim_timer_handler, SIR_LIM_DEAUTH_ACK_TIMEOUT,
348 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530349 pe_err("could not create DEAUTH ACK TIMEOUT timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 goto err_timer;
351 }
352
353 /* (> no of BI* no of TUs per BI * 1TU in msec +
354 * p2p start time offset*1 TU in msec = 2*100*1.024 + 5*1.024
355 * = 204.8 + 5.12 = 209.20)
356 */
357 cfgValue = LIM_INSERT_SINGLESHOTNOA_TIMEOUT_VALUE;
358 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700359 if (tx_timer_create(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 &pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer,
361 "Single Shot NOA Insert timeout", lim_timer_handler,
362 SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT, cfgValue, 0,
363 TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530364 pe_err("Can't create Single Shot NOA Insert Timeout tmr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 goto err_timer;
366 }
367
368 cfgValue = ACTIVE_TO_PASSIVE_CONVERISON_TIMEOUT;
369 cfgValue = SYS_MS_TO_TICKS(cfgValue);
Naveen Rawat22b1a932015-08-26 12:13:18 -0700370 if (tx_timer_create(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 &pMac->lim.limTimers.gLimActiveToPassiveChannelTimer,
372 "ACTIVE TO PASSIVE CHANNEL", lim_timer_handler,
373 SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE, cfgValue, 0,
374 TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530375 pe_warn("could not create timer for passive channel to active channel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 goto err_timer;
377 }
378
379 return TX_SUCCESS;
380
381err_timer:
Abhishek Singh748d8a22017-08-21 15:19:37 +0530382 lim_delete_timers_host_roam(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 tx_timer_delete(&pMac->lim.limTimers.gLimDeauthAckTimer);
384 tx_timer_delete(&pMac->lim.limTimers.gLimDisassocAckTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 tx_timer_delete(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
386 while (((int32_t)-- i) >= 0) {
387 tx_timer_delete(&pMac->lim.limTimers.gpLimCnfWaitTimer[i]);
388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 tx_timer_delete(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
390 tx_timer_delete(&pMac->lim.limTimers.gLimAuthFailureTimer);
391 tx_timer_delete(&pMac->lim.limTimers.gLimAddtsRspTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 tx_timer_delete(&pMac->lim.limTimers.gLimAssocFailureTimer);
393 tx_timer_delete(&pMac->lim.limTimers.gLimJoinFailureTimer);
394 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530395 tx_timer_delete(&pMac->lim.limTimers.g_lim_periodic_auth_retry_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 tx_timer_delete(&pMac->lim.limTimers.gLimQuietBssTimer);
397 tx_timer_delete(&pMac->lim.limTimers.gLimQuietTimer);
398 tx_timer_delete(&pMac->lim.limTimers.gLimChannelSwitchTimer);
399 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicProbeReqTimer);
400 tx_timer_delete(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer);
401 tx_timer_delete(&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer);
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530402 tx_timer_delete(&pMac->lim.limTimers.sae_auth_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403
404 if (NULL != pMac->lim.gLimPreAuthTimerTable.pTable) {
Naveen Rawat25460932016-02-05 16:56:08 -0800405 for (i = 0; i < pMac->lim.gLimPreAuthTimerTable.numEntry; i++)
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800406 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable[i]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530407 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
409 }
410 return TX_TIMER_ERROR;
411} /****** end lim_create_timers() ******/
412
413/**
414 * lim_timer_handler()
415 *
416 ***FUNCTION:
417 * This function is called upon
418 * 1. MIN_CHANNEL, MAX_CHANNEL timer expiration during scanning
419 * 2. JOIN_FAILURE timer expiration while joining a BSS
420 * 3. AUTH_FAILURE timer expiration while authenticating with a peer
421 * 4. Heartbeat timer expiration on STA
422 * 5. Background scan timer expiration on STA
423 * 6. AID release, Pre-auth cleanup and Link monitoring timer
424 * expiration on AP
425 *
426 ***LOGIC:
427 *
428 ***ASSUMPTIONS:
429 * NA
430 *
431 ***NOTE:
432 * NA
433 *
434 * @param param - Message corresponding to the timer that expired
435 *
436 * @return None
437 */
438
439void lim_timer_handler(void *pMacGlobal, uint32_t param)
440{
441 uint32_t statusCode;
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700442 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
444
445 /* Prepare and post message to LIM Message Queue */
446
447 msg.type = (uint16_t) param;
448 msg.bodyptr = NULL;
449 msg.bodyval = 0;
450
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +0530451 statusCode = lim_post_msg_high_priority(pMac, &msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 if (statusCode != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530453 pe_err("posting message: %X to LIM failed, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 msg.type, statusCode);
455} /****** end lim_timer_handler() ******/
456
457/**
458 * lim_addts_response_timer_handler()
459 *
460 ***FUNCTION:
461 * This function is called upon Addts response timer expiration on sta
462 *
463 ***LOGIC:
464 * Message SIR_LIM_ADDTS_RSP_TIMEOUT is posted to gSirLimMsgQ
465 * when this function is executed.
466 *
467 ***ASSUMPTIONS:
468 * NA
469 *
470 ***NOTE:
471 * NA
472 *
473 * @param param - pointer to pre-auth node
474 *
475 * @return None
476 */
477
478void lim_addts_response_timer_handler(void *pMacGlobal, uint32_t param)
479{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700480 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
482
483 /* Prepare and post message to LIM Message Queue */
484
485 msg.type = SIR_LIM_ADDTS_RSP_TIMEOUT;
486 msg.bodyval = param;
487 msg.bodyptr = NULL;
488
489 lim_post_msg_api(pMac, &msg);
490} /****** end lim_auth_response_timer_handler() ******/
491
492/**
493 * lim_auth_response_timer_handler()
494 *
495 ***FUNCTION:
496 * This function is called upon Auth response timer expiration on AP
497 *
498 ***LOGIC:
499 * Message SIR_LIM_AUTH_RSP_TIMEOUT is posted to gSirLimMsgQ
500 * when this function is executed.
501 *
502 ***ASSUMPTIONS:
503 * NA
504 *
505 ***NOTE:
506 * NA
507 *
508 * @param param - pointer to pre-auth node
509 *
510 * @return None
511 */
512
513void lim_auth_response_timer_handler(void *pMacGlobal, uint32_t param)
514{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700515 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
517
518 /* Prepare and post message to LIM Message Queue */
519
520 msg.type = SIR_LIM_AUTH_RSP_TIMEOUT;
521 msg.bodyptr = NULL;
522 msg.bodyval = (uint32_t) param;
523
524 lim_post_msg_api(pMac, &msg);
525} /****** end lim_auth_response_timer_handler() ******/
526
527/**
528 * lim_assoc_failure_timer_handler()
529 *
530 * @mac_global : Pointer to Global MAC structure
531 * @param : Indicates whether this is assoc or reassoc failure timeout
532 *
533 * This function is called upon Re/Assoc failure timer expiration on STA.
534 * Message SIR_LIM_ASSOC_FAIL_TIMEOUT is posted to gSirLimMsgQ when this
535 * function is executed.
536 *
537 * Return void
538 */
539void lim_assoc_failure_timer_handler(void *mac_global, uint32_t param)
540{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700541 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542 tpAniSirGlobal mac_ctx = (tpAniSirGlobal) mac_global;
543 tpPESession session = NULL;
544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 session = mac_ctx->lim.pSessionEntry;
546 if (LIM_REASSOC == param && NULL != session
547 && session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530548 pe_err("Reassoc timeout happened");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 if (mac_ctx->lim.reAssocRetryAttempt <
550 LIM_MAX_REASSOC_RETRY_LIMIT) {
551 lim_send_retry_reassoc_req_frame(mac_ctx,
552 session->pLimMlmReassocRetryReq, session);
553 mac_ctx->lim.reAssocRetryAttempt++;
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530554 pe_warn("Reassoc request retry is sent %d times",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 mac_ctx->lim.reAssocRetryAttempt);
556 return;
557 } else {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530558 pe_warn("Reassoc request retry MAX: %d reached",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 LIM_MAX_REASSOC_RETRY_LIMIT);
560 if (NULL != session->pLimMlmReassocRetryReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530561 qdf_mem_free(session->pLimMlmReassocRetryReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 session->pLimMlmReassocRetryReq = NULL;
563 }
564 }
565 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 /* Prepare and post message to LIM Message Queue */
567 msg.type = SIR_LIM_ASSOC_FAIL_TIMEOUT;
568 msg.bodyval = (uint32_t) param;
569 msg.bodyptr = NULL;
570 lim_post_msg_api(mac_ctx, &msg);
571} /****** end lim_assoc_failure_timer_handler() ******/
572
573/**
574 * lim_update_olbc_cache_timer_handler()
575 *
576 ***FUNCTION:
577 * This function is called upon update olbc cache timer expiration
578 * on STA
579 *
580 ***LOGIC:
581 * Message SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT is posted to gSirLimMsgQ
582 * when this function is executed.
583 *
584 ***ASSUMPTIONS:
585 * NA
586 *
587 ***NOTE:
588 * NA
589 *
590 * @param
591 *
592 * @return None
593 */
594void lim_update_olbc_cache_timer_handler(void *pMacGlobal, uint32_t param)
595{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700596 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
598
599 /* Prepare and post message to LIM Message Queue */
600
601 msg.type = SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT;
602 msg.bodyval = 0;
603 msg.bodyptr = NULL;
604
605 lim_post_msg_api(pMac, &msg);
606} /****** end lim_update_olbc_cache_timer_handler() ******/
607
608/**
609 * lim_deactivate_and_change_timer()
610 *
611 ***FUNCTION:
612 * This function is called to deactivate and change a timer
613 * for future re-activation
614 *
615 ***LOGIC:
616 *
617 ***ASSUMPTIONS:
618 * NA
619 *
620 ***NOTE:
621 * NA
622 *
623 * @param pMac - Pointer to Global MAC structure
624 * @param timerId - enum of timer to be deactivated and changed
625 * This enum is defined in lim_utils.h file
626 *
627 * @return None
628 */
629
630void lim_deactivate_and_change_timer(tpAniSirGlobal pMac, uint32_t timerId)
631{
632 uint32_t val = 0;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530633 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 switch (timerId) {
Varun Reddy Yeturu32de0e42016-04-15 14:25:59 +0530636 case eLIM_REASSOC_FAIL_TIMER:
637 case eLIM_FT_PREAUTH_RSP_TIMER:
638 lim_deactivate_and_change_timer_host_roam(pMac, timerId);
639 break;
640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 case eLIM_ADDTS_RSP_TIMER:
642 pMac->lim.gLimAddtsRspTimerCount++;
643 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer)
644 != TX_SUCCESS) {
645 /* Could not deactivate AddtsRsp Timer */
646 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530647 pe_err("Unable to deactivate AddtsRsp timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 }
649 break;
650
651 case eLIM_PERIODIC_PROBE_REQ_TIMER:
652 if (tx_timer_deactivate
653 (&pMac->lim.limTimers.gLimPeriodicProbeReqTimer)
654 != TX_SUCCESS) {
655 /* Could not deactivate min channel timer. */
656 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530657 pe_err("Unable to deactivate periodic timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 }
659
660 val =
661 SYS_MS_TO_TICKS(pMac->lim.gpLimMlmScanReq->minChannelTime) /
662 2;
Anurag Chouhan1a734282016-09-03 16:23:00 +0530663 if (val) {
664 if (tx_timer_change(
665 &pMac->lim.limTimers.gLimPeriodicProbeReqTimer,
666 val, 0) != TX_SUCCESS) {
667 /* Could not change min channel timer. */
668 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530669 pe_err("Unable to change periodic timer");
Anurag Chouhan1a734282016-09-03 16:23:00 +0530670 }
671 } else
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530672 pe_err("Do not change gLimPeriodicProbeReqTimer values,"
673 "value: %d minchannel time: %d"
674 "maxchannel time: %d", val,
Anurag Chouhan1a734282016-09-03 16:23:00 +0530675 pMac->lim.gpLimMlmScanReq->minChannelTime,
676 pMac->lim.gpLimMlmScanReq->maxChannelTime);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677
678 break;
679
680 case eLIM_JOIN_FAIL_TIMER:
681 if (tx_timer_deactivate
682 (&pMac->lim.limTimers.gLimJoinFailureTimer)
683 != TX_SUCCESS) {
684 /**
685 * Could not deactivate Join Failure
686 * timer. Log error.
687 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530688 pe_err("Unable to deactivate Join Failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 }
690
691 if (wlan_cfg_get_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
692 &val) != eSIR_SUCCESS) {
693 /**
694 * Could not get JoinFailureTimeout value
695 * from CFG. Log error.
696 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530697 pe_err("could not retrieve JoinFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 }
699 val = SYS_MS_TO_TICKS(val);
700
701 if (tx_timer_change(&pMac->lim.limTimers.gLimJoinFailureTimer,
702 val, 0) != TX_SUCCESS) {
703 /**
704 * Could not change Join Failure
705 * timer. Log error.
706 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530707 pe_err("Unable to change Join Failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708 }
709
710 break;
711
712 case eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER:
713 if (tx_timer_deactivate
714 (&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer)
715 != TX_SUCCESS) {
716 /* Could not deactivate periodic join req Times. */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530717 pe_err("Unable to deactivate periodic join request timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 }
719
720 val = SYS_MS_TO_TICKS(LIM_JOIN_PROBE_REQ_TIMER_MS);
721 if (tx_timer_change
722 (&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer, val,
723 0) != TX_SUCCESS) {
724 /* Could not change periodic join req times. */
725 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530726 pe_err("Unable to change periodic join request timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 }
728
729 break;
730
731 case eLIM_AUTH_FAIL_TIMER:
732 if (tx_timer_deactivate
733 (&pMac->lim.limTimers.gLimAuthFailureTimer)
734 != TX_SUCCESS) {
735 /* Could not deactivate Auth failure timer. */
736 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530737 pe_err("Unable to deactivate auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 }
739 /* Change timer to reactivate it in future */
740 if (wlan_cfg_get_int(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
741 &val) != eSIR_SUCCESS) {
742 /**
743 * Could not get AuthFailureTimeout value
744 * from CFG. Log error.
745 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530746 pe_err("could not retrieve AuthFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 }
748 val = SYS_MS_TO_TICKS(val);
749
750 if (tx_timer_change(&pMac->lim.limTimers.gLimAuthFailureTimer,
751 val, 0) != TX_SUCCESS) {
752 /* Could not change Authentication failure timer. */
753 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530754 pe_err("unable to change Auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 }
756
757 break;
758
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530759 case eLIM_AUTH_RETRY_TIMER:
760
761 if (tx_timer_deactivate
762 (&pMac->lim.limTimers.g_lim_periodic_auth_retry_timer)
763 != TX_SUCCESS) {
764 /* Could not deactivate Auth Retry Timer. */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530765 pe_err("Unable to deactivate Auth Retry timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530766 }
767 session_entry = pe_find_session_by_session_id(pMac,
768 pMac->lim.limTimers.
769 g_lim_periodic_auth_retry_timer.sessionId);
770 if (NULL == session_entry) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530771 pe_err("session does not exist for given SessionId : %d",
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530772 pMac->lim.limTimers.
773 g_lim_periodic_auth_retry_timer.sessionId);
774 break;
775 }
776 /* 3/5 of the beacon interval */
777 val = (session_entry->beaconParams.beaconInterval * 3) / 5;
778 val = SYS_MS_TO_TICKS(val);
779 if (tx_timer_change
780 (&pMac->lim.limTimers.g_lim_periodic_auth_retry_timer,
781 val, 0) != TX_SUCCESS) {
782 /* Could not change Auth Retry timer. */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530783 pe_err("Unable to change Auth Retry timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530784 }
785 break;
786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 case eLIM_ASSOC_FAIL_TIMER:
788 if (tx_timer_deactivate
789 (&pMac->lim.limTimers.gLimAssocFailureTimer) !=
790 TX_SUCCESS) {
791 /* Could not deactivate Association failure timer. */
792 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530793 pe_err("unable to deactivate Association failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 }
795 /* Change timer to reactivate it in future */
796 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT,
797 &val) != eSIR_SUCCESS) {
798 /**
799 * Could not get AssocFailureTimeout value
800 * from CFG. Log error.
801 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530802 pe_err("could not retrieve AssocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 }
804 val = SYS_MS_TO_TICKS(val);
805
806 if (tx_timer_change(&pMac->lim.limTimers.gLimAssocFailureTimer,
807 val, 0) != TX_SUCCESS) {
808 /* Could not change Association failure timer. */
809 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530810 pe_err("unable to change Assoc failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 }
812
813 break;
814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 case eLIM_PROBE_AFTER_HB_TIMER:
816 if (tx_timer_deactivate
817 (&pMac->lim.limTimers.gLimProbeAfterHBTimer) !=
818 TX_SUCCESS) {
819 /* Could not deactivate Heartbeat timer. */
820 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530821 pe_err("unable to deactivate probeAfterHBTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 } else {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530823 pe_debug("Deactivated probe after hb timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 }
825
826 if (wlan_cfg_get_int(pMac, WNI_CFG_PROBE_AFTER_HB_FAIL_TIMEOUT,
827 &val) != eSIR_SUCCESS) {
828 /**
829 * Could not get PROBE_AFTER_HB_FAILURE
830 * value from CFG. Log error.
831 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530832 pe_err("could not retrieve PROBE_AFTER_HB_FAIL_TIMEOUT value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833 }
834 /* Change timer to reactivate it in future */
835 val = SYS_MS_TO_TICKS(val);
836
837 if (tx_timer_change(&pMac->lim.limTimers.gLimProbeAfterHBTimer,
838 val, 0) != TX_SUCCESS) {
839 /* Could not change HeartBeat timer. */
840 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530841 pe_err("unable to change ProbeAfterHBTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 } else {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530843 pe_debug("Probe after HB timer value is changed: %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 val);
845 }
846
847 break;
848
849 case eLIM_LEARN_DURATION_TIMER:
850 break;
851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 case eLIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
853 if (tx_timer_deactivate
854 (&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer) !=
855 TX_SUCCESS) {
856 /**
857 ** Could not deactivate Active to passive channel timer.
858 ** Log error.
859 **/
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530860 pe_err("Unable to Deactivate Active to passive channel timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 return;
862 }
863 val = ACTIVE_TO_PASSIVE_CONVERISON_TIMEOUT;
864 val = SYS_MS_TO_TICKS(val);
865 if (tx_timer_change
866 (&pMac->lim.limTimers.gLimActiveToPassiveChannelTimer, val,
867 0) != TX_SUCCESS) {
868 /**
869 * Could not change timer to check scan type for passive channel.
870 * timer. Log error.
871 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530872 pe_err("Unable to change timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 return;
874 }
875 break;
876
877 case eLIM_DISASSOC_ACK_TIMER:
878 if (tx_timer_deactivate
879 (&pMac->lim.limTimers.gLimDisassocAckTimer) != TX_SUCCESS) {
880 /**
881 ** Could not deactivate Join Failure
882 ** timer. Log error.
883 **/
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530884 pe_err("Unable to deactivate Disassoc ack timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 return;
886 }
887 val = 1000;
888 val = SYS_MS_TO_TICKS(val);
889 if (tx_timer_change(&pMac->lim.limTimers.gLimDisassocAckTimer,
890 val, 0) != TX_SUCCESS) {
891 /**
892 * Could not change Join Failure
893 * timer. Log error.
894 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530895 pe_err("Unable to change timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 return;
897 }
898 break;
899
900 case eLIM_DEAUTH_ACK_TIMER:
901 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimDeauthAckTimer)
902 != TX_SUCCESS) {
903 /**
904 ** Could not deactivate Join Failure
905 ** timer. Log error.
906 **/
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530907 pe_err("Unable to deactivate Deauth ack timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 return;
909 }
910 val = 1000;
911 val = SYS_MS_TO_TICKS(val);
912 if (tx_timer_change(&pMac->lim.limTimers.gLimDeauthAckTimer,
913 val, 0) != TX_SUCCESS) {
914 /**
915 * Could not change Join Failure
916 * timer. Log error.
917 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530918 pe_err("Unable to change timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 return;
920 }
921 break;
922
923 case eLIM_INSERT_SINGLESHOT_NOA_TIMER:
924 if (tx_timer_deactivate
925 (&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer) !=
926 TX_SUCCESS) {
927 /**
928 ** Could not deactivate SingleShot NOA Insert
929 ** timer. Log error.
930 **/
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530931 pe_err("Unable to deactivate SingleShot NOA Insert timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 return;
933 }
934 val = LIM_INSERT_SINGLESHOTNOA_TIMEOUT_VALUE;
935 val = SYS_MS_TO_TICKS(val);
936 if (tx_timer_change
937 (&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer, val,
938 0) != TX_SUCCESS) {
939 /**
940 * Could not change Single Shot NOA Insert
941 * timer. Log error.
942 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +0530943 pe_err("Unable to change timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 return;
945 }
946 break;
947
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530948 case eLIM_AUTH_SAE_TIMER:
949 if (tx_timer_deactivate
950 (&pMac->lim.limTimers.sae_auth_timer)
951 != TX_SUCCESS)
952 pe_err("Unable to deactivate SAE auth timer");
953
954 /* Change timer to reactivate it in future */
955 val = SYS_MS_TO_TICKS(LIM_AUTH_SAE_TIMER_MS);
956
957 if (tx_timer_change(&pMac->lim.limTimers.sae_auth_timer,
958 val, 0) != TX_SUCCESS)
959 pe_err("unable to change SAE auth timer");
960
961 break;
962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 default:
964 /* Invalid timerId. Log error */
965 break;
966 }
967} /****** end lim_deactivate_and_change_timer() ******/
968
969/**
970 * lim_deactivate_and_change_per_sta_id_timer()
971 *
972 *
973 * @brief: This function is called to deactivate and change a per STA timer
974 * for future re-activation
975 *
976 ***LOGIC:
977 *
978 ***ASSUMPTIONS:
979 * NA
980 *
981 * @note staId for eLIM_AUTH_RSP_TIMER is auth Node Index.
982 *
983 * @param pMac - Pointer to Global MAC structure
984 * @param timerId - enum of timer to be deactivated and changed
985 * This enum is defined in lim_utils.h file
986 * @param staId - staId
987 *
988 * @return None
989 */
990
991void
992lim_deactivate_and_change_per_sta_id_timer(tpAniSirGlobal pMac, uint32_t timerId,
993 uint16_t staId)
994{
995 uint32_t val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996
997 switch (timerId) {
998 case eLIM_CNF_WAIT_TIMER:
999
1000 if (tx_timer_deactivate
1001 (&pMac->lim.limTimers.gpLimCnfWaitTimer[staId])
1002 != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301003 pe_err("unable to deactivate CNF wait timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 }
1005 /* Change timer to reactivate it in future */
1006
1007 if (wlan_cfg_get_int(pMac, WNI_CFG_WT_CNF_TIMEOUT,
1008 &val) != eSIR_SUCCESS) {
1009 /**
1010 * Could not get cnf timeout value
1011 * from CFG. Log error.
1012 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301013 pe_err("could not retrieve cnf timeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 }
1015 val = SYS_MS_TO_TICKS(val);
1016
1017 if (tx_timer_change
1018 (&pMac->lim.limTimers.gpLimCnfWaitTimer[staId], val,
1019 val) != TX_SUCCESS) {
1020 /* Could not change cnf timer. */
1021 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301022 pe_err("unable to change cnf wait timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 }
1024
1025 break;
1026
1027 case eLIM_AUTH_RSP_TIMER:
1028 {
1029 tLimPreAuthNode *pAuthNode;
1030
1031 pAuthNode =
1032 lim_get_pre_auth_node_from_index(pMac,
1033 &pMac->lim.
1034 gLimPreAuthTimerTable,
1035 staId);
1036
1037 if (pAuthNode == NULL) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301038 pe_err("Invalid Pre Auth Index passed :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 staId);
1040 break;
1041 }
1042
1043 if (tx_timer_deactivate(&pAuthNode->timer) !=
1044 TX_SUCCESS) {
1045 /* Could not deactivate auth response timer. */
1046 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301047 pe_err("unable to deactivate auth response timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 }
1049 /* Change timer to reactivate it in future */
1050
1051 if (wlan_cfg_get_int
1052 (pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
1053 &val) != eSIR_SUCCESS) {
1054 /**
1055 * Could not get auth rsp timeout value
1056 * from CFG. Log error.
1057 */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301058 pe_err("could not retrieve auth response timeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 }
1060
1061 val = SYS_MS_TO_TICKS(val);
1062
1063 if (tx_timer_change(&pAuthNode->timer, val, 0) !=
1064 TX_SUCCESS) {
1065 /* Could not change auth rsp timer. */
1066 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301067 pe_err("unable to change auth rsp timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 }
1069 }
1070 break;
1071
1072 default:
1073 /* Invalid timerId. Log error */
1074 break;
1075
1076 }
1077}
1078
1079/**
1080 * lim_activate_cnf_timer()
1081 *
1082 ***FUNCTION:
1083 * This function is called to activate a per STA timer
1084 *
1085 ***LOGIC:
1086 *
1087 ***ASSUMPTIONS:
1088 * NA
1089 *
1090 ***NOTE:
1091 * NA
1092 *
1093 * @param pMac - Pointer to Global MAC structure
1094 * @param StaId - staId
1095 *
1096 * @return None
1097 */
1098
1099void lim_activate_cnf_timer(tpAniSirGlobal pMac, uint16_t staId,
1100 tpPESession psessionEntry)
1101{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId =
1103 psessionEntry->peSessionId;
1104 if (tx_timer_activate(&pMac->lim.limTimers.gpLimCnfWaitTimer[staId])
1105 != TX_SUCCESS) {
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301106 pe_err("could not activate cnf wait timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 }
1108}
1109
1110/**
1111 * lim_activate_auth_rsp_timer()
1112 *
1113 ***FUNCTION:
1114 * This function is called to activate a per STA timer
1115 *
1116 ***LOGIC:
1117 *
1118 ***ASSUMPTIONS:
1119 * NA
1120 *
1121 ***NOTE:
1122 * NA
1123 *
1124 * @param pMac - Pointer to Global MAC structure
1125 * @param id - id
1126 *
1127 * @return None
1128 */
1129
1130void lim_activate_auth_rsp_timer(tpAniSirGlobal pMac, tLimPreAuthNode *pAuthNode)
1131{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 if (tx_timer_activate(&pAuthNode->timer) != TX_SUCCESS) {
1133 /* / Could not activate auth rsp timer. */
1134 /* Log error */
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301135 pe_err("could not activate auth rsp timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 }
1137}
1138
1139/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 * limAssocCnfWaitTmerHandler()
1141 *
1142 ***FUNCTION:
1143 * This function post a message to send a disassociate frame out.
1144 *
1145 ***LOGIC:
1146 *
1147 ***ASSUMPTIONS:
1148 *
1149 ***NOTE:
1150 * NA
1151 *
1152 * @param
1153 *
1154 * @return None
1155 */
1156
1157void lim_cnf_wait_tmer_handler(void *pMacGlobal, uint32_t param)
1158{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07001159 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 uint32_t statusCode;
1161 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
1162
1163 msg.type = SIR_LIM_CNF_WAIT_TIMEOUT;
1164 msg.bodyval = (uint32_t) param;
1165 msg.bodyptr = NULL;
1166
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301167 statusCode = lim_post_msg_api(pMac, &msg);
1168 if (statusCode != eSIR_SUCCESS)
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301169 pe_err("posting to LIM failed, reason: %d", statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170
1171}
1172
1173void lim_channel_switch_timer_handler(void *pMacGlobal, uint32_t param)
1174{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07001175 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
1177
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301178 pe_debug("ChannelSwitch Timer expired. Posting msg to LIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179
1180 msg.type = SIR_LIM_CHANNEL_SWITCH_TIMEOUT;
1181 msg.bodyval = (uint32_t) param;
1182 msg.bodyptr = NULL;
1183
1184 lim_post_msg_api(pMac, &msg);
1185}
1186
1187void lim_quiet_timer_handler(void *pMacGlobal, uint32_t param)
1188{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07001189 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
1191
1192 msg.type = SIR_LIM_QUIET_TIMEOUT;
1193 msg.bodyval = (uint32_t) param;
1194 msg.bodyptr = NULL;
1195
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301196 pe_debug("Post SIR_LIM_QUIET_TIMEOUT msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 lim_post_msg_api(pMac, &msg);
1198}
1199
1200void lim_quiet_bss_timer_handler(void *pMacGlobal, uint32_t param)
1201{
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07001202 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 tpAniSirGlobal pMac = (tpAniSirGlobal) pMacGlobal;
1204
1205 msg.type = SIR_LIM_QUIET_BSS_TIMEOUT;
1206 msg.bodyval = (uint32_t) param;
1207 msg.bodyptr = NULL;
Nishank Aggarwalf0e344b2017-03-23 16:39:13 +05301208 pe_debug("Post SIR_LIM_QUIET_BSS_TIMEOUT msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 lim_post_msg_api(pMac, &msg);
1210}
1211