blob: 0daff6af35bcb7a9587ab19f9a951282c769b369 [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_cfg_updates.cc contains the utility functions
30 * to handle various CFG parameter update events
31 * Author: Chandra Modumudi
32 * Date: 01/20/03
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 */
37
38#include "ani_global.h"
39
40#include "wni_cfg.h"
41#include "sir_mac_prot_def.h"
42#include "cfg_api.h"
43#include "lim_types.h"
44#include "lim_utils.h"
45#include "lim_prop_exts_utils.h"
46#include "sch_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048
49static void lim_update_config(tpAniSirGlobal pMac, tpPESession psessionEntry);
50
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051/** -------------------------------------------------------------
52 \fn lim_set_cfg_protection
53 \brief sets lim global cfg cache from the config.
54 \param tpAniSirGlobal pMac
55 \return None
56 -------------------------------------------------------------*/
57void lim_set_cfg_protection(tpAniSirGlobal pMac, tpPESession pesessionEntry)
58{
59 uint32_t val = 0;
60
61 if (pesessionEntry != NULL && LIM_IS_AP_ROLE(pesessionEntry)) {
62 if (pesessionEntry->gLimProtectionControl ==
63 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053064 qdf_mem_set((void *)&pesessionEntry->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 sizeof(tCfgProtection), 0);
66 else {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070067 pe_debug("frm11a = %d, from11b = %d, frm11g = %d, "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 "ht20 = %d, nongf = %d, lsigTxop = %d, "
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070069 "rifs = %d, obss = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 pesessionEntry->cfgProtection.fromlla,
71 pesessionEntry->cfgProtection.fromllb,
72 pesessionEntry->cfgProtection.fromllg,
73 pesessionEntry->cfgProtection.ht20,
74 pesessionEntry->cfgProtection.nonGf,
75 pesessionEntry->cfgProtection.lsigTxop,
76 pesessionEntry->cfgProtection.rifs,
77 pesessionEntry->cfgProtection.obss);
78 }
79 } else {
80 if (wlan_cfg_get_int(pMac, WNI_CFG_FORCE_POLICY_PROTECTION, &val)
81 != eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070082 pe_err("reading WNI_CFG_FORCE_POLICY_PROTECTION cfg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 return;
84 } else
85 pMac->lim.gLimProtectionControl = (uint8_t) val;
86
87 if (wlan_cfg_get_int(pMac, WNI_CFG_PROTECTION_ENABLED, &val) !=
88 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070089 pe_err("reading protection cfg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 return;
91 }
92
93 if (pMac->lim.gLimProtectionControl ==
94 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053095 qdf_mem_set((void *)&pMac->lim.cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 sizeof(tCfgProtection), 0);
97 else {
98 pMac->lim.cfgProtection.fromlla =
99 (val >> WNI_CFG_PROTECTION_ENABLED_FROM_llA) & 1;
100 pMac->lim.cfgProtection.fromllb =
101 (val >> WNI_CFG_PROTECTION_ENABLED_FROM_llB) & 1;
102 pMac->lim.cfgProtection.fromllg =
103 (val >> WNI_CFG_PROTECTION_ENABLED_FROM_llG) & 1;
104 pMac->lim.cfgProtection.ht20 =
105 (val >> WNI_CFG_PROTECTION_ENABLED_HT_20) & 1;
106 pMac->lim.cfgProtection.nonGf =
107 (val >> WNI_CFG_PROTECTION_ENABLED_NON_GF) & 1;
108 pMac->lim.cfgProtection.lsigTxop =
109 (val >> WNI_CFG_PROTECTION_ENABLED_LSIG_TXOP) & 1;
110 pMac->lim.cfgProtection.rifs =
111 (val >> WNI_CFG_PROTECTION_ENABLED_RIFS) & 1;
112 pMac->lim.cfgProtection.obss =
113 (val >> WNI_CFG_PROTECTION_ENABLED_OBSS) & 1;
114
115 }
116 }
117}
118
119/**
120 * lim_handle_param_update()
121 *
122 ***FUNCTION:
123 * This function is use to post a message whenever need indicate
124 * there is update of config parameter.
125 *
126 ***PARAMS:
127 *
128 ***LOGIC:
129 *
130 ***ASSUMPTIONS:
131 * NA
132 *
133 ***NOTE:
134 *
135 * @param pMac - Pointer to Global MAC structure
136 * @param cfgId - ID of CFG parameter that got updated
137 * @return None
138 */
139void lim_handle_param_update(tpAniSirGlobal pMac, eUpdateIEsType cfgId)
140{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800141 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 uint32_t status;
143
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700144 pe_debug("Handling CFG parameter id %X update", cfgId);
145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 switch (cfgId) {
147 case eUPDATE_IE_PROBE_BCN:
148 {
149 msg.type = SIR_LIM_UPDATE_BEACON;
150 status = lim_post_msg_api(pMac, &msg);
151
152 if (status != TX_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700153 pe_err("Failed lim_post_msg_api %u", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 break;
155 }
156 default:
157 break;
158 }
159}
160
161/**
162 * lim_handle_cf_gparam_update()
163 *
164 ***FUNCTION:
165 * This function is called by lim_process_messages() to
166 * whenever SIR_CFG_PARAM_UPDATE_IND message is posted
167 * to LIM (due to a set operation on a CFG parameter).
168 *
169 ***PARAMS:
170 *
171 ***LOGIC:
172 *
173 ***ASSUMPTIONS:
174 * NA
175 *
176 ***NOTE:
177 *
178 * @param pMac - Pointer to Global MAC structure
179 * @param cfgId - ID of CFG parameter that got updated
180 * @return None
181 */
182
183void lim_handle_cf_gparam_update(tpAniSirGlobal pMac, uint32_t cfgId)
184{
185 uint32_t val1, val2;
186 uint16_t val16;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 tSirMacHTParametersInfo *pAmpduParamInfo;
188
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700189 pe_debug("Handling CFG parameter id %X update", cfgId);
190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 switch (cfgId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192 case WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT:
193 if (pMac->lim.gLimMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) {
194 /* 'Change' timer for future activations */
195 lim_deactivate_and_change_timer(pMac,
196 eLIM_ASSOC_FAIL_TIMER);
197 }
198
199 break;
200
201 case WNI_CFG_PROTECTION_ENABLED:
202 lim_set_cfg_protection(pMac, NULL);
203 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 case WNI_CFG_MPDU_DENSITY:
206 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
207 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700208 pe_err("could not retrieve HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 break;
210 }
211 if (wlan_cfg_get_int(pMac, WNI_CFG_MPDU_DENSITY, &val2) !=
212 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700213 pe_err("could not retrieve MPDU Density CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 break;
215 }
216 val16 = (uint16_t) val1;
217 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
218 pAmpduParamInfo->mpduDensity = (uint8_t) val2;
219 if (cfg_set_int
220 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
221 *(uint8_t *) pAmpduParamInfo) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700222 pe_err("could not update HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 break;
224 case WNI_CFG_MAX_RX_AMPDU_FACTOR:
225 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
226 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700227 pe_err("could not retrieve HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 break;
229 }
230 if (wlan_cfg_get_int(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) !=
231 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700232 pe_err("could not retrieve AMPDU Factor CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 break;
234 }
235 val16 = (uint16_t) val1;
236 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
237 pAmpduParamInfo->maxRxAMPDUFactor = (uint8_t) val2;
238 if (cfg_set_int
239 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
240 *(uint8_t *) pAmpduParamInfo) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700241 pe_err("could not update HT AMPDU Param CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 break;
243
244 case WNI_CFG_DOT11_MODE:
245 if (wlan_cfg_get_int(pMac, WNI_CFG_DOT11_MODE, &val1) !=
246 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700247 pe_err("could not retrieve Dot11 Mode CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 break;
249 }
250 break;
251
252 case WNI_CFG_SCAN_IN_POWERSAVE:
253 if (wlan_cfg_get_int(pMac, WNI_CFG_SCAN_IN_POWERSAVE, &val1) !=
254 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700255 pe_err("Unable to get WNI_CFG_SCAN_IN_POWERSAVE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 break;
257 }
258 pMac->lim.gScanInPowersave = (uint8_t) val1;
259 break;
260
261 case WNI_CFG_ASSOC_STA_LIMIT:
262 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val1) !=
263 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700264 pe_err("Unable to get WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265 break;
266 }
267 pMac->lim.gLimAssocStaLimit = (uint16_t) val1;
268 break;
269 default:
270 break;
271 }
272} /*** end lim_handle_cf_gparam_update() ***/
273
274/**
275 * lim_apply_configuration()
276 *
277 ***FUNCTION:
278 * This function is called to apply the configured parameters
279 * before joining or reassociating with a BSS or starting a BSS.
280 *
281 ***PARAMS:
282 *
283 ***LOGIC:
284 *
285 ***ASSUMPTIONS:
286 * NA
287 *
288 ***NOTE:
289 *
290 * @param pMac - Pointer to Global MAC structure
291 * @return None
292 */
293
294void lim_apply_configuration(tpAniSirGlobal pMac, tpPESession psessionEntry)
295{
296 uint32_t val = 0, phyMode;
297
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700298 pe_debug("Applying config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300 psessionEntry->limSentCapsChangeNtf = false;
301
302 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 lim_update_config(pMac, psessionEntry);
305
306 lim_get_short_slot_from_phy_mode(pMac, psessionEntry, phyMode,
307 &psessionEntry->shortSlotTimeSupported);
308
309 lim_set_cfg_protection(pMac, psessionEntry);
310
311 /* Added for BT - AMP Support */
312 if (LIM_IS_AP_ROLE(psessionEntry) ||
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700313 LIM_IS_IBSS_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 /* This check is required to ensure the beacon generation is not done
315 as a part of join request for a BT-AMP station */
316
317 if (psessionEntry->statypeForBss == STA_ENTRY_SELF) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700318 pe_debug("Initializing BT-AMP beacon generation");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 sch_set_beacon_interval(pMac, psessionEntry);
320 sch_set_fixed_beacon_fields(pMac, psessionEntry);
321 }
322 }
323
324 if (wlan_cfg_get_int(pMac, WNI_CFG_SCAN_IN_POWERSAVE, &val) !=
325 eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700326 pe_err("could not retrieve WNI_CFG_SCAN_IN_POWERSAVE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 return;
328 }
329
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700330 pe_debug("pMac->lim.gScanInPowersave = %hu",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 pMac->lim.gScanInPowersave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 pMac->lim.gScanInPowersave = (uint8_t) val;
333
334} /*** end lim_apply_configuration() ***/
335
336/**
337 * lim_update_config
338 *
339 * FUNCTION:
340 * Update the local state from CFG database
341 * (This used to be dphUpdateConfig)
342 *
343 * LOGIC:
344 *
345 * ASSUMPTIONS:
346 *
347 * NOTE:
348 *
349 * @param None
350 * @return None
351 */
352
353static void lim_update_config(tpAniSirGlobal pMac, tpPESession psessionEntry)
354{
355 uint32_t val;
356
357 sir_copy_mac_addr(pMac->lim.gLimMyMacAddr, psessionEntry->selfMacAddr);
358
359 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700360 pe_err("cfg get short preamble failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 psessionEntry->beaconParams.fShortPreamble = (val) ? 1 : 0;
362
363 /* In STA case this parameter is filled during the join request */
364 if (LIM_IS_AP_ROLE(psessionEntry) ||
365 LIM_IS_IBSS_ROLE(psessionEntry)) {
366 if (wlan_cfg_get_int(pMac, WNI_CFG_WME_ENABLED, &val) !=
367 eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700368 pe_err("cfg get wme enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 psessionEntry->limWmeEnabled = (val) ? 1 : 0;
370 }
371
372 if (wlan_cfg_get_int(pMac, WNI_CFG_WSM_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700373 pe_err("cfg get wsm enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 psessionEntry->limWsmEnabled = (val) ? 1 : 0;
375
376 if ((!psessionEntry->limWmeEnabled) && (psessionEntry->limWsmEnabled)) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700377 pe_err("Can't enable WSM without WME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 psessionEntry->limWsmEnabled = 0;
379 }
380 /* In STA , this parameter is filled during the join request */
381 if (LIM_IS_AP_ROLE(psessionEntry) || LIM_IS_IBSS_ROLE(psessionEntry)) {
382 if (wlan_cfg_get_int(pMac, WNI_CFG_QOS_ENABLED, &val) !=
383 eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700384 pe_err("cfg get qos enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 psessionEntry->limQosEnabled = (val) ? 1 : 0;
386 }
387 if (wlan_cfg_get_int(pMac, WNI_CFG_HCF_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700388 pe_err("cfg get hcf enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 psessionEntry->limHcfEnabled = (val) ? 1 : 0;
390
391 /* AP: WSM should enable HCF as well, for STA enable WSM only after */
392 /* association response is received */
393 if (psessionEntry->limWsmEnabled && LIM_IS_AP_ROLE(psessionEntry))
394 psessionEntry->limHcfEnabled = 1;
395
396 if (wlan_cfg_get_int(pMac, WNI_CFG_11D_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700397 pe_err("cfg get 11d enabled failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 psessionEntry->lim11dEnabled = (val) ? 1 : 0;
399
400 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700401 pe_err("cfg get assoc sta limit failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 }
403 pMac->lim.gLimAssocStaLimit = (uint16_t) val;
404
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700405 pe_debug("Updated Lim shadow state based on CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406}