xref: /wlan-driver/qcacld-3.0/core/mac/src/pe/lim/lim_roam_timer_utils.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: lim_roam_timer_utils.c
21  *
22  * Host based roaming timers implementation
23  */
24 
25 #include "lim_types.h"
26 #include "lim_utils.h"
27 #include "lim_assoc_utils.h"
28 #include "lim_security_utils.h"
29 
30 /**
31  * lim_create_timers_host_roam() - Create timers used in host based roaming
32  * @mac_ctx: Global MAC context
33  *
34  * Create reassoc and preauth timers
35  *
36  * Return: TX_SUCCESS or TX_TIMER_ERROR
37  */
lim_create_timers_host_roam(struct mac_context * mac_ctx)38 uint32_t lim_create_timers_host_roam(struct mac_context *mac_ctx)
39 {
40 	uint32_t cfg_value;
41 
42 	cfg_value = SYS_MS_TO_TICKS(
43 			mac_ctx->mlme_cfg->timeouts.reassoc_failure_timeout);
44 	/* Create Association failure timer and activate it later */
45 	if (tx_timer_create(mac_ctx,
46 			&mac_ctx->lim.lim_timers.gLimReassocFailureTimer,
47 		    "REASSOC FAILURE TIMEOUT", lim_assoc_failure_timer_handler,
48 		    LIM_REASSOC, cfg_value, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
49 		pe_err("failed to create Reassoc timer");
50 		return TX_TIMER_ERROR;
51 	}
52 	cfg_value = 1000;
53 	cfg_value = SYS_MS_TO_TICKS(cfg_value);
54 	if (tx_timer_create(mac_ctx,
55 			&mac_ctx->lim.lim_timers.gLimFTPreAuthRspTimer,
56 			"FT PREAUTH RSP TIMEOUT",
57 			lim_timer_handler, SIR_LIM_FT_PREAUTH_RSP_TIMEOUT,
58 			cfg_value, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
59 		pe_err("failed to create Join fail timer");
60 		goto err_roam_timer;
61 	}
62 	return TX_SUCCESS;
63 
64 err_roam_timer:
65 	tx_timer_delete(&mac_ctx->lim.lim_timers.gLimReassocFailureTimer);
66 	return TX_TIMER_ERROR;
67 }
68 
lim_delete_timers_host_roam(struct mac_context * mac_ctx)69 void lim_delete_timers_host_roam(struct mac_context *mac_ctx)
70 {
71 	tLimTimers *lim_timer = &mac_ctx->lim.lim_timers;
72 
73 	/* Delete Reassociation failure timer. */
74 	tx_timer_delete(&lim_timer->gLimReassocFailureTimer);
75 	/* Delete FT Preauth response timer */
76 	tx_timer_delete(&lim_timer->gLimFTPreAuthRspTimer);
77 }
78 
lim_deactivate_timers_host_roam(struct mac_context * mac_ctx)79 void lim_deactivate_timers_host_roam(struct mac_context *mac_ctx)
80 {
81 	tLimTimers *lim_timer = &mac_ctx->lim.lim_timers;
82 
83 	/* Deactivate Reassociation failure timer. */
84 	tx_timer_deactivate(&lim_timer->gLimReassocFailureTimer);
85 	/* Deactivate FT Preauth response timer */
86 	tx_timer_deactivate(&lim_timer->gLimFTPreAuthRspTimer);
87 }
88 
89 /**
90  * lim_deactivate_and_change_timer_host_roam() - Change timers in host roaming
91  * @mac_ctx: Pointer to Global MAC structure
92  * @timer_id: enum of timer to be deactivated and changed
93  *
94  * This function is called to deactivate and change a timer for future
95  * re-activation for host roaming timers.
96  *
97  * Return: None
98  */
lim_deactivate_and_change_timer_host_roam(struct mac_context * mac_ctx,uint32_t timer_id)99 void lim_deactivate_and_change_timer_host_roam(struct mac_context *mac_ctx,
100 		uint32_t timer_id)
101 {
102 	uint32_t val = 0;
103 
104 	switch (timer_id) {
105 	case eLIM_REASSOC_FAIL_TIMER:
106 		if (tx_timer_deactivate
107 			(&mac_ctx->lim.lim_timers.gLimReassocFailureTimer) !=
108 				TX_SUCCESS)
109 			pe_warn("unable to deactivate Reassoc fail timer");
110 
111 		val = SYS_MS_TO_TICKS(
112 			mac_ctx->mlme_cfg->timeouts.reassoc_failure_timeout);
113 		if (tx_timer_change
114 			(&mac_ctx->lim.lim_timers.gLimReassocFailureTimer, val,
115 			 0) != TX_SUCCESS)
116 			pe_warn("unable to change Reassoc fail timer");
117 		break;
118 
119 	case eLIM_FT_PREAUTH_RSP_TIMER:
120 		if (tx_timer_deactivate
121 			(&mac_ctx->lim.lim_timers.gLimFTPreAuthRspTimer) !=
122 			TX_SUCCESS) {
123 			pe_err("Unable to deactivate Preauth Fail timer");
124 			return;
125 		}
126 		val = 1000;
127 		val = SYS_MS_TO_TICKS(val);
128 		if (tx_timer_change(
129 				&mac_ctx->lim.lim_timers.gLimFTPreAuthRspTimer,
130 				val, 0) != TX_SUCCESS) {
131 			pe_err("Unable to change Join Failure timer");
132 			return;
133 		}
134 		break;
135 	}
136 }
137 
138