xref: /wlan-driver/qcacld-3.0/core/mac/src/pe/lim/lim_process_cfg_updates.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4 
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /*
22  * This file lim_process_cfg_updates.cc contains the utility functions
23  * to handle various CFG parameter update events
24  * Author:        Chandra Modumudi
25  * Date:          01/20/03
26  * History:-
27  * Date           Modified by    Modification Information
28  * --------------------------------------------------------------------
29  */
30 
31 #include "ani_global.h"
32 
33 #include "wni_cfg.h"
34 #include "sir_mac_prot_def.h"
35 #include "lim_types.h"
36 #include "lim_utils.h"
37 #include "lim_prop_exts_utils.h"
38 #include "sch_api.h"
39 #include "rrm_api.h"
40 
41 static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session);
42 
lim_set_cfg_protection(struct mac_context * mac,struct pe_session * pesessionEntry)43 void lim_set_cfg_protection(struct mac_context *mac, struct pe_session *pesessionEntry)
44 {
45 	uint32_t val = 0;
46 	struct wlan_mlme_cfg *mlme_cfg = mac->mlme_cfg;
47 
48 	if (pesessionEntry && LIM_IS_AP_ROLE(pesessionEntry)) {
49 		if (pesessionEntry->gLimProtectionControl ==
50 		    MLME_FORCE_POLICY_PROTECTION_DISABLE)
51 			qdf_mem_zero((void *)&pesessionEntry->cfgProtection,
52 				    sizeof(tCfgProtection));
53 		else {
54 			pe_debug("frm11a = %d, from11b = %d, frm11g = %d, "
55 				   "ht20 = %d, nongf = %d, lsigTxop = %d, "
56 				   "rifs = %d, obss = %d",
57 				pesessionEntry->cfgProtection.fromlla,
58 				pesessionEntry->cfgProtection.fromllb,
59 				pesessionEntry->cfgProtection.fromllg,
60 				pesessionEntry->cfgProtection.ht20,
61 				pesessionEntry->cfgProtection.nonGf,
62 				pesessionEntry->cfgProtection.lsigTxop,
63 				pesessionEntry->cfgProtection.rifs,
64 				pesessionEntry->cfgProtection.obss);
65 		}
66 	} else {
67 		mac->lim.gLimProtectionControl =
68 			mlme_cfg->sap_protection_cfg.protection_force_policy;
69 
70 
71 		if (mac->lim.gLimProtectionControl ==
72 		    MLME_FORCE_POLICY_PROTECTION_DISABLE)
73 			qdf_mem_zero((void *)&mac->lim.cfgProtection,
74 				    sizeof(tCfgProtection));
75 		else {
76 			val = mlme_cfg->sap_protection_cfg.protection_enabled;
77 
78 			mac->lim.cfgProtection.fromlla =
79 				(val >> MLME_PROTECTION_ENABLED_FROM_llA) & 1;
80 			mac->lim.cfgProtection.fromllb =
81 				(val >> MLME_PROTECTION_ENABLED_FROM_llB) & 1;
82 			mac->lim.cfgProtection.fromllg =
83 				(val >> MLME_PROTECTION_ENABLED_FROM_llG) & 1;
84 			mac->lim.cfgProtection.ht20 =
85 				(val >> MLME_PROTECTION_ENABLED_HT_20) & 1;
86 			mac->lim.cfgProtection.nonGf =
87 				(val >> MLME_PROTECTION_ENABLED_NON_GF) & 1;
88 			mac->lim.cfgProtection.lsigTxop =
89 				(val >> MLME_PROTECTION_ENABLED_LSIG_TXOP) & 1;
90 			mac->lim.cfgProtection.rifs =
91 				(val >> MLME_PROTECTION_ENABLED_RIFS) & 1;
92 			mac->lim.cfgProtection.obss =
93 				(val >> MLME_PROTECTION_ENABLED_OBSS) & 1;
94 
95 		}
96 	}
97 }
98 
99 /**
100  * lim_handle_param_update()
101  *
102  ***FUNCTION:
103  * This function is use to post a message whenever need indicate
104  * there is update of config parameter.
105  *
106  ***PARAMS:
107  *
108  ***LOGIC:
109  *
110  ***ASSUMPTIONS:
111  * NA
112  *
113  ***NOTE:
114  *
115  * @param  mac  - Pointer to Global MAC structure
116  * @param  cfgId - ID of CFG parameter that got updated
117  * @return None
118  */
lim_handle_param_update(struct mac_context * mac,eUpdateIEsType cfgId)119 void lim_handle_param_update(struct mac_context *mac, eUpdateIEsType cfgId)
120 {
121 	struct scheduler_msg msg = { 0 };
122 	QDF_STATUS status;
123 
124 	pe_debug("Handling CFG parameter id %X update", cfgId);
125 
126 	switch (cfgId) {
127 	case eUPDATE_IE_PROBE_BCN:
128 	{
129 		msg.type = SIR_LIM_UPDATE_BEACON;
130 		status = lim_post_msg_api(mac, &msg);
131 
132 		if (status != QDF_STATUS_SUCCESS)
133 			pe_err("Failed lim_post_msg_api %u", status);
134 		break;
135 	}
136 	default:
137 		break;
138 	}
139 }
140 
141 /**
142  * lim_apply_configuration()
143  *
144  ***FUNCTION:
145  * This function is called to apply the configured parameters
146  * before joining or reassociating with a BSS or starting a BSS.
147  *
148  ***PARAMS:
149  *
150  ***LOGIC:
151  *
152  ***ASSUMPTIONS:
153  * NA
154  *
155  ***NOTE:
156  *
157  * @param  mac  - Pointer to Global MAC structure
158  * @return None
159  */
160 
lim_apply_configuration(struct mac_context * mac,struct pe_session * pe_session)161 void lim_apply_configuration(struct mac_context *mac, struct pe_session *pe_session)
162 {
163 	uint32_t phyMode;
164 
165 	pe_session->limSentCapsChangeNtf = false;
166 
167 	lim_get_phy_mode(mac, &phyMode, pe_session);
168 
169 	lim_update_config(mac, pe_session);
170 
171 	lim_get_short_slot_from_phy_mode(mac, pe_session, phyMode,
172 					 &pe_session->shortSlotTimeSupported);
173 
174 	lim_set_cfg_protection(mac, pe_session);
175 
176 	/* Added for BT - AMP Support */
177 	if (LIM_IS_AP_ROLE(pe_session)) {
178 		/* This check is required to ensure the beacon generation is not done
179 		   as a part of join request for a BT-AMP station */
180 
181 		if (pe_session->statypeForBss == STA_ENTRY_SELF) {
182 			sch_set_beacon_interval(mac, pe_session);
183 			sch_set_fixed_beacon_fields(mac, pe_session);
184 		}
185 	}
186 } /*** end lim_apply_configuration() ***/
187 
188 /**
189  * lim_update_config
190  *
191  * FUNCTION:
192  * Update the local state from CFG database
193  * (This used to be dphUpdateConfig)
194  *
195  * LOGIC:
196  *
197  * ASSUMPTIONS:
198  *
199  * NOTE:
200  *
201  * @param None
202  * @return None
203  */
204 
lim_update_config(struct mac_context * mac,struct pe_session * pe_session)205 static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session)
206 {
207 	bool enabled;
208 
209 	pe_session->beaconParams.fShortPreamble =
210 					mac->mlme_cfg->ht_caps.short_preamble;
211 
212 	/* In STA case this parameter is filled during the join request */
213 	if (LIM_IS_AP_ROLE(pe_session)) {
214 		enabled = mac->mlme_cfg->wmm_params.wme_enabled;
215 		pe_session->limWmeEnabled = enabled;
216 	}
217 	enabled = mac->mlme_cfg->wmm_params.wsm_enabled;
218 	pe_session->limWsmEnabled = enabled;
219 
220 	if ((!pe_session->limWmeEnabled) && (pe_session->limWsmEnabled)) {
221 		pe_err("Can't enable WSM without WME");
222 		pe_session->limWsmEnabled = 0;
223 	}
224 	/* In STA , this parameter is filled during the join request */
225 	if (LIM_IS_AP_ROLE(pe_session)) {
226 		enabled = mac->mlme_cfg->wmm_params.qos_enabled;
227 		pe_session->limQosEnabled = enabled;
228 	}
229 	pe_session->limHcfEnabled = mac->mlme_cfg->feature_flags.enable_hcf;
230 
231 	/* AP: WSM should enable HCF as well, for STA enable WSM only after */
232 	/* association response is received */
233 	if (pe_session->limWsmEnabled && LIM_IS_AP_ROLE(pe_session))
234 		pe_session->limHcfEnabled = 1;
235 
236 	pe_debug("Updated Lim shadow state based on CFG");
237 }
238