blob: eaee1d036aa9a8c71e3b71d7325c20093f583c37 [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
Jeff Johnson9320c1e2018-12-02 13:09:20 -080040static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041
Jeff Johnson9320c1e2018-12-02 13:09:20 -080042void lim_set_cfg_protection(struct mac_context *mac, struct pe_session *pesessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043{
44 uint32_t val = 0;
Jeff Johnson348973e2018-11-22 16:51:12 -080045 struct wlan_mlme_cfg *mlme_cfg = mac->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 {
Jeff Johnson348973e2018-11-22 16:51:12 -080066 mac->lim.gLimProtectionControl =
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053067 mlme_cfg->sap_protection_cfg.protection_force_policy;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
Jeff Johnson348973e2018-11-22 16:51:12 -080070 if (mac->lim.gLimProtectionControl ==
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053071 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson348973e2018-11-22 16:51:12 -080072 qdf_mem_set((void *)&mac->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
Jeff Johnson348973e2018-11-22 16:51:12 -080077 mac->lim.cfgProtection.fromlla =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053078 (val >> MLME_PROTECTION_ENABLED_FROM_llA) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080079 mac->lim.cfgProtection.fromllb =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053080 (val >> MLME_PROTECTION_ENABLED_FROM_llB) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080081 mac->lim.cfgProtection.fromllg =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053082 (val >> MLME_PROTECTION_ENABLED_FROM_llG) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080083 mac->lim.cfgProtection.ht20 =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053084 (val >> MLME_PROTECTION_ENABLED_HT_20) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080085 mac->lim.cfgProtection.nonGf =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053086 (val >> MLME_PROTECTION_ENABLED_NON_GF) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080087 mac->lim.cfgProtection.lsigTxop =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053088 (val >> MLME_PROTECTION_ENABLED_LSIG_TXOP) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080089 mac->lim.cfgProtection.rifs =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053090 (val >> MLME_PROTECTION_ENABLED_RIFS) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080091 mac->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 *
Jeff Johnson348973e2018-11-22 16:51:12 -0800114 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 * @param cfgId - ID of CFG parameter that got updated
116 * @return None
117 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800118void lim_handle_param_update(struct mac_context *mac, eUpdateIEsType cfgId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119{
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;
Jeff Johnson348973e2018-11-22 16:51:12 -0800129 status = lim_post_msg_api(mac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130
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/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 * lim_apply_configuration()
142 *
143 ***FUNCTION:
144 * This function is called to apply the configured parameters
145 * before joining or reassociating with a BSS or starting a BSS.
146 *
147 ***PARAMS:
148 *
149 ***LOGIC:
150 *
151 ***ASSUMPTIONS:
152 * NA
153 *
154 ***NOTE:
155 *
Jeff Johnson348973e2018-11-22 16:51:12 -0800156 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 * @return None
158 */
159
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800160void lim_apply_configuration(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161{
162 uint32_t val = 0, phyMode;
163
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700164 pe_debug("Applying config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800166 pe_session->limSentCapsChangeNtf = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800168 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800170 lim_update_config(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800172 lim_get_short_slot_from_phy_mode(mac, pe_session, phyMode,
173 &pe_session->shortSlotTimeSupported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800175 lim_set_cfg_protection(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176
177 /* Added for BT - AMP Support */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800178 if (LIM_IS_AP_ROLE(pe_session) ||
179 LIM_IS_IBSS_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 /* This check is required to ensure the beacon generation is not done
181 as a part of join request for a BT-AMP station */
182
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800183 if (pe_session->statypeForBss == STA_ENTRY_SELF) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700184 pe_debug("Initializing BT-AMP beacon generation");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800185 sch_set_beacon_interval(mac, pe_session);
186 sch_set_fixed_beacon_fields(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 }
188 }
189
Jeff Johnson348973e2018-11-22 16:51:12 -0800190 if (wlan_cfg_get_int(mac, WNI_CFG_SCAN_IN_POWERSAVE, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700191 QDF_STATUS_SUCCESS) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700192 pe_err("could not retrieve WNI_CFG_SCAN_IN_POWERSAVE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 return;
194 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195} /*** end lim_apply_configuration() ***/
196
197/**
198 * lim_update_config
199 *
200 * FUNCTION:
201 * Update the local state from CFG database
202 * (This used to be dphUpdateConfig)
203 *
204 * LOGIC:
205 *
206 * ASSUMPTIONS:
207 *
208 * NOTE:
209 *
210 * @param None
211 * @return None
212 */
213
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800214static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215{
216 uint32_t val;
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +0530217 bool enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800219 pe_session->beaconParams.fShortPreamble =
Jeff Johnson348973e2018-11-22 16:51:12 -0800220 mac->mlme_cfg->ht_caps.short_preamble;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221
222 /* In STA case this parameter is filled during the join request */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800223 if (LIM_IS_AP_ROLE(pe_session) ||
224 LIM_IS_IBSS_ROLE(pe_session)) {
Jeff Johnson348973e2018-11-22 16:51:12 -0800225 enabled = mac->mlme_cfg->wmm_params.wme_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800226 pe_session->limWmeEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 }
Jeff Johnson348973e2018-11-22 16:51:12 -0800228 enabled = mac->mlme_cfg->wmm_params.wsm_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800229 pe_session->limWsmEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800231 if ((!pe_session->limWmeEnabled) && (pe_session->limWsmEnabled)) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700232 pe_err("Can't enable WSM without WME");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800233 pe_session->limWsmEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 }
235 /* In STA , this parameter is filled during the join request */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800236 if (LIM_IS_AP_ROLE(pe_session) || LIM_IS_IBSS_ROLE(pe_session)) {
Jeff Johnson348973e2018-11-22 16:51:12 -0800237 enabled = mac->mlme_cfg->wmm_params.qos_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800238 pe_session->limQosEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800240 pe_session->limHcfEnabled = mac->mlme_cfg->feature_flags.enable_hcf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241
242 /* AP: WSM should enable HCF as well, for STA enable WSM only after */
243 /* association response is received */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800244 if (pe_session->limWsmEnabled && LIM_IS_AP_ROLE(pe_session))
245 pe_session->limHcfEnabled = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246
Jeff Johnson348973e2018-11-22 16:51:12 -0800247 if (wlan_cfg_get_int(mac, WNI_CFG_11D_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700248 pe_err("cfg get 11d enabled failed");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800249 pe_session->lim11dEnabled = (val) ? 1 : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700251 pe_debug("Updated Lim shadow state based on CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252}