xref: /wlan-driver/qcacld-3.0/core/mac/src/pe/lim/lim_timer_utils.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * This file lim_timer_utils.cc contains the utility functions
22  * LIM uses for handling various timers.
23  * Author:        Chandra Modumudi
24  * Date:          02/13/02
25  * History:-
26  * Date           Modified by    Modification Information
27  * --------------------------------------------------------------------
28  */
29 
30 #include "lim_types.h"
31 #include "lim_utils.h"
32 #include "lim_assoc_utils.h"
33 #include "lim_security_utils.h"
34 #include "wlan_mlme_public_struct.h"
35 #include <lim_api.h>
36 
37 /* Lim Quite timer in ticks */
38 #define LIM_QUIET_TIMER_TICKS                    100
39 /* Lim Quite BSS timer interval in ticks */
40 #define LIM_QUIET_BSS_TIMER_TICK                 100
41 /* Lim KeepAlive timer default (3000)ms */
42 #define LIM_KEEPALIVE_TIMER_MS                   3000
43 /* Lim Periodic Auth Retry timer default 60 ms */
44 #define LIM_AUTH_RETRY_TIMER_MS   60
45 
46 /*
47  * SAE auth timer of 5secs. This is required for duration of entire SAE
48  * authentication.
49  */
50 #define LIM_AUTH_SAE_TIMER_MS 5000
51 
52 /*
53  * STA stats resp timer of 10secs. This is required for duration of RRM
54  * STA STATS report response from report request.
55  */
56 #define LIM_RRM_STA_STATS_RSP_TIMER_MS 10000
57 
lim_create_non_ap_timers(struct mac_context * mac)58 static bool lim_create_non_ap_timers(struct mac_context *mac)
59 {
60 	uint32_t cfgValue;
61 
62 	cfgValue = SYS_MS_TO_TICKS(
63 			mac->mlme_cfg->timeouts.join_failure_timeout);
64 	/* Create Join failure timer and activate it later */
65 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimJoinFailureTimer,
66 			    "JOIN FAILURE TIMEOUT",
67 			    lim_timer_handler, SIR_LIM_JOIN_FAIL_TIMEOUT,
68 			    cfgValue, 0,
69 			    TX_NO_ACTIVATE) != TX_SUCCESS) {
70 		/* / Could not create Join failure timer. */
71 		/* Log error */
72 		pe_err("could not create Join failure timer");
73 		return false;
74 	}
75 	cfgValue = SYS_MS_TO_TICKS(
76 			mac->mlme_cfg->timeouts.probe_req_retry_timeout);
77 	/* Send unicast probe req frame every 200 ms */
78 	if (tx_timer_create(mac,
79 			    &mac->lim.lim_timers.gLimPeriodicJoinProbeReqTimer,
80 			    "Periodic Join Probe Request Timer",
81 			    lim_timer_handler,
82 			    SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT,
83 			    cfgValue, 0,
84 			    TX_NO_ACTIVATE) != TX_SUCCESS) {
85 		pe_err("could not create Periodic Join Probe Request tmr");
86 		return false;
87 	}
88 
89 	/* Send Auth frame every 60 ms */
90 	if ((tx_timer_create(mac,
91 		&mac->lim.lim_timers.g_lim_periodic_auth_retry_timer,
92 		"Periodic AUTH Timer",
93 		lim_timer_handler, SIR_LIM_AUTH_RETRY_TIMEOUT,
94 		SYS_MS_TO_TICKS(LIM_AUTH_RETRY_TIMER_MS), 0,
95 		TX_NO_ACTIVATE)) != TX_SUCCESS) {
96 		pe_err("could not create Periodic AUTH Timer");
97 		return false;
98 	}
99 
100 	cfgValue = SYS_MS_TO_TICKS(
101 			mac->mlme_cfg->timeouts.assoc_failure_timeout);
102 	/* Create Association failure timer and activate it later */
103 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimAssocFailureTimer,
104 			    "ASSOC FAILURE TIMEOUT",
105 			    lim_assoc_failure_timer_handler, LIM_ASSOC,
106 			    cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
107 		pe_err("could not create Association failure timer");
108 		return false;
109 	}
110 
111 	cfgValue = SYS_MS_TO_TICKS(mac->mlme_cfg->timeouts.addts_rsp_timeout);
112 
113 	/* Create Addts response timer and activate it later */
114 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimAddtsRspTimer,
115 			    "ADDTS RSP TIMEOUT",
116 			    lim_addts_response_timer_handler,
117 			    SIR_LIM_ADDTS_RSP_TIMEOUT,
118 			    cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
119 		pe_err("could not create Addts response timer");
120 		return false;
121 	}
122 
123 	cfgValue = SYS_MS_TO_TICKS(
124 			mac->mlme_cfg->timeouts.auth_failure_timeout);
125 	/* Create Auth failure timer and activate it later */
126 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimAuthFailureTimer,
127 			    "AUTH FAILURE TIMEOUT",
128 			    lim_timer_handler,
129 			    SIR_LIM_AUTH_FAIL_TIMEOUT,
130 			    cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
131 		pe_err("could not create Auth failure timer");
132 		return false;
133 	}
134 
135 	/*
136 	 * SAE auth timer of 5secs. This is required for duration of entire SAE
137 	 * authentication.
138 	 */
139 	if ((tx_timer_create(mac,
140 		&mac->lim.lim_timers.sae_auth_timer,
141 		"SAE AUTH Timer",
142 		lim_timer_handler, SIR_LIM_AUTH_SAE_TIMEOUT,
143 		SYS_MS_TO_TICKS(LIM_AUTH_SAE_TIMER_MS), 0,
144 		TX_NO_ACTIVATE)) != TX_SUCCESS) {
145 		pe_err("could not create SAE AUTH Timer");
146 		return false;
147 	}
148 
149 	return true;
150 }
151 /**
152  * lim_create_timers()
153  *
154  * @mac : Pointer to Global MAC structure
155  *
156  * This function is called upon receiving
157  * 1. SME_START_REQ for STA in ESS role
158  * 2. SME_START_BSS_REQ for AP role & STA in IBSS role
159  *
160  * @return : status of operation
161  */
162 
lim_create_timers(struct mac_context * mac)163 uint32_t lim_create_timers(struct mac_context *mac)
164 {
165 	uint32_t cfgValue, i = 0;
166 
167 	pe_debug("Creating Timers used by LIM module in Role: %d",
168 	       mac->lim.gLimSystemRole);
169 	/* Create timers required for host roaming feature */
170 	if (TX_SUCCESS != lim_create_timers_host_roam(mac))
171 		return TX_TIMER_ERROR;
172 
173 	if (mac->lim.gLimSystemRole != eLIM_AP_ROLE)
174 		if (false == lim_create_non_ap_timers(mac))
175 			goto err_timer;
176 
177 	cfgValue = mac->mlme_cfg->sta.wait_cnf_timeout;
178 	cfgValue = SYS_MS_TO_TICKS(cfgValue);
179 	for (i = 0; i < (mac->lim.maxStation + 1); i++) {
180 		if (tx_timer_create(mac,
181 				    &mac->lim.lim_timers.gpLimCnfWaitTimer[i],
182 				    "CNF_MISS_TIMEOUT",
183 				    lim_cnf_wait_tmer_handler,
184 				    (uint32_t) i, cfgValue,
185 				    0, TX_NO_ACTIVATE) != TX_SUCCESS) {
186 			pe_err("Cannot create CNF wait timer");
187 			goto err_timer;
188 		}
189 	}
190 
191 	/* Alloc and init table for the preAuth timer list */
192 	cfgValue = mac->mlme_cfg->lfr.max_num_pre_auth;
193 	mac->lim.gLimPreAuthTimerTable.numEntry = cfgValue;
194 	mac->lim.gLimPreAuthTimerTable.pTable =
195 		qdf_mem_malloc(cfgValue * sizeof(tLimPreAuthNode *));
196 
197 	if (!mac->lim.gLimPreAuthTimerTable.pTable)
198 		goto err_timer;
199 
200 	for (i = 0; i < cfgValue; i++) {
201 		mac->lim.gLimPreAuthTimerTable.pTable[i] =
202 					qdf_mem_malloc(sizeof(tLimPreAuthNode));
203 		if (!mac->lim.gLimPreAuthTimerTable.pTable[i]) {
204 			mac->lim.gLimPreAuthTimerTable.numEntry = 0;
205 			goto err_timer;
206 		}
207 	}
208 
209 	lim_init_pre_auth_timer_table(mac, &mac->lim.gLimPreAuthTimerTable);
210 	pe_debug("alloc and init table for preAuth timers");
211 
212 	cfgValue = SYS_MS_TO_TICKS(
213 			mac->mlme_cfg->timeouts.olbc_detect_timeout);
214 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimUpdateOlbcCacheTimer,
215 			    "OLBC UPDATE CACHE TIMEOUT",
216 			    lim_update_olbc_cache_timer_handler,
217 			    SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT, cfgValue,
218 			    cfgValue, TX_NO_ACTIVATE) != TX_SUCCESS) {
219 		pe_err("Cannot create update OLBC cache tmr");
220 		goto err_timer;
221 	}
222 
223 	cfgValue = 1000;
224 	cfgValue = SYS_MS_TO_TICKS(cfgValue);
225 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimDisassocAckTimer,
226 			    "DISASSOC ACK TIMEOUT",
227 			    lim_timer_handler, SIR_LIM_DISASSOC_ACK_TIMEOUT,
228 			    cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
229 		pe_err("could not DISASSOC ACK TIMEOUT timer");
230 		goto err_timer;
231 	}
232 
233 	cfgValue = 1000;
234 	cfgValue = SYS_MS_TO_TICKS(cfgValue);
235 	if (tx_timer_create(mac, &mac->lim.lim_timers.gLimDeauthAckTimer,
236 			    "DISASSOC ACK TIMEOUT",
237 			    lim_process_deauth_ack_timeout,
238 			    WLAN_INVALID_VDEV_ID,
239 			    cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
240 		pe_err("could not create DEAUTH ACK TIMEOUT timer");
241 		goto err_timer;
242 	}
243 
244 	if ((tx_timer_create(mac,
245 			     &mac->lim.lim_timers.rrm_sta_stats_resp_timer,
246 			     "STA STATS RSP timer",
247 			     lim_timer_handler,
248 			     SIR_LIM_RRM_STA_STATS_RSP_TIMEOUT,
249 			     SYS_MS_TO_TICKS(LIM_RRM_STA_STATS_RSP_TIMER_MS), 0,
250 			     TX_NO_ACTIVATE)) != TX_SUCCESS) {
251 		pe_err("could not create STA STATS RSP Timer");
252 		goto err_timer;
253 	}
254 	return TX_SUCCESS;
255 
256 err_timer:
257 	lim_delete_timers_host_roam(mac);
258 	tx_timer_delete(&mac->lim.lim_timers.rrm_sta_stats_resp_timer);
259 	tx_timer_delete(&mac->lim.lim_timers.gLimDeauthAckTimer);
260 	tx_timer_delete(&mac->lim.lim_timers.gLimDisassocAckTimer);
261 	tx_timer_delete(&mac->lim.lim_timers.gLimUpdateOlbcCacheTimer);
262 	while (((int32_t)-- i) >= 0) {
263 		tx_timer_delete(&mac->lim.lim_timers.gpLimCnfWaitTimer[i]);
264 	}
265 	tx_timer_delete(&mac->lim.lim_timers.gLimAuthFailureTimer);
266 	tx_timer_delete(&mac->lim.lim_timers.gLimAddtsRspTimer);
267 	tx_timer_delete(&mac->lim.lim_timers.gLimAssocFailureTimer);
268 	tx_timer_delete(&mac->lim.lim_timers.gLimJoinFailureTimer);
269 	tx_timer_delete(&mac->lim.lim_timers.gLimPeriodicJoinProbeReqTimer);
270 	tx_timer_delete(&mac->lim.lim_timers.g_lim_periodic_auth_retry_timer);
271 	tx_timer_delete(&mac->lim.lim_timers.sae_auth_timer);
272 
273 	if (mac->lim.gLimPreAuthTimerTable.pTable) {
274 		for (i = 0; i < mac->lim.gLimPreAuthTimerTable.numEntry; i++)
275 			qdf_mem_free(mac->lim.gLimPreAuthTimerTable.pTable[i]);
276 		qdf_mem_free(mac->lim.gLimPreAuthTimerTable.pTable);
277 		mac->lim.gLimPreAuthTimerTable.pTable = NULL;
278 	}
279 	return TX_TIMER_ERROR;
280 } /****** end lim_create_timers() ******/
281 
282 /**
283  * lim_timer_handler()
284  *
285  ***FUNCTION:
286  * This function is called upon
287  * 1. MIN_CHANNEL, MAX_CHANNEL timer expiration during scanning
288  * 2. JOIN_FAILURE timer expiration while joining a BSS
289  * 3. AUTH_FAILURE timer expiration while authenticating with a peer
290  * 4. Heartbeat timer expiration on STA
291  * 5. Background scan timer expiration on STA
292  * 6. AID release, Pre-auth cleanup and Link monitoring timer
293  *    expiration on AP
294  *
295  ***LOGIC:
296  *
297  ***ASSUMPTIONS:
298  * NA
299  *
300  ***NOTE:
301  * NA
302  *
303  * @param  param - Message corresponding to the timer that expired
304  *
305  * @return None
306  */
307 
lim_timer_handler(void * pMacGlobal,uint32_t param)308 void lim_timer_handler(void *pMacGlobal, uint32_t param)
309 {
310 	QDF_STATUS status;
311 	struct scheduler_msg msg = {0};
312 	struct mac_context *mac = (struct mac_context *) pMacGlobal;
313 
314 	/* Prepare and post message to LIM Message Queue */
315 
316 	msg.type = (uint16_t) param;
317 	msg.bodyptr = NULL;
318 	msg.bodyval = 0;
319 
320 	pe_debug("param %X ", msg.type);
321 
322 	status = lim_post_msg_high_priority(mac, &msg);
323 	if (status != QDF_STATUS_SUCCESS)
324 		pe_err("posting message: %X to LIM failed, reason: %d",
325 			msg.type, status);
326 } /****** end lim_timer_handler() ******/
327 
328 /**
329  * lim_addts_response_timer_handler()
330  *
331  ***FUNCTION:
332  * This function is called upon Addts response timer expiration on sta
333  *
334  ***LOGIC:
335  * Message SIR_LIM_ADDTS_RSP_TIMEOUT is posted to gSirLimMsgQ
336  * when this function is executed.
337  *
338  ***ASSUMPTIONS:
339  * NA
340  *
341  ***NOTE:
342  * NA
343  *
344  * @param  param - pointer to pre-auth node
345  *
346  * @return None
347  */
348 
lim_addts_response_timer_handler(void * pMacGlobal,uint32_t param)349 void lim_addts_response_timer_handler(void *pMacGlobal, uint32_t param)
350 {
351 	struct scheduler_msg msg = {0};
352 	struct mac_context *mac = (struct mac_context *) pMacGlobal;
353 
354 	/* Prepare and post message to LIM Message Queue */
355 
356 	msg.type = SIR_LIM_ADDTS_RSP_TIMEOUT;
357 	msg.bodyval = param;
358 	msg.bodyptr = NULL;
359 
360 	lim_post_msg_api(mac, &msg);
361 } /****** end lim_auth_response_timer_handler() ******/
362 
363 /**
364  * lim_auth_response_timer_handler()
365  *
366  ***FUNCTION:
367  * This function is called upon Auth response timer expiration on AP
368  *
369  ***LOGIC:
370  * Message SIR_LIM_AUTH_RSP_TIMEOUT is posted to gSirLimMsgQ
371  * when this function is executed.
372  *
373  ***ASSUMPTIONS:
374  * NA
375  *
376  ***NOTE:
377  * NA
378  *
379  * @param  param - pointer to pre-auth node
380  *
381  * @return None
382  */
383 
lim_auth_response_timer_handler(void * pMacGlobal,uint32_t param)384 void lim_auth_response_timer_handler(void *pMacGlobal, uint32_t param)
385 {
386 	struct scheduler_msg msg = {0};
387 	struct mac_context *mac = (struct mac_context *) pMacGlobal;
388 
389 	/* Prepare and post message to LIM Message Queue */
390 
391 	msg.type = SIR_LIM_AUTH_RSP_TIMEOUT;
392 	msg.bodyptr = NULL;
393 	msg.bodyval = (uint32_t) param;
394 
395 	lim_post_msg_api(mac, &msg);
396 } /****** end lim_auth_response_timer_handler() ******/
397 
398 /**
399  * lim_assoc_failure_timer_handler()
400  *
401  * @mac_global  : Pointer to Global MAC structure
402  * @param       : Indicates whether this is assoc or reassoc failure timeout
403  *
404  * This function is called upon Re/Assoc failure timer expiration on STA.
405  * Message SIR_LIM_ASSOC_FAIL_TIMEOUT is posted to gSirLimMsgQ when this
406  * function is executed.
407  *
408  * Return void
409  */
lim_assoc_failure_timer_handler(void * mac_global,uint32_t param)410 void lim_assoc_failure_timer_handler(void *mac_global, uint32_t param)
411 {
412 	struct scheduler_msg msg = {0};
413 	struct mac_context *mac_ctx = (struct mac_context *) mac_global;
414 	struct pe_session *session = NULL;
415 
416 	session = mac_ctx->lim.pe_session;
417 	if (LIM_REASSOC == param && session
418 	    && session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE) {
419 		pe_err("Reassoc timeout happened");
420 		if (mac_ctx->lim.reAssocRetryAttempt <
421 		    LIM_MAX_REASSOC_RETRY_LIMIT) {
422 			lim_send_retry_reassoc_req_frame(mac_ctx,
423 			    session->pLimMlmReassocRetryReq, session);
424 			mac_ctx->lim.reAssocRetryAttempt++;
425 			pe_warn("Reassoc request retry is sent %d times",
426 				mac_ctx->lim.reAssocRetryAttempt);
427 			return;
428 		} else {
429 			pe_warn("Reassoc request retry MAX: %d reached",
430 				LIM_MAX_REASSOC_RETRY_LIMIT);
431 			if (session->pLimMlmReassocRetryReq) {
432 				qdf_mem_free(session->pLimMlmReassocRetryReq);
433 				session->pLimMlmReassocRetryReq = NULL;
434 			}
435 		}
436 	}
437 	/* Prepare and post message to LIM Message Queue */
438 	msg.type = SIR_LIM_ASSOC_FAIL_TIMEOUT;
439 	msg.bodyval = (uint32_t) param;
440 	msg.bodyptr = NULL;
441 	lim_post_msg_api(mac_ctx, &msg);
442 } /****** end lim_assoc_failure_timer_handler() ******/
443 
444 /**
445  * lim_update_olbc_cache_timer_handler()
446  *
447  ***FUNCTION:
448  * This function is called upon update olbc cache timer expiration
449  * on STA
450  *
451  ***LOGIC:
452  * Message SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT is posted to gSirLimMsgQ
453  * when this function is executed.
454  *
455  ***ASSUMPTIONS:
456  * NA
457  *
458  ***NOTE:
459  * NA
460  *
461  * @param
462  *
463  * @return None
464  */
lim_update_olbc_cache_timer_handler(void * pMacGlobal,uint32_t param)465 void lim_update_olbc_cache_timer_handler(void *pMacGlobal, uint32_t param)
466 {
467 	struct scheduler_msg msg = {0};
468 	struct mac_context *mac = (struct mac_context *) pMacGlobal;
469 
470 	/* Prepare and post message to LIM Message Queue */
471 
472 	msg.type = SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT;
473 	msg.bodyval = 0;
474 	msg.bodyptr = NULL;
475 
476 	lim_post_msg_api(mac, &msg);
477 } /****** end lim_update_olbc_cache_timer_handler() ******/
478 
479 /**
480  * lim_deactivate_and_change_timer()
481  *
482  ***FUNCTION:
483  * This function is called to deactivate and change a timer
484  * for future re-activation
485  *
486  ***LOGIC:
487  *
488  ***ASSUMPTIONS:
489  * NA
490  *
491  ***NOTE:
492  * NA
493  *
494  * @param  mac    - Pointer to Global MAC structure
495  * @param  timerId - enum of timer to be deactivated and changed
496  *                   This enum is defined in lim_utils.h file
497  *
498  * @return None
499  */
500 
lim_deactivate_and_change_timer(struct mac_context * mac,uint32_t timerId)501 void lim_deactivate_and_change_timer(struct mac_context *mac, uint32_t timerId)
502 {
503 	uint32_t val = 0;
504 	struct pe_session * session_entry;
505 
506 	switch (timerId) {
507 	case eLIM_REASSOC_FAIL_TIMER:
508 	case eLIM_FT_PREAUTH_RSP_TIMER:
509 		lim_deactivate_and_change_timer_host_roam(mac, timerId);
510 		break;
511 
512 	case eLIM_ADDTS_RSP_TIMER:
513 		mac->lim.gLimAddtsRspTimerCount++;
514 		if (tx_timer_deactivate(&mac->lim.lim_timers.gLimAddtsRspTimer)
515 		    != TX_SUCCESS) {
516 			/* Could not deactivate AddtsRsp Timer */
517 			/* Log error */
518 			pe_err("Unable to deactivate AddtsRsp timer");
519 		}
520 		break;
521 
522 	case eLIM_JOIN_FAIL_TIMER:
523 		if (tx_timer_deactivate
524 			    (&mac->lim.lim_timers.gLimJoinFailureTimer)
525 		    != TX_SUCCESS) {
526 			/**
527 			 * Could not deactivate Join Failure
528 			 * timer. Log error.
529 			 */
530 			pe_err("Unable to deactivate Join Failure timer");
531 		}
532 
533 		val = SYS_MS_TO_TICKS(
534 				mac->mlme_cfg->timeouts.join_failure_timeout);
535 
536 		if (tx_timer_change(&mac->lim.lim_timers.gLimJoinFailureTimer,
537 				    val, 0) != TX_SUCCESS) {
538 			/**
539 			 * Could not change Join Failure
540 			 * timer. Log error.
541 			 */
542 			pe_err("Unable to change Join Failure timer");
543 		}
544 
545 		break;
546 
547 	case eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER:
548 		if (tx_timer_deactivate
549 			    (&mac->lim.lim_timers.gLimPeriodicJoinProbeReqTimer)
550 		    != TX_SUCCESS) {
551 			/* Could not deactivate periodic join req Times. */
552 			pe_err("Unable to deactivate periodic join request timer");
553 		}
554 		val = SYS_MS_TO_TICKS(
555 			mac->mlme_cfg->timeouts.probe_req_retry_timeout);
556 		if (tx_timer_change
557 			    (&mac->lim.lim_timers.gLimPeriodicJoinProbeReqTimer,
558 			     val, 0) != TX_SUCCESS) {
559 			/* Could not change periodic join req times. */
560 			/* Log error */
561 			pe_err("Unable to change periodic join request timer");
562 		}
563 
564 		break;
565 
566 	case eLIM_AUTH_FAIL_TIMER:
567 		if (tx_timer_deactivate
568 			    (&mac->lim.lim_timers.gLimAuthFailureTimer)
569 		    != TX_SUCCESS) {
570 			/* Could not deactivate Auth failure timer. */
571 			/* Log error */
572 			pe_err("Unable to deactivate auth failure timer");
573 		}
574 		/* Change timer to reactivate it in future */
575 		val = SYS_MS_TO_TICKS(
576 				mac->mlme_cfg->timeouts.auth_failure_timeout);
577 
578 		if (tx_timer_change(&mac->lim.lim_timers.gLimAuthFailureTimer,
579 				    val, 0) != TX_SUCCESS) {
580 			/* Could not change Authentication failure timer. */
581 			/* Log error */
582 			pe_err("unable to change Auth failure timer");
583 		}
584 
585 		break;
586 
587 	case eLIM_AUTH_RETRY_TIMER:
588 
589 		if (tx_timer_deactivate
590 			  (&mac->lim.lim_timers.g_lim_periodic_auth_retry_timer)
591 							 != TX_SUCCESS) {
592 			/* Could not deactivate Auth Retry Timer. */
593 			pe_err("Unable to deactivate Auth Retry timer");
594 		}
595 		session_entry = pe_find_session_by_session_id(mac,
596 			mac->lim.lim_timers.
597 				g_lim_periodic_auth_retry_timer.sessionId);
598 		if (!session_entry) {
599 			pe_debug("session does not exist for given SessionId : %d",
600 				 mac->lim.lim_timers.
601 				 g_lim_periodic_auth_retry_timer.sessionId);
602 			break;
603 		}
604 		/* 3/5 of the beacon interval */
605 		val = (session_entry->beaconParams.beaconInterval * 3) / 5;
606 		val = SYS_MS_TO_TICKS(val);
607 		if (tx_timer_change
608 			 (&mac->lim.lim_timers.g_lim_periodic_auth_retry_timer,
609 							val, 0) != TX_SUCCESS) {
610 			/* Could not change Auth Retry timer. */
611 			pe_err("Unable to change Auth Retry timer");
612 		}
613 		break;
614 
615 	case eLIM_ASSOC_FAIL_TIMER:
616 		if (tx_timer_deactivate
617 			    (&mac->lim.lim_timers.gLimAssocFailureTimer) !=
618 		    TX_SUCCESS) {
619 			/* Could not deactivate Association failure timer. */
620 			/* Log error */
621 			pe_err("unable to deactivate Association failure timer");
622 		}
623 		/* Change timer to reactivate it in future */
624 		val = SYS_MS_TO_TICKS(
625 				mac->mlme_cfg->timeouts.assoc_failure_timeout);
626 
627 		if (tx_timer_change(&mac->lim.lim_timers.gLimAssocFailureTimer,
628 				    val, 0) != TX_SUCCESS) {
629 			/* Could not change Association failure timer. */
630 			/* Log error */
631 			pe_err("unable to change Assoc failure timer");
632 		}
633 
634 		break;
635 
636 	case eLIM_DISASSOC_ACK_TIMER:
637 		if (tx_timer_deactivate(
638 			&mac->lim.lim_timers.gLimDisassocAckTimer) !=
639 		    TX_SUCCESS) {
640 			/**
641 			** Could not deactivate Join Failure
642 			** timer. Log error.
643 			**/
644 			pe_err("Unable to deactivate Disassoc ack timer");
645 			return;
646 		}
647 		val = 1000;
648 		val = SYS_MS_TO_TICKS(val);
649 		if (tx_timer_change(&mac->lim.lim_timers.gLimDisassocAckTimer,
650 				    val, 0) != TX_SUCCESS) {
651 			/**
652 			 * Could not change Join Failure
653 			 * timer. Log error.
654 			 */
655 			pe_err("Unable to change timer");
656 			return;
657 		}
658 		break;
659 
660 	case eLIM_DEAUTH_ACK_TIMER:
661 		if (tx_timer_deactivate(&mac->lim.lim_timers.gLimDeauthAckTimer)
662 		    != TX_SUCCESS) {
663 			/**
664 			** Could not deactivate Join Failure
665 			** timer. Log error.
666 			**/
667 			pe_err("Unable to deactivate Deauth ack timer");
668 			return;
669 		}
670 		val = 1000;
671 		val = SYS_MS_TO_TICKS(val);
672 		if (tx_timer_change(&mac->lim.lim_timers.gLimDeauthAckTimer,
673 				    val, 0) != TX_SUCCESS) {
674 			/**
675 			 * Could not change Join Failure
676 			 * timer. Log error.
677 			 */
678 			pe_err("Unable to change timer");
679 			return;
680 		}
681 		break;
682 
683 	case eLIM_AUTH_SAE_TIMER:
684 		if (tx_timer_deactivate
685 		   (&mac->lim.lim_timers.sae_auth_timer)
686 		    != TX_SUCCESS)
687 			pe_err("Unable to deactivate SAE auth timer");
688 
689 		/* Change timer to reactivate it in future */
690 		val = SYS_MS_TO_TICKS(LIM_AUTH_SAE_TIMER_MS);
691 
692 		if (tx_timer_change(&mac->lim.lim_timers.sae_auth_timer,
693 				    val, 0) != TX_SUCCESS)
694 			pe_err("unable to change SAE auth timer");
695 
696 		break;
697 	case eLIM_RRM_STA_STATS_RSP_TIMER:
698 		if (tx_timer_deactivate
699 		   (&mac->lim.lim_timers.rrm_sta_stats_resp_timer)
700 		    != TX_SUCCESS)
701 			pe_err("Unable to deactivate STA STATS RSP timer");
702 
703 		/* Change timer to reactivate it in future */
704 		val = SYS_MS_TO_TICKS(LIM_RRM_STA_STATS_RSP_TIMER_MS);
705 
706 		if (tx_timer_change(
707 			&mac->lim.lim_timers.rrm_sta_stats_resp_timer,
708 			val, 0) != TX_SUCCESS)
709 			pe_err("unable to change STA STATS RSP timer");
710 
711 		break;
712 
713 	default:
714 		/* Invalid timerId. Log error */
715 		break;
716 	}
717 } /****** end lim_deactivate_and_change_timer() ******/
718 
719 /**
720  * lim_deactivate_and_change_per_sta_id_timer()
721  *
722  *
723  * @brief: This function is called to deactivate and change a per STA timer
724  * for future re-activation
725  *
726  ***LOGIC:
727  *
728  ***ASSUMPTIONS:
729  * NA
730  *
731  * @note   staId for eLIM_AUTH_RSP_TIMER is auth Node Index.
732  *
733  * @param  mac    - Pointer to Global MAC structure
734  * @param  timerId - enum of timer to be deactivated and changed
735  *                   This enum is defined in lim_utils.h file
736  * @param  staId   - staId
737  *
738  * @return None
739  */
740 
741 void
lim_deactivate_and_change_per_sta_id_timer(struct mac_context * mac,uint32_t timerId,uint16_t staId)742 lim_deactivate_and_change_per_sta_id_timer(struct mac_context *mac, uint32_t timerId,
743 					   uint16_t staId)
744 {
745 	uint32_t val;
746 
747 	switch (timerId) {
748 	case eLIM_CNF_WAIT_TIMER:
749 
750 		if (staId >= (mac->lim.maxStation + 1)) {
751 			pe_err("Invalid staId = %d ", staId);
752 			return;
753 		}
754 
755 		if (tx_timer_deactivate(&mac->lim.lim_timers.gpLimCnfWaitTimer[staId])
756 					!= TX_SUCCESS) {
757 			pe_err("unable to deactivate CNF wait timer");
758 		}
759 
760 		/* Change timer to reactivate it in future */
761 		val = mac->mlme_cfg->sta.wait_cnf_timeout;
762 		val = SYS_MS_TO_TICKS(val);
763 
764 		if (tx_timer_change
765 			    (&mac->lim.lim_timers.gpLimCnfWaitTimer[staId], val,
766 			    val) != TX_SUCCESS) {
767 			/* Could not change cnf timer. */
768 			/* Log error */
769 			pe_err("unable to change cnf wait timer");
770 		}
771 
772 		break;
773 
774 	case eLIM_AUTH_RSP_TIMER:
775 	{
776 		tLimPreAuthNode *pAuthNode;
777 
778 		pAuthNode =
779 			lim_get_pre_auth_node_from_index(mac,
780 							 &mac->lim.
781 							 gLimPreAuthTimerTable,
782 							 staId);
783 
784 		if (!pAuthNode) {
785 			pe_err("Invalid Pre Auth Index passed :%d",
786 				staId);
787 			break;
788 		}
789 
790 		if (tx_timer_deactivate(&pAuthNode->timer) !=
791 		    TX_SUCCESS) {
792 			/* Could not deactivate auth response timer. */
793 			/* Log error */
794 			pe_err("unable to deactivate auth response timer");
795 		}
796 		/* Change timer to reactivate it in future */
797 		val = SYS_MS_TO_TICKS(
798 				mac->mlme_cfg->timeouts.auth_rsp_timeout);
799 
800 		if (tx_timer_change(&pAuthNode->timer, val, 0) !=
801 		    TX_SUCCESS) {
802 			/* Could not change auth rsp timer. */
803 			/* Log error */
804 			pe_err("unable to change auth rsp timer");
805 		}
806 	}
807 	break;
808 
809 	default:
810 		/* Invalid timerId. Log error */
811 		break;
812 
813 	}
814 }
815 
816 /**
817  * lim_activate_cnf_timer()
818  *
819  ***FUNCTION:
820  * This function is called to activate a per STA timer
821  *
822  ***LOGIC:
823  *
824  ***ASSUMPTIONS:
825  * NA
826  *
827  ***NOTE:
828  * NA
829  *
830  * @param  mac    - Pointer to Global MAC structure
831  * @param  StaId   - staId
832  *
833  * @return None
834  */
835 
lim_activate_cnf_timer(struct mac_context * mac,uint16_t staId,struct pe_session * pe_session)836 void lim_activate_cnf_timer(struct mac_context *mac, uint16_t staId,
837 			    struct pe_session *pe_session)
838 {
839 	mac->lim.lim_timers.gpLimCnfWaitTimer[staId].sessionId =
840 		pe_session->peSessionId;
841 	if (tx_timer_activate(&mac->lim.lim_timers.gpLimCnfWaitTimer[staId])
842 	    != TX_SUCCESS) {
843 		pe_err("could not activate cnf wait timer");
844 	}
845 }
846 
847 /**
848  * lim_activate_auth_rsp_timer()
849  *
850  ***FUNCTION:
851  * This function is called to activate a per STA timer
852  *
853  ***LOGIC:
854  *
855  ***ASSUMPTIONS:
856  * NA
857  *
858  ***NOTE:
859  * NA
860  *
861  * @param  mac    - Pointer to Global MAC structure
862  * @param  id      - id
863  *
864  * @return None
865  */
866 
lim_activate_auth_rsp_timer(struct mac_context * mac,tLimPreAuthNode * pAuthNode)867 void lim_activate_auth_rsp_timer(struct mac_context *mac, tLimPreAuthNode *pAuthNode)
868 {
869 	if (tx_timer_activate(&pAuthNode->timer) != TX_SUCCESS) {
870 		/* / Could not activate auth rsp timer. */
871 		/* Log error */
872 		pe_err("could not activate auth rsp timer");
873 	}
874 }
875 
876 /**
877  * limAssocCnfWaitTmerHandler()
878  *
879  ***FUNCTION:
880  *        This function post a message to send a disassociate frame out.
881  *
882  ***LOGIC:
883  *
884  ***ASSUMPTIONS:
885  *
886  ***NOTE:
887  * NA
888  *
889  * @param
890  *
891  * @return None
892  */
893 
lim_cnf_wait_tmer_handler(void * pMacGlobal,uint32_t param)894 void lim_cnf_wait_tmer_handler(void *pMacGlobal, uint32_t param)
895 {
896 	struct scheduler_msg msg = {0};
897 	uint32_t status_code;
898 	struct mac_context *mac = (struct mac_context *) pMacGlobal;
899 
900 	msg.type = SIR_LIM_CNF_WAIT_TIMEOUT;
901 	msg.bodyval = (uint32_t) param;
902 	msg.bodyptr = NULL;
903 
904 	status_code = lim_post_msg_api(mac, &msg);
905 	if (status_code != QDF_STATUS_SUCCESS)
906 		pe_err("posting to LIM failed, reason: %d", status_code);
907 
908 }
909