blob: be177cf77c16252fea9711a2bc744381d8d66b2a [file] [log] [blame]
Sourav Mohapatra113685f2018-08-29 14:21:55 +05301/*
2 * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3 *
4 * 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 * DOC: define internal APIs related to the fwol component
20 */
21
22#include "wlan_fw_offload_main.h"
Sourav Mohapatra113685f2018-08-29 14:21:55 +053023
24struct wlan_fwol_psoc_obj *fwol_get_psoc_obj(struct wlan_objmgr_psoc *psoc)
25{
26 return wlan_objmgr_psoc_get_comp_private_obj(psoc,
27 WLAN_UMAC_COMP_FWOL);
28}
29
Dundi Raviteja3b637092018-09-12 13:42:50 +053030static void
Dundi Raviteja85a240a2018-09-10 15:03:07 +053031fwol_init_coex_config_in_cfg(struct wlan_objmgr_psoc *psoc,
32 struct wlan_fwol_coex_config *coex_config)
Dundi Raviteja3b637092018-09-12 13:42:50 +053033{
34 coex_config->btc_mode = cfg_get(psoc, CFG_BTC_MODE);
35 coex_config->antenna_isolation = cfg_get(psoc, CFG_ANTENNA_ISOLATION);
36 coex_config->max_tx_power_for_btc =
37 cfg_get(psoc, CFG_MAX_TX_POWER_FOR_BTC);
38 coex_config->wlan_low_rssi_threshold =
39 cfg_get(psoc, CFG_WLAN_LOW_RSSI_THRESHOLD);
40 coex_config->bt_low_rssi_threshold =
41 cfg_get(psoc, CFG_BT_LOW_RSSI_THRESHOLD);
42 coex_config->bt_interference_low_ll =
43 cfg_get(psoc, CFG_BT_INTERFERENCE_LOW_LL);
44 coex_config->bt_interference_low_ul =
45 cfg_get(psoc, CFG_BT_INTERFERENCE_LOW_UL);
46 coex_config->bt_interference_medium_ll =
47 cfg_get(psoc, CFG_BT_INTERFERENCE_MEDIUM_LL);
48 coex_config->bt_interference_medium_ul =
49 cfg_get(psoc, CFG_BT_INTERFERENCE_MEDIUM_UL);
50 coex_config->bt_interference_high_ll =
51 cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_LL);
52 coex_config->bt_interference_high_ul =
53 cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_UL);
54}
55
Dundi Raviteja47ac7092018-09-07 10:40:28 +053056static void
Dundi Raviteja85a240a2018-09-10 15:03:07 +053057fwol_init_thermal_temp_in_cfg(struct wlan_objmgr_psoc *psoc,
58 struct wlan_fwol_thermal_temp *thermal_temp)
Dundi Raviteja47ac7092018-09-07 10:40:28 +053059{
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080060 thermal_temp->thermal_temp_min_level[0] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053061 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL0);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080062 thermal_temp->thermal_temp_max_level[0] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053063 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL0);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080064 thermal_temp->thermal_temp_min_level[1] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053065 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL1);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080066 thermal_temp->thermal_temp_max_level[1] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053067 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL1);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080068 thermal_temp->thermal_temp_min_level[2] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053069 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL2);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080070 thermal_temp->thermal_temp_max_level[2] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053071 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL2);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080072 thermal_temp->thermal_temp_min_level[3] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053073 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL3);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080074 thermal_temp->thermal_temp_max_level[3] =
Dundi Raviteja47ac7092018-09-07 10:40:28 +053075 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL3);
Manikandan Mohan9045e2e2018-11-26 16:44:19 -080076
77 thermal_temp->thermal_mitigation_enable =
78 cfg_get(psoc, CFG_THERMAL_MITIGATION_ENABLE);
79 thermal_temp->throttle_period = cfg_get(psoc, CFG_THROTTLE_PERIOD);
80 thermal_temp->throttle_dutycycle_level[0] =
81 cfg_get(psoc, CFG_THROTTLE_DUTY_CYCLE_LEVEL0);
82 thermal_temp->throttle_dutycycle_level[1]=
83 cfg_get(psoc, CFG_THROTTLE_DUTY_CYCLE_LEVEL1);
84 thermal_temp->throttle_dutycycle_level[2]=
85 cfg_get(psoc, CFG_THROTTLE_DUTY_CYCLE_LEVEL2);
86 thermal_temp->throttle_dutycycle_level[3]=
87 cfg_get(psoc, CFG_THROTTLE_DUTY_CYCLE_LEVEL3);
Dundi Raviteja47ac7092018-09-07 10:40:28 +053088}
89
Dundi Raviteja9ab4e7b2018-09-28 14:18:28 +053090/**
91 * fwol_parse_probe_req_ouis - form ouis from ini gProbeReqOUIs
92 * @psoc: Pointer to struct wlan_objmgr_psoc context
93 * @whitelist: Pointer to struct wlan_fwol_ie_whitelist
94 *
95 * This function parses the ini string gProbeReqOUIs which needs be to in the
96 * following format:
97 * "<8 characters of [0-9] or [A-F]>space<8 characters from [0-9] etc.,"
98 * example: "AABBCCDD 1122EEFF"
99 * and the logic counts the number of OUIS and allocates the memory
100 * for every valid OUI and is stored in struct hdd_context
101 *
102 * Return: None
103 */
104static void fwol_parse_probe_req_ouis(struct wlan_objmgr_psoc *psoc,
105 struct wlan_fwol_ie_whitelist *whitelist)
106{
107 uint8_t probe_req_ouis[MAX_PRB_REQ_VENDOR_OUI_INI_LEN] = {0};
108 uint32_t *voui = whitelist->probe_req_voui;
109 char *str;
110 uint8_t *token;
111 uint32_t oui_indx = 0;
112 int ret;
113 uint32_t hex_value;
114
115 qdf_str_lcopy(probe_req_ouis, cfg_get(psoc, CFG_PROBE_REQ_OUI),
116 MAX_PRB_REQ_VENDOR_OUI_INI_LEN);
117 str = probe_req_ouis;
118 whitelist->no_of_probe_req_ouis = 0;
119
120 if (!qdf_str_len(str)) {
121 fwol_info("NO OUIs to parse");
122 return;
123 }
124
125 token = strsep(&str, " ");
126 while (token) {
127 if (qdf_str_len(token) != 8)
128 goto next_token;
129
130 ret = qdf_kstrtouint(token, 16, &hex_value);
131 if (ret)
132 goto next_token;
133
134 voui[oui_indx++] = cpu_to_be32(hex_value);
135 if (oui_indx >= MAX_PROBE_REQ_OUIS)
136 break;
137next_token:
138 token = strsep(&str, " ");
139 }
140
141 if (!oui_indx) {
142 whitelist->ie_whitelist = false;
143 return;
144 }
145
146 whitelist->no_of_probe_req_ouis = oui_indx;
147}
148
149/**
150 * fwol_validate_ie_bitmaps() - Validate all IE whitelist bitmap param values
151 * @psoc: Pointer to struct wlan_objmgr_psoc
152 * @whitelist: Pointer to struct wlan_fwol_ie_whitelist
153 *
154 * Return: True if all bitmap values are valid, else false
155 */
156static bool fwol_validate_ie_bitmaps(struct wlan_objmgr_psoc *psoc,
157 struct wlan_fwol_ie_whitelist *whitelist)
158{
159 if (!(whitelist->ie_bitmap_0 && whitelist->ie_bitmap_1 &&
160 whitelist->ie_bitmap_2 && whitelist->ie_bitmap_3 &&
161 whitelist->ie_bitmap_4 && whitelist->ie_bitmap_5 &&
162 whitelist->ie_bitmap_6 && whitelist->ie_bitmap_7))
163 return false;
164
165 /*
166 * check whether vendor oui IE is set and OUIs are present, each OUI
167 * is entered in the form of string of 8 characters from ini, therefore,
168 * for atleast one OUI, minimum length is 8 and hence this string length
169 * is checked for minimum of 8
170 */
171 if ((whitelist->ie_bitmap_6 & VENDOR_SPECIFIC_IE_BITMAP) &&
172 (qdf_str_len(cfg_get(psoc, CFG_PROBE_REQ_OUI)) < 8))
173 return false;
174
175 /* check whether vendor oui IE is not set but OUIs are present */
176 if (!(whitelist->ie_bitmap_6 & VENDOR_SPECIFIC_IE_BITMAP) &&
177 (qdf_str_len(cfg_get(psoc, CFG_PROBE_REQ_OUI)) > 0))
178 return false;
179
180 return true;
181}
182
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530183static void
184fwol_init_ie_whiltelist_in_cfg(struct wlan_objmgr_psoc *psoc,
185 struct wlan_fwol_ie_whitelist *whitelist)
186{
187 whitelist->ie_whitelist = cfg_get(psoc, CFG_PROBE_REQ_IE_WHITELIST);
188 whitelist->ie_bitmap_0 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP0);
189 whitelist->ie_bitmap_1 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP1);
190 whitelist->ie_bitmap_2 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP2);
191 whitelist->ie_bitmap_3 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP3);
192 whitelist->ie_bitmap_4 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP4);
193 whitelist->ie_bitmap_5 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP5);
194 whitelist->ie_bitmap_6 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP6);
195 whitelist->ie_bitmap_7 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP7);
Dundi Raviteja9ab4e7b2018-09-28 14:18:28 +0530196 if (!fwol_validate_ie_bitmaps(psoc, whitelist))
197 whitelist->ie_whitelist = false;
198 fwol_parse_probe_req_ouis(psoc, whitelist);
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530199}
200
Sourav Mohapatra0f3b8572018-09-12 10:03:51 +0530201/**
202 * ucfg_fwol_fetch_dhcp_server_settings: Populate the enable_dhcp_server_offload
203 * and dhcp_max_num_clients from cfg
204 * @psoc: The global psoc handler
205 * @fwol_cfg: The cfg structure
206 *
207 * Return: none
208 */
209#ifdef DHCP_SERVER_OFFLOAD
210static void ucfg_fwol_fetch_dhcp_server_settings(struct wlan_objmgr_psoc *psoc,
211 struct wlan_fwol_cfg *fwol_cfg)
212{
213 fwol_cfg->enable_dhcp_server_offload =
214 cfg_get(psoc, CFG_DHCP_SERVER_OFFLOAD_SUPPORT);
215 fwol_cfg->dhcp_max_num_clients =
216 cfg_get(psoc, CFG_DHCP_SERVER_OFFLOAD_NUM_CLIENT);
217}
218#else
219static void ucfg_fwol_fetch_dhcp_server_settings(struct wlan_objmgr_psoc *psoc,
220 struct wlan_fwol_cfg *fwol_cfg)
221{
222}
223#endif
224
225/**
226 * ucfg_fwol_fetch_tsf_gpio_pin: Populate the tsf_gpio_pin from cfg
227 * @psoc: The global psoc handler
228 * @fwol_cfg: The cfg structure
229 *
230 * Return: none
231 */
232#ifdef WLAN_FEATURE_TSF
233static void ucfg_fwol_fetch_tsf_gpio_pin(struct wlan_objmgr_psoc *psoc,
234 struct wlan_fwol_cfg *fwol_cfg)
235{
236 fwol_cfg->tsf_gpio_pin = cfg_get(psoc, CFG_SET_TSF_GPIO_PIN);
237}
238#else
239static void ucfg_fwol_fetch_tsf_gpio_pin(struct wlan_objmgr_psoc *psoc,
240 struct wlan_fwol_cfg *fwol_cfg)
241{
242}
243#endif
244
245/**
246 * ucfg_fwol_fetch_ra_filter: Populate the RA filter enabled or not from cfg
247 * @psoc: The global psoc handler
248 * @fwol_cfg: The cfg structure
249 *
250 * Return: none
251 */
252#ifdef FEATURE_WLAN_RA_FILTERING
253static void ucfg_fwol_fetch_ra_filter(struct wlan_objmgr_psoc *psoc,
254 struct wlan_fwol_cfg *fwol_cfg)
255{
256 fwol_cfg->is_rate_limit_enabled = cfg_get(psoc, CFG_RA_FILTER_ENABLE);
257}
258#else
259static void ucfg_fwol_fetch_ra_filter(struct wlan_objmgr_psoc *psoc,
260 struct wlan_fwol_cfg *fwol_cfg)
261{
262}
263#endif
264
Sourav Mohapatra113685f2018-08-29 14:21:55 +0530265QDF_STATUS fwol_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc)
266{
267 QDF_STATUS status = QDF_STATUS_SUCCESS;
268 struct wlan_fwol_psoc_obj *fwol_obj;
269 struct wlan_fwol_cfg *fwol_cfg;
270
271 fwol_obj = fwol_get_psoc_obj(psoc);
272 if (!fwol_obj) {
273 fwol_err("Failed to get FWOL Obj");
274 return QDF_STATUS_E_FAILURE;
275 }
276
277 fwol_cfg = &fwol_obj->cfg;
Dundi Raviteja3b637092018-09-12 13:42:50 +0530278
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530279 fwol_init_coex_config_in_cfg(psoc, &fwol_cfg->coex_config);
280 fwol_init_thermal_temp_in_cfg(psoc, &fwol_cfg->thermal_temp_cfg);
281 fwol_init_ie_whiltelist_in_cfg(psoc, &fwol_cfg->ie_whitelist_cfg);
Sourav Mohapatrad9387d82018-09-07 12:28:52 +0530282 fwol_cfg->ani_enabled = cfg_get(psoc, CFG_ENABLE_ANI);
283 fwol_cfg->enable_rts_sifsbursting =
284 cfg_get(psoc, CFG_SET_RTS_FOR_SIFS_BURSTING);
285 fwol_cfg->max_mpdus_inampdu = cfg_get(psoc, CFG_MAX_MPDUS_IN_AMPDU);
286 fwol_cfg->arp_ac_category = cfg_get(psoc, CFG_ARP_AC_CATEGORY);
287 fwol_cfg->enable_phy_reg_retention = cfg_get(psoc, CFG_ENABLE_PHY_REG);
288 fwol_cfg->upper_brssi_thresh = cfg_get(psoc, CFG_UPPER_BRSSI_THRESH);
289 fwol_cfg->lower_brssi_thresh = cfg_get(psoc, CFG_LOWER_BRSSI_THRESH);
290 fwol_cfg->enable_dtim_1chrx = cfg_get(psoc, CFG_DTIM_1CHRX_ENABLE);
291 fwol_cfg->alternative_chainmask_enabled =
292 cfg_get(psoc, CFG_ENABLE_COEX_ALT_CHAINMASK);
Sourav Mohapatra0f3b8572018-09-12 10:03:51 +0530293 fwol_cfg->smart_chainmask_enabled =
294 cfg_get(psoc, CFG_ENABLE_SMART_CHAINMASK);
295 fwol_cfg->get_rts_profile = cfg_get(psoc, CFG_ENABLE_FW_RTS_PROFILE);
296 fwol_cfg->enable_fw_log_level =
297 cfg_get(psoc, CFG_ENABLE_FW_DEBUG_LOG_LEVEL);
298 fwol_cfg->enable_fw_log_type = cfg_get(psoc, CFG_ENABLE_FW_LOG_TYPE);
299 ucfg_fwol_fetch_ra_filter(psoc, fwol_cfg);
300 ucfg_fwol_fetch_tsf_gpio_pin(psoc, fwol_cfg);
301 ucfg_fwol_fetch_dhcp_server_settings(psoc, fwol_cfg);
Sourav Mohapatra113685f2018-08-29 14:21:55 +0530302
303 return status;
304}
305
306QDF_STATUS fwol_cfg_on_psoc_disable(struct wlan_objmgr_psoc *psoc)
307{
308 /* Clear the CFG structure */
309 return QDF_STATUS_SUCCESS;
310}