blob: aa0d566bdbd1b75f04097d8fd5d585e98d5fe395 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Wu Gao8800cb12018-02-09 12:29:27 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * 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/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_cfg_updates.cc contains the utility functions
21 * to handle various CFG parameter update events
22 * Author: Chandra Modumudi
23 * Date: 01/20/03
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 */
28
29#include "ani_global.h"
30
31#include "wni_cfg.h"
32#include "sir_mac_prot_def.h"
33#include "cfg_api.h"
34#include "lim_types.h"
35#include "lim_utils.h"
36#include "lim_prop_exts_utils.h"
37#include "sch_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039
40static void lim_update_config(tpAniSirGlobal pMac, tpPESession psessionEntry);
41
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042void lim_set_cfg_protection(tpAniSirGlobal pMac, tpPESession pesessionEntry)
43{
44 uint32_t val = 0;
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053045 struct wlan_mlme_cfg *mlme_cfg = pMac->mlme_cfg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046
47 if (pesessionEntry != NULL && LIM_IS_AP_ROLE(pesessionEntry)) {
48 if (pesessionEntry->gLimProtectionControl ==
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053049 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053050 qdf_mem_set((void *)&pesessionEntry->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051 sizeof(tCfgProtection), 0);
52 else {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070053 pe_debug("frm11a = %d, from11b = %d, frm11g = %d, "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054 "ht20 = %d, nongf = %d, lsigTxop = %d, "
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070055 "rifs = %d, obss = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056 pesessionEntry->cfgProtection.fromlla,
57 pesessionEntry->cfgProtection.fromllb,
58 pesessionEntry->cfgProtection.fromllg,
59 pesessionEntry->cfgProtection.ht20,
60 pesessionEntry->cfgProtection.nonGf,
61 pesessionEntry->cfgProtection.lsigTxop,
62 pesessionEntry->cfgProtection.rifs,
63 pesessionEntry->cfgProtection.obss);
64 }
65 } else {
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053066 pMac->lim.gLimProtectionControl =
67 mlme_cfg->sap_protection_cfg.protection_force_policy;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70 if (pMac->lim.gLimProtectionControl ==
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053071 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053072 qdf_mem_set((void *)&pMac->lim.cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 sizeof(tCfgProtection), 0);
74 else {
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053075 val = mlme_cfg->sap_protection_cfg.protection_enabled;
76
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 pMac->lim.cfgProtection.fromlla =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053078 (val >> MLME_PROTECTION_ENABLED_FROM_llA) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 pMac->lim.cfgProtection.fromllb =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053080 (val >> MLME_PROTECTION_ENABLED_FROM_llB) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 pMac->lim.cfgProtection.fromllg =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053082 (val >> MLME_PROTECTION_ENABLED_FROM_llG) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 pMac->lim.cfgProtection.ht20 =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053084 (val >> MLME_PROTECTION_ENABLED_HT_20) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 pMac->lim.cfgProtection.nonGf =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053086 (val >> MLME_PROTECTION_ENABLED_NON_GF) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 pMac->lim.cfgProtection.lsigTxop =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053088 (val >> MLME_PROTECTION_ENABLED_LSIG_TXOP) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 pMac->lim.cfgProtection.rifs =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053090 (val >> MLME_PROTECTION_ENABLED_RIFS) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 pMac->lim.cfgProtection.obss =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053092 (val >> MLME_PROTECTION_ENABLED_OBSS) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093
94 }
95 }
96}
97
98/**
99 * lim_handle_param_update()
100 *
101 ***FUNCTION:
102 * This function is use to post a message whenever need indicate
103 * there is update of config parameter.
104 *
105 ***PARAMS:
106 *
107 ***LOGIC:
108 *
109 ***ASSUMPTIONS:
110 * NA
111 *
112 ***NOTE:
113 *
114 * @param pMac - Pointer to Global MAC structure
115 * @param cfgId - ID of CFG parameter that got updated
116 * @return None
117 */
118void lim_handle_param_update(tpAniSirGlobal pMac, eUpdateIEsType cfgId)
119{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800120 struct scheduler_msg msg = { 0 };
Jeff Johnsonc9f44622018-06-29 14:18:53 -0700121 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700123 pe_debug("Handling CFG parameter id %X update", cfgId);
124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 switch (cfgId) {
126 case eUPDATE_IE_PROBE_BCN:
127 {
128 msg.type = SIR_LIM_UPDATE_BEACON;
129 status = lim_post_msg_api(pMac, &msg);
130
Jeff Johnsonc9f44622018-06-29 14:18:53 -0700131 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700132 pe_err("Failed lim_post_msg_api %u", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 break;
134 }
135 default:
136 break;
137 }
138}
139
140/**
141 * lim_handle_cf_gparam_update()
142 *
143 ***FUNCTION:
144 * This function is called by lim_process_messages() to
145 * whenever SIR_CFG_PARAM_UPDATE_IND message is posted
146 * to LIM (due to a set operation on a CFG parameter).
147 *
148 ***PARAMS:
149 *
150 ***LOGIC:
151 *
152 ***ASSUMPTIONS:
153 * NA
154 *
155 ***NOTE:
156 *
157 * @param pMac - Pointer to Global MAC structure
158 * @param cfgId - ID of CFG parameter that got updated
159 * @return None
160 */
161
162void lim_handle_cf_gparam_update(tpAniSirGlobal pMac, uint32_t cfgId)
163{
164 uint32_t val1, val2;
165 uint16_t val16;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 tSirMacHTParametersInfo *pAmpduParamInfo;
167
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700168 pe_debug("Handling CFG parameter id %X update", cfgId);
169
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 switch (cfgId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 case WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT:
172 if (pMac->lim.gLimMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) {
173 /* 'Change' timer for future activations */
174 lim_deactivate_and_change_timer(pMac,
175 eLIM_ASSOC_FAIL_TIMER);
176 }
177
178 break;
179
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 case WNI_CFG_MPDU_DENSITY:
181 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700182 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700183 pe_err("could not retrieve HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 break;
185 }
186 if (wlan_cfg_get_int(pMac, WNI_CFG_MPDU_DENSITY, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700187 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700188 pe_err("could not retrieve MPDU Density CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 break;
190 }
191 val16 = (uint16_t) val1;
192 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
193 pAmpduParamInfo->mpduDensity = (uint8_t) val2;
194 if (cfg_set_int
195 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700196 *(uint8_t *) pAmpduParamInfo) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700197 pe_err("could not update HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 break;
199 case WNI_CFG_MAX_RX_AMPDU_FACTOR:
200 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700201 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700202 pe_err("could not retrieve HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 break;
204 }
205 if (wlan_cfg_get_int(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700206 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700207 pe_err("could not retrieve AMPDU Factor CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 break;
209 }
210 val16 = (uint16_t) val1;
211 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
212 pAmpduParamInfo->maxRxAMPDUFactor = (uint8_t) val2;
213 if (cfg_set_int
214 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700215 *(uint8_t *) pAmpduParamInfo) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700216 pe_err("could not update HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 break;
218
219 case WNI_CFG_DOT11_MODE:
220 if (wlan_cfg_get_int(pMac, WNI_CFG_DOT11_MODE, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700221 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700222 pe_err("could not retrieve Dot11 Mode CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 break;
224 }
225 break;
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 default:
228 break;
229 }
230} /*** end lim_handle_cf_gparam_update() ***/
231
232/**
233 * lim_apply_configuration()
234 *
235 ***FUNCTION:
236 * This function is called to apply the configured parameters
237 * before joining or reassociating with a BSS or starting a BSS.
238 *
239 ***PARAMS:
240 *
241 ***LOGIC:
242 *
243 ***ASSUMPTIONS:
244 * NA
245 *
246 ***NOTE:
247 *
248 * @param pMac - Pointer to Global MAC structure
249 * @return None
250 */
251
252void lim_apply_configuration(tpAniSirGlobal pMac, tpPESession psessionEntry)
253{
254 uint32_t val = 0, phyMode;
255
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700256 pe_debug("Applying config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257
258 psessionEntry->limSentCapsChangeNtf = false;
259
260 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
261
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 lim_update_config(pMac, psessionEntry);
263
264 lim_get_short_slot_from_phy_mode(pMac, psessionEntry, phyMode,
265 &psessionEntry->shortSlotTimeSupported);
266
267 lim_set_cfg_protection(pMac, psessionEntry);
268
269 /* Added for BT - AMP Support */
270 if (LIM_IS_AP_ROLE(psessionEntry) ||
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700271 LIM_IS_IBSS_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 /* This check is required to ensure the beacon generation is not done
273 as a part of join request for a BT-AMP station */
274
275 if (psessionEntry->statypeForBss == STA_ENTRY_SELF) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700276 pe_debug("Initializing BT-AMP beacon generation");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 sch_set_beacon_interval(pMac, psessionEntry);
278 sch_set_fixed_beacon_fields(pMac, psessionEntry);
279 }
280 }
281
282 if (wlan_cfg_get_int(pMac, WNI_CFG_SCAN_IN_POWERSAVE, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700283 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700284 pe_err("could not retrieve WNI_CFG_SCAN_IN_POWERSAVE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 return;
286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287} /*** end lim_apply_configuration() ***/
288
289/**
290 * lim_update_config
291 *
292 * FUNCTION:
293 * Update the local state from CFG database
294 * (This used to be dphUpdateConfig)
295 *
296 * LOGIC:
297 *
298 * ASSUMPTIONS:
299 *
300 * NOTE:
301 *
302 * @param None
303 * @return None
304 */
305
306static void lim_update_config(tpAniSirGlobal pMac, tpPESession psessionEntry)
307{
308 uint32_t val;
309
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700310 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700311 pe_err("cfg get short preamble failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 psessionEntry->beaconParams.fShortPreamble = (val) ? 1 : 0;
313
314 /* In STA case this parameter is filled during the join request */
315 if (LIM_IS_AP_ROLE(psessionEntry) ||
316 LIM_IS_IBSS_ROLE(psessionEntry)) {
317 if (wlan_cfg_get_int(pMac, WNI_CFG_WME_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700318 QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700319 pe_err("cfg get wme enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 psessionEntry->limWmeEnabled = (val) ? 1 : 0;
321 }
322
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700323 if (wlan_cfg_get_int(pMac, WNI_CFG_WSM_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700324 pe_err("cfg get wsm enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 psessionEntry->limWsmEnabled = (val) ? 1 : 0;
326
327 if ((!psessionEntry->limWmeEnabled) && (psessionEntry->limWsmEnabled)) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700328 pe_err("Can't enable WSM without WME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 psessionEntry->limWsmEnabled = 0;
330 }
331 /* In STA , this parameter is filled during the join request */
332 if (LIM_IS_AP_ROLE(psessionEntry) || LIM_IS_IBSS_ROLE(psessionEntry)) {
333 if (wlan_cfg_get_int(pMac, WNI_CFG_QOS_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700334 QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700335 pe_err("cfg get qos enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 psessionEntry->limQosEnabled = (val) ? 1 : 0;
337 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700338 if (wlan_cfg_get_int(pMac, WNI_CFG_HCF_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700339 pe_err("cfg get hcf enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 psessionEntry->limHcfEnabled = (val) ? 1 : 0;
341
342 /* AP: WSM should enable HCF as well, for STA enable WSM only after */
343 /* association response is received */
344 if (psessionEntry->limWsmEnabled && LIM_IS_AP_ROLE(psessionEntry))
345 psessionEntry->limHcfEnabled = 1;
346
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700347 if (wlan_cfg_get_int(pMac, WNI_CFG_11D_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700348 pe_err("cfg get 11d enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 psessionEntry->lim11dEnabled = (val) ? 1 : 0;
350
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700351 pe_debug("Updated Lim shadow state based on CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352}