blob: f98463ea6f77746027cbbed855af6d015dbcebad [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{
60 thermal_temp->thermal_temp_min_level0 =
61 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL0);
62 thermal_temp->thermal_temp_max_level0 =
63 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL0);
64 thermal_temp->thermal_temp_min_level1 =
65 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL1);
66 thermal_temp->thermal_temp_max_level1 =
67 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL1);
68 thermal_temp->thermal_temp_min_level2 =
69 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL2);
70 thermal_temp->thermal_temp_max_level2 =
71 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL2);
72 thermal_temp->thermal_temp_min_level3 =
73 cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL3);
74 thermal_temp->thermal_temp_max_level3 =
75 cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL3);
76}
77
Dundi Raviteja9ab4e7b2018-09-28 14:18:28 +053078/**
79 * fwol_parse_probe_req_ouis - form ouis from ini gProbeReqOUIs
80 * @psoc: Pointer to struct wlan_objmgr_psoc context
81 * @whitelist: Pointer to struct wlan_fwol_ie_whitelist
82 *
83 * This function parses the ini string gProbeReqOUIs which needs be to in the
84 * following format:
85 * "<8 characters of [0-9] or [A-F]>space<8 characters from [0-9] etc.,"
86 * example: "AABBCCDD 1122EEFF"
87 * and the logic counts the number of OUIS and allocates the memory
88 * for every valid OUI and is stored in struct hdd_context
89 *
90 * Return: None
91 */
92static void fwol_parse_probe_req_ouis(struct wlan_objmgr_psoc *psoc,
93 struct wlan_fwol_ie_whitelist *whitelist)
94{
95 uint8_t probe_req_ouis[MAX_PRB_REQ_VENDOR_OUI_INI_LEN] = {0};
96 uint32_t *voui = whitelist->probe_req_voui;
97 char *str;
98 uint8_t *token;
99 uint32_t oui_indx = 0;
100 int ret;
101 uint32_t hex_value;
102
103 qdf_str_lcopy(probe_req_ouis, cfg_get(psoc, CFG_PROBE_REQ_OUI),
104 MAX_PRB_REQ_VENDOR_OUI_INI_LEN);
105 str = probe_req_ouis;
106 whitelist->no_of_probe_req_ouis = 0;
107
108 if (!qdf_str_len(str)) {
109 fwol_info("NO OUIs to parse");
110 return;
111 }
112
113 token = strsep(&str, " ");
114 while (token) {
115 if (qdf_str_len(token) != 8)
116 goto next_token;
117
118 ret = qdf_kstrtouint(token, 16, &hex_value);
119 if (ret)
120 goto next_token;
121
122 voui[oui_indx++] = cpu_to_be32(hex_value);
123 if (oui_indx >= MAX_PROBE_REQ_OUIS)
124 break;
125next_token:
126 token = strsep(&str, " ");
127 }
128
129 if (!oui_indx) {
130 whitelist->ie_whitelist = false;
131 return;
132 }
133
134 whitelist->no_of_probe_req_ouis = oui_indx;
135}
136
137/**
138 * fwol_validate_ie_bitmaps() - Validate all IE whitelist bitmap param values
139 * @psoc: Pointer to struct wlan_objmgr_psoc
140 * @whitelist: Pointer to struct wlan_fwol_ie_whitelist
141 *
142 * Return: True if all bitmap values are valid, else false
143 */
144static bool fwol_validate_ie_bitmaps(struct wlan_objmgr_psoc *psoc,
145 struct wlan_fwol_ie_whitelist *whitelist)
146{
147 if (!(whitelist->ie_bitmap_0 && whitelist->ie_bitmap_1 &&
148 whitelist->ie_bitmap_2 && whitelist->ie_bitmap_3 &&
149 whitelist->ie_bitmap_4 && whitelist->ie_bitmap_5 &&
150 whitelist->ie_bitmap_6 && whitelist->ie_bitmap_7))
151 return false;
152
153 /*
154 * check whether vendor oui IE is set and OUIs are present, each OUI
155 * is entered in the form of string of 8 characters from ini, therefore,
156 * for atleast one OUI, minimum length is 8 and hence this string length
157 * is checked for minimum of 8
158 */
159 if ((whitelist->ie_bitmap_6 & VENDOR_SPECIFIC_IE_BITMAP) &&
160 (qdf_str_len(cfg_get(psoc, CFG_PROBE_REQ_OUI)) < 8))
161 return false;
162
163 /* check whether vendor oui IE is not set but OUIs are present */
164 if (!(whitelist->ie_bitmap_6 & VENDOR_SPECIFIC_IE_BITMAP) &&
165 (qdf_str_len(cfg_get(psoc, CFG_PROBE_REQ_OUI)) > 0))
166 return false;
167
168 return true;
169}
170
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530171static void
172fwol_init_ie_whiltelist_in_cfg(struct wlan_objmgr_psoc *psoc,
173 struct wlan_fwol_ie_whitelist *whitelist)
174{
175 whitelist->ie_whitelist = cfg_get(psoc, CFG_PROBE_REQ_IE_WHITELIST);
176 whitelist->ie_bitmap_0 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP0);
177 whitelist->ie_bitmap_1 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP1);
178 whitelist->ie_bitmap_2 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP2);
179 whitelist->ie_bitmap_3 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP3);
180 whitelist->ie_bitmap_4 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP4);
181 whitelist->ie_bitmap_5 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP5);
182 whitelist->ie_bitmap_6 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP6);
183 whitelist->ie_bitmap_7 = cfg_get(psoc, CFG_PROBE_REQ_IE_BIT_MAP7);
Dundi Raviteja9ab4e7b2018-09-28 14:18:28 +0530184 if (!fwol_validate_ie_bitmaps(psoc, whitelist))
185 whitelist->ie_whitelist = false;
186 fwol_parse_probe_req_ouis(psoc, whitelist);
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530187}
188
Sourav Mohapatra0f3b8572018-09-12 10:03:51 +0530189/**
190 * ucfg_fwol_fetch_dhcp_server_settings: Populate the enable_dhcp_server_offload
191 * and dhcp_max_num_clients from cfg
192 * @psoc: The global psoc handler
193 * @fwol_cfg: The cfg structure
194 *
195 * Return: none
196 */
197#ifdef DHCP_SERVER_OFFLOAD
198static void ucfg_fwol_fetch_dhcp_server_settings(struct wlan_objmgr_psoc *psoc,
199 struct wlan_fwol_cfg *fwol_cfg)
200{
201 fwol_cfg->enable_dhcp_server_offload =
202 cfg_get(psoc, CFG_DHCP_SERVER_OFFLOAD_SUPPORT);
203 fwol_cfg->dhcp_max_num_clients =
204 cfg_get(psoc, CFG_DHCP_SERVER_OFFLOAD_NUM_CLIENT);
205}
206#else
207static void ucfg_fwol_fetch_dhcp_server_settings(struct wlan_objmgr_psoc *psoc,
208 struct wlan_fwol_cfg *fwol_cfg)
209{
210}
211#endif
212
213/**
214 * ucfg_fwol_fetch_tsf_gpio_pin: Populate the tsf_gpio_pin from cfg
215 * @psoc: The global psoc handler
216 * @fwol_cfg: The cfg structure
217 *
218 * Return: none
219 */
220#ifdef WLAN_FEATURE_TSF
221static void ucfg_fwol_fetch_tsf_gpio_pin(struct wlan_objmgr_psoc *psoc,
222 struct wlan_fwol_cfg *fwol_cfg)
223{
224 fwol_cfg->tsf_gpio_pin = cfg_get(psoc, CFG_SET_TSF_GPIO_PIN);
225}
226#else
227static void ucfg_fwol_fetch_tsf_gpio_pin(struct wlan_objmgr_psoc *psoc,
228 struct wlan_fwol_cfg *fwol_cfg)
229{
230}
231#endif
232
233/**
234 * ucfg_fwol_fetch_ra_filter: Populate the RA filter enabled or not from cfg
235 * @psoc: The global psoc handler
236 * @fwol_cfg: The cfg structure
237 *
238 * Return: none
239 */
240#ifdef FEATURE_WLAN_RA_FILTERING
241static void ucfg_fwol_fetch_ra_filter(struct wlan_objmgr_psoc *psoc,
242 struct wlan_fwol_cfg *fwol_cfg)
243{
244 fwol_cfg->is_rate_limit_enabled = cfg_get(psoc, CFG_RA_FILTER_ENABLE);
245}
246#else
247static void ucfg_fwol_fetch_ra_filter(struct wlan_objmgr_psoc *psoc,
248 struct wlan_fwol_cfg *fwol_cfg)
249{
250}
251#endif
252
Sourav Mohapatra113685f2018-08-29 14:21:55 +0530253QDF_STATUS fwol_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc)
254{
255 QDF_STATUS status = QDF_STATUS_SUCCESS;
256 struct wlan_fwol_psoc_obj *fwol_obj;
257 struct wlan_fwol_cfg *fwol_cfg;
258
259 fwol_obj = fwol_get_psoc_obj(psoc);
260 if (!fwol_obj) {
261 fwol_err("Failed to get FWOL Obj");
262 return QDF_STATUS_E_FAILURE;
263 }
264
265 fwol_cfg = &fwol_obj->cfg;
Dundi Raviteja3b637092018-09-12 13:42:50 +0530266
Dundi Raviteja85a240a2018-09-10 15:03:07 +0530267 fwol_init_coex_config_in_cfg(psoc, &fwol_cfg->coex_config);
268 fwol_init_thermal_temp_in_cfg(psoc, &fwol_cfg->thermal_temp_cfg);
269 fwol_init_ie_whiltelist_in_cfg(psoc, &fwol_cfg->ie_whitelist_cfg);
Sourav Mohapatrad9387d82018-09-07 12:28:52 +0530270 fwol_cfg->ani_enabled = cfg_get(psoc, CFG_ENABLE_ANI);
271 fwol_cfg->enable_rts_sifsbursting =
272 cfg_get(psoc, CFG_SET_RTS_FOR_SIFS_BURSTING);
273 fwol_cfg->max_mpdus_inampdu = cfg_get(psoc, CFG_MAX_MPDUS_IN_AMPDU);
274 fwol_cfg->arp_ac_category = cfg_get(psoc, CFG_ARP_AC_CATEGORY);
275 fwol_cfg->enable_phy_reg_retention = cfg_get(psoc, CFG_ENABLE_PHY_REG);
276 fwol_cfg->upper_brssi_thresh = cfg_get(psoc, CFG_UPPER_BRSSI_THRESH);
277 fwol_cfg->lower_brssi_thresh = cfg_get(psoc, CFG_LOWER_BRSSI_THRESH);
278 fwol_cfg->enable_dtim_1chrx = cfg_get(psoc, CFG_DTIM_1CHRX_ENABLE);
279 fwol_cfg->alternative_chainmask_enabled =
280 cfg_get(psoc, CFG_ENABLE_COEX_ALT_CHAINMASK);
Sourav Mohapatra0f3b8572018-09-12 10:03:51 +0530281 fwol_cfg->smart_chainmask_enabled =
282 cfg_get(psoc, CFG_ENABLE_SMART_CHAINMASK);
283 fwol_cfg->get_rts_profile = cfg_get(psoc, CFG_ENABLE_FW_RTS_PROFILE);
284 fwol_cfg->enable_fw_log_level =
285 cfg_get(psoc, CFG_ENABLE_FW_DEBUG_LOG_LEVEL);
286 fwol_cfg->enable_fw_log_type = cfg_get(psoc, CFG_ENABLE_FW_LOG_TYPE);
287 ucfg_fwol_fetch_ra_filter(psoc, fwol_cfg);
288 ucfg_fwol_fetch_tsf_gpio_pin(psoc, fwol_cfg);
289 ucfg_fwol_fetch_dhcp_server_settings(psoc, fwol_cfg);
Sourav Mohapatra113685f2018-08-29 14:21:55 +0530290
291 return status;
292}
293
294QDF_STATUS fwol_cfg_on_psoc_disable(struct wlan_objmgr_psoc *psoc)
295{
296 /* Clear the CFG structure */
297 return QDF_STATUS_SUCCESS;
298}