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