blob: 83cb868cead63300c14c891a149ba848494a956c [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Harprit Chhabadadc5bc152018-12-21 15:37:46 -08002 * Copyright (c) 2012-2019 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033#include "lim_types.h"
34#include "lim_utils.h"
35#include "lim_prop_exts_utils.h"
36#include "sch_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038
Jeff Johnson9320c1e2018-12-02 13:09:20 -080039static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040
Jeff Johnson9320c1e2018-12-02 13:09:20 -080041void lim_set_cfg_protection(struct mac_context *mac, struct pe_session *pesessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042{
43 uint32_t val = 0;
Jeff Johnson348973e2018-11-22 16:51:12 -080044 struct wlan_mlme_cfg *mlme_cfg = mac->mlme_cfg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045
Jeff Johnson8e9530b2019-03-18 13:41:42 -070046 if (pesessionEntry && LIM_IS_AP_ROLE(pesessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047 if (pesessionEntry->gLimProtectionControl ==
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053048 MLME_FORCE_POLICY_PROTECTION_DISABLE)
hangtian127c9532019-01-12 13:29:07 +080049 qdf_mem_zero((void *)&pesessionEntry->cfgProtection,
50 sizeof(tCfgProtection));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051 else {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070052 pe_debug("frm11a = %d, from11b = %d, frm11g = %d, "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053 "ht20 = %d, nongf = %d, lsigTxop = %d, "
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -070054 "rifs = %d, obss = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055 pesessionEntry->cfgProtection.fromlla,
56 pesessionEntry->cfgProtection.fromllb,
57 pesessionEntry->cfgProtection.fromllg,
58 pesessionEntry->cfgProtection.ht20,
59 pesessionEntry->cfgProtection.nonGf,
60 pesessionEntry->cfgProtection.lsigTxop,
61 pesessionEntry->cfgProtection.rifs,
62 pesessionEntry->cfgProtection.obss);
63 }
64 } else {
Jeff Johnson348973e2018-11-22 16:51:12 -080065 mac->lim.gLimProtectionControl =
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053066 mlme_cfg->sap_protection_cfg.protection_force_policy;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
Jeff Johnson348973e2018-11-22 16:51:12 -080069 if (mac->lim.gLimProtectionControl ==
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053070 MLME_FORCE_POLICY_PROTECTION_DISABLE)
hangtian127c9532019-01-12 13:29:07 +080071 qdf_mem_zero((void *)&mac->lim.cfgProtection,
72 sizeof(tCfgProtection));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 else {
Pragaspathi Thilagarajf4cc58b2018-07-31 00:39:05 +053074 val = mlme_cfg->sap_protection_cfg.protection_enabled;
75
Jeff Johnson348973e2018-11-22 16:51:12 -080076 mac->lim.cfgProtection.fromlla =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053077 (val >> MLME_PROTECTION_ENABLED_FROM_llA) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080078 mac->lim.cfgProtection.fromllb =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053079 (val >> MLME_PROTECTION_ENABLED_FROM_llB) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080080 mac->lim.cfgProtection.fromllg =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053081 (val >> MLME_PROTECTION_ENABLED_FROM_llG) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080082 mac->lim.cfgProtection.ht20 =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053083 (val >> MLME_PROTECTION_ENABLED_HT_20) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080084 mac->lim.cfgProtection.nonGf =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053085 (val >> MLME_PROTECTION_ENABLED_NON_GF) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080086 mac->lim.cfgProtection.lsigTxop =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053087 (val >> MLME_PROTECTION_ENABLED_LSIG_TXOP) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080088 mac->lim.cfgProtection.rifs =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053089 (val >> MLME_PROTECTION_ENABLED_RIFS) & 1;
Jeff Johnson348973e2018-11-22 16:51:12 -080090 mac->lim.cfgProtection.obss =
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +053091 (val >> MLME_PROTECTION_ENABLED_OBSS) & 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092
93 }
94 }
95}
96
97/**
98 * lim_handle_param_update()
99 *
100 ***FUNCTION:
101 * This function is use to post a message whenever need indicate
102 * there is update of config parameter.
103 *
104 ***PARAMS:
105 *
106 ***LOGIC:
107 *
108 ***ASSUMPTIONS:
109 * NA
110 *
111 ***NOTE:
112 *
Jeff Johnson348973e2018-11-22 16:51:12 -0800113 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 * @param cfgId - ID of CFG parameter that got updated
115 * @return None
116 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800117void lim_handle_param_update(struct mac_context *mac, eUpdateIEsType cfgId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800119 struct scheduler_msg msg = { 0 };
Jeff Johnsonc9f44622018-06-29 14:18:53 -0700120 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700122 pe_debug("Handling CFG parameter id %X update", cfgId);
123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124 switch (cfgId) {
125 case eUPDATE_IE_PROBE_BCN:
126 {
127 msg.type = SIR_LIM_UPDATE_BEACON;
Jeff Johnson348973e2018-11-22 16:51:12 -0800128 status = lim_post_msg_api(mac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129
Jeff Johnsonc9f44622018-06-29 14:18:53 -0700130 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700131 pe_err("Failed lim_post_msg_api %u", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 break;
133 }
134 default:
135 break;
136 }
137}
138
139/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 * lim_apply_configuration()
141 *
142 ***FUNCTION:
143 * This function is called to apply the configured parameters
144 * before joining or reassociating with a BSS or starting a BSS.
145 *
146 ***PARAMS:
147 *
148 ***LOGIC:
149 *
150 ***ASSUMPTIONS:
151 * NA
152 *
153 ***NOTE:
154 *
Jeff Johnson348973e2018-11-22 16:51:12 -0800155 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 * @return None
157 */
158
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800159void lim_apply_configuration(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160{
Harprit Chhabadadc5bc152018-12-21 15:37:46 -0800161 uint32_t phyMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700163 pe_debug("Applying config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800165 pe_session->limSentCapsChangeNtf = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800167 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800169 lim_update_config(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800171 lim_get_short_slot_from_phy_mode(mac, pe_session, phyMode,
172 &pe_session->shortSlotTimeSupported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800174 lim_set_cfg_protection(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175
176 /* Added for BT - AMP Support */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800177 if (LIM_IS_AP_ROLE(pe_session) ||
178 LIM_IS_IBSS_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 /* This check is required to ensure the beacon generation is not done
180 as a part of join request for a BT-AMP station */
181
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800182 if (pe_session->statypeForBss == STA_ENTRY_SELF) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700183 pe_debug("Initializing BT-AMP beacon generation");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800184 sch_set_beacon_interval(mac, pe_session);
185 sch_set_fixed_beacon_fields(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 }
187 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188} /*** end lim_apply_configuration() ***/
189
190/**
191 * lim_update_config
192 *
193 * FUNCTION:
194 * Update the local state from CFG database
195 * (This used to be dphUpdateConfig)
196 *
197 * LOGIC:
198 *
199 * ASSUMPTIONS:
200 *
201 * NOTE:
202 *
203 * @param None
204 * @return None
205 */
206
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800207static void lim_update_config(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208{
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +0530209 bool enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800211 pe_session->beaconParams.fShortPreamble =
Jeff Johnson348973e2018-11-22 16:51:12 -0800212 mac->mlme_cfg->ht_caps.short_preamble;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213
214 /* In STA case this parameter is filled during the join request */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800215 if (LIM_IS_AP_ROLE(pe_session) ||
216 LIM_IS_IBSS_ROLE(pe_session)) {
Jeff Johnson348973e2018-11-22 16:51:12 -0800217 enabled = mac->mlme_cfg->wmm_params.wme_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800218 pe_session->limWmeEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 }
Jeff Johnson348973e2018-11-22 16:51:12 -0800220 enabled = mac->mlme_cfg->wmm_params.wsm_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800221 pe_session->limWsmEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800223 if ((!pe_session->limWmeEnabled) && (pe_session->limWsmEnabled)) {
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700224 pe_err("Can't enable WSM without WME");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800225 pe_session->limWsmEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 }
227 /* In STA , this parameter is filled during the join request */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800228 if (LIM_IS_AP_ROLE(pe_session) || LIM_IS_IBSS_ROLE(pe_session)) {
Jeff Johnson348973e2018-11-22 16:51:12 -0800229 enabled = mac->mlme_cfg->wmm_params.qos_enabled;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800230 pe_session->limQosEnabled = enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800232 pe_session->limHcfEnabled = mac->mlme_cfg->feature_flags.enable_hcf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
234 /* AP: WSM should enable HCF as well, for STA enable WSM only after */
235 /* association response is received */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800236 if (pe_session->limWsmEnabled && LIM_IS_AP_ROLE(pe_session))
237 pe_session->limHcfEnabled = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238
Abhinav Kumard4d6eb72018-12-04 20:30:37 +0530239 pe_session->lim11dEnabled = mac->mlme_cfg->gen.enabled_11d ? 1 : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240
Srinivas Girigowdad0a72f92017-03-26 15:41:14 -0700241 pe_debug("Updated Lim shadow state based on CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242}