1 /*
2 * Copyright (c) 2012 - 2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19 /**
20 * DOC: declare utility API related to the fw_offload component
21 * called by other components
22 */
23
24 #ifndef _WLAN_FW_OFFLOAD_MAIN_H_
25 #define _WLAN_FW_OFFLOAD_MAIN_H_
26
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_global_obj.h>
29 #include <wlan_cmn.h>
30 #include <scheduler_api.h>
31
32 #include "cfg_ucfg_api.h"
33 #include "wlan_fwol_public_structs.h"
34
35 #define fwol_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_FWOL, params)
36 #define fwol_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_FWOL, params)
37 #define fwol_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_FWOL, params)
38 #define fwol_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_FWOL, params)
39 #define fwol_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_FWOL, params)
40
41 #define fwol_nofl_alert(params...) \
42 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_FWOL, params)
43 #define fwol_nofl_err(params...) \
44 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_FWOL, params)
45 #define fwol_nofl_warn(params...) \
46 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_FWOL, params)
47 #define fwol_nofl_info(params...) \
48 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_FWOL, params)
49 #define fwol_nofl_debug(params...) \
50 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_FWOL, params)
51
52 /**
53 * enum wlan_fwol_southbound_event - fw offload south bound event type
54 * @WLAN_FWOL_EVT_INVALID: invalid/unknown value
55 * @WLAN_FWOL_EVT_GET_ELNA_BYPASS_RESPONSE: get eLNA bypass response
56 * @WLAN_FWOL_EVT_GET_THERMAL_STATS_RESPONSE: get Thermal Stats response
57 * @WLAN_FWOL_EVT_LAST: internal use
58 * @WLAN_FWOL_EVT_MAX: value of last valid enumerator
59 */
60 enum wlan_fwol_southbound_event {
61 WLAN_FWOL_EVT_INVALID = 0,
62 WLAN_FWOL_EVT_GET_ELNA_BYPASS_RESPONSE,
63 WLAN_FWOL_EVT_GET_THERMAL_STATS_RESPONSE,
64 WLAN_FWOL_EVT_LAST,
65 WLAN_FWOL_EVT_MAX = WLAN_FWOL_EVT_LAST - 1
66 };
67
68 /**
69 * struct wlan_fwol_coex_config - BTC config items
70 * @btc_mode: Config BTC mode
71 * @antenna_isolation: Antenna isolation
72 * @max_tx_power_for_btc: Max wlan tx power in co-ex scenario
73 * @wlan_low_rssi_threshold: Wlan low rssi threshold for BTC mode switching
74 * @bt_low_rssi_threshold: BT low rssi threshold for BTC mode switching
75 * @bt_interference_low_ll: Lower limit of low level BT interference
76 * @bt_interference_low_ul: Upper limit of low level BT interference
77 * @bt_interference_medium_ll: Lower limit of medium level BT interference
78 * @bt_interference_medium_ul: Upper limit of medium level BT interference
79 * @bt_interference_high_ll: Lower limit of high level BT interference
80 * @bt_interference_high_ul: Upper limit of high level BT interference
81 * @btc_mpta_helper_enable: Enable/Disable tri-radio MPTA helper
82 * @bt_sco_allow_wlan_2g_scan: Enable/Disable wlan 2g scan when
83 * BT SCO connection is on
84 * @btc_three_way_coex_config_legacy_enable: Enable/Disable tri-radio coex
85 * config legacy feature
86 * @ble_scan_coex_policy: BLE Scan policy, true - better BLE scan result, false
87 * better wlan throughput
88 * @coex_tput_shaping_enable: wifi traffic shaping enable, true - enable,
89 * false - disable
90 */
91 struct wlan_fwol_coex_config {
92 uint8_t btc_mode;
93 uint8_t antenna_isolation;
94 uint8_t max_tx_power_for_btc;
95 int16_t wlan_low_rssi_threshold;
96 int16_t bt_low_rssi_threshold;
97 int16_t bt_interference_low_ll;
98 int16_t bt_interference_low_ul;
99 int16_t bt_interference_medium_ll;
100 int16_t bt_interference_medium_ul;
101 int16_t bt_interference_high_ll;
102 int16_t bt_interference_high_ul;
103 #ifdef FEATURE_MPTA_HELPER
104 bool btc_mpta_helper_enable;
105 #endif
106 bool bt_sco_allow_wlan_2g_scan;
107 #ifdef FEATURE_COEX_CONFIG
108 bool btc_three_way_coex_config_legacy_enable;
109 #endif
110 bool ble_scan_coex_policy;
111 #ifdef FEATURE_COEX_TPUT_SHAPING_CONFIG
112 bool coex_tput_shaping_enable;
113 #endif
114 };
115
116 #define FWOL_THERMAL_LEVEL_MAX 6
117 #define FWOL_THERMAL_THROTTLE_LEVEL_MAX 6
118 /**
119 * struct wlan_fwol_thermal_temp - Thermal temperature config items
120 * @thermal_temp_min_level: Array of temperature minimum levels
121 * @thermal_temp_max_level: Array of temperature maximum levels
122 * @thermal_mitigation_enable: Control for Thermal mitigation feature
123 * @throttle_period: Thermal throttle period value
124 * @throttle_dutycycle_level: Array of throttle duty cycle levels
125 * @thermal_sampling_time: sampling time for thermal mitigation in ms
126 * @mon_id: Monitor client id either the wpps or apps
127 * @priority_apps: Priority of the apps mitigation to consider by fw
128 * @priority_wpps: Priority of the wpps mitigation to consider by fw
129 * @thermal_action: thermal action as defined enum thermal_mgmt_action_code
130 * @therm_stats_offset: thermal temp offset as set in gThermalStatsTempOffset
131 */
132 struct wlan_fwol_thermal_temp {
133 bool thermal_mitigation_enable;
134 uint32_t throttle_period;
135 uint16_t thermal_temp_min_level[FWOL_THERMAL_LEVEL_MAX];
136 uint16_t thermal_temp_max_level[FWOL_THERMAL_LEVEL_MAX];
137 uint32_t throttle_dutycycle_level[FWOL_THERMAL_THROTTLE_LEVEL_MAX];
138 uint16_t thermal_sampling_time;
139 uint8_t mon_id;
140 uint8_t priority_apps;
141 uint8_t priority_wpps;
142 enum thermal_mgmt_action_code thermal_action;
143 #ifdef THERMAL_STATS_SUPPORT
144 uint8_t therm_stats_offset;
145 #endif
146 };
147
148 /**
149 * struct wlan_fwol_ie_allowlist - Probe request IE allowlist config items
150 * @ie_allowlist: IE allowlist flag
151 * @ie_bitmap_0: IE bitmap 0
152 * @ie_bitmap_1: IE bitmap 1
153 * @ie_bitmap_2: IE bitmap 2
154 * @ie_bitmap_3: IE bitmap 3
155 * @ie_bitmap_4: IE bitmap 4
156 * @ie_bitmap_5: IE bitmap 5
157 * @ie_bitmap_6: IE bitmap 6
158 * @ie_bitmap_7: IE bitmap 7
159 * @no_of_probe_req_ouis: Total number of ouis present in probe req
160 * @probe_req_voui: Stores oui values after parsing probe req ouis
161 */
162 struct wlan_fwol_ie_allowlist {
163 bool ie_allowlist;
164 uint32_t ie_bitmap_0;
165 uint32_t ie_bitmap_1;
166 uint32_t ie_bitmap_2;
167 uint32_t ie_bitmap_3;
168 uint32_t ie_bitmap_4;
169 uint32_t ie_bitmap_5;
170 uint32_t ie_bitmap_6;
171 uint32_t ie_bitmap_7;
172 uint32_t no_of_probe_req_ouis;
173 uint32_t probe_req_voui[MAX_PROBE_REQ_OUIS];
174 };
175
176 /**
177 * struct wlan_fwol_neighbor_report_cfg - Neighbor report config params
178 * @enable_bitmask: Neighbor report offload bitmask control
179 * @params_bitmask: Param validity bitmask
180 * @time_offset: Neighbor report frame time offset
181 * @low_rssi_offset: Low RSSI offset
182 * @bmiss_count_trigger: Beacon miss trigger count
183 * @per_threshold_offset: PER Threshold offset
184 * @cache_timeout: Cache timeout
185 * @max_req_cap: Max request per peer
186 */
187 struct wlan_fwol_neighbor_report_cfg {
188 uint32_t enable_bitmask;
189 uint32_t params_bitmask;
190 uint32_t time_offset;
191 uint32_t low_rssi_offset;
192 uint32_t bmiss_count_trigger;
193 uint32_t per_threshold_offset;
194 uint32_t cache_timeout;
195 uint32_t max_req_cap;
196 };
197
198 #ifdef WLAN_FEATURE_TSF_ACCURACY
199 /**
200 * struct wlan_fwol_tsf_accuracy_configs - TSF Accuracy feature config params
201 * @enable: Flag to Enable/Disable TSF Accuracy Feature
202 * @sync_gpio: GPIO to indicate TSF sync is done. The GPIO pin is toggled at
203 * every TSF sync done.
204 * @periodic_pulse_gpio: GPIO to indicate TSF time completes a cycle of given
205 * interval. The GPIO pin gets pulse of 1msec for every
206 * TSF cycle complete.
207 * @pulse_interval_ms: Periodicy of TSF pulse in milli seconds.
208 */
209 struct wlan_fwol_tsf_accuracy_configs {
210 bool enable;
211 uint32_t sync_gpio;
212 uint32_t periodic_pulse_gpio;
213 uint32_t pulse_interval_ms;
214 };
215 #endif
216
217 /**
218 * struct wlan_fwol_cfg - fwol config items
219 * @coex_config: coex config items
220 * @thermal_temp_cfg: Thermal temperature related config items
221 * @ie_allowlist_cfg: IE Allowlist related config items
222 * @neighbor_report_cfg: 11K neighbor report config
223 * @ani_enabled: ANI enable/disable
224 * @pcie_config: to control pcie gen and lane params
225 * @enable_rts_sifsbursting: Enable RTS SIFS Bursting
226 * @enable_sifs_burst: Enable SIFS burst
227 * @max_mpdus_inampdu: Max number of MPDUS
228 * @enable_phy_reg_retention: Enable PHY reg retention
229 * @upper_brssi_thresh: Upper BRSSI threshold
230 * @lower_brssi_thresh: Lower BRSSI threshold
231 * @enable_dtim_1chrx: Enable/disable DTIM 1 CHRX
232 * @alternative_chainmask_enabled: Alternate chainmask
233 * @smart_chainmask_enabled: Enable/disable chainmask
234 * @get_rts_profile: Set the RTS profile
235 * @enable_fw_log_level: Set the FW log level
236 * @enable_fw_log_type: Set the FW log type
237 * @enable_fw_module_log_level: enable fw module log level
238 * @enable_fw_module_log_level_num: enable fw module log level num
239 * @enable_fw_mod_wow_log_level: enable fw wow module log level
240 * @enable_fw_mod_wow_log_level_num: enable fw wow module log level num
241 * @sap_xlna_bypass: bypass SAP xLNA
242 * @is_rate_limit_enabled: Enable/disable RA rate limited
243 * @tsf_gpio_pin: TSF GPIO Pin config
244 * @tsf_irq_host_gpio_pin: TSF GPIO Pin config
245 * @tsf_sync_host_gpio_pin: TSF Sync GPIO Pin config
246 * @tsf_ptp_options: TSF Plus feature options config
247 * @tsf_sync_enable: TSF sync feature enable/disable
248 * @tsf_accuracy_configs: TSF Accuracy feature config parameters
249 * @sae_enable: SAE feature enable config
250 * @gcmp_enable: GCMP feature enable config
251 * @enable_tx_sch_delay: Enable TX SCH delay value config
252 * @enable_secondary_rate: Enable secondary retry rate config
253 * @enable_dhcp_server_offload: DHCP Offload is enabled or not
254 * @dhcp_max_num_clients: Max number of DHCP client supported
255 * @dwelltime_params: adaptive dwell time parameters
256 * @enable_ilp: ILP HW block configuration
257 * @sap_sho: SAP SHO HW offload configuration
258 * @disable_hw_assist: Flag to configure HW assist feature in FW
259 * @enable_ofdm_scrambler_seed: Decide to enable/disable OFDM scrambler seed
260 */
261 struct wlan_fwol_cfg {
262 /* Add CFG and INI items here */
263 struct wlan_fwol_coex_config coex_config;
264 struct wlan_fwol_thermal_temp thermal_temp_cfg;
265 struct wlan_fwol_ie_allowlist ie_allowlist_cfg;
266 struct wlan_fwol_neighbor_report_cfg neighbor_report_cfg;
267 bool ani_enabled;
268 uint8_t pcie_config;
269 bool enable_rts_sifsbursting;
270 uint8_t enable_sifs_burst;
271 uint8_t max_mpdus_inampdu;
272 uint8_t enable_phy_reg_retention;
273 uint16_t upper_brssi_thresh;
274 uint16_t lower_brssi_thresh;
275 bool enable_dtim_1chrx;
276 bool alternative_chainmask_enabled;
277 bool smart_chainmask_enabled;
278 uint16_t get_rts_profile;
279 uint16_t enable_fw_log_level;
280 uint16_t enable_fw_log_type;
281 uint8_t enable_fw_module_log_level[FW_MODULE_LOG_LEVEL_STRING_LENGTH];
282 uint8_t enable_fw_module_log_level_num;
283 uint8_t enable_fw_mod_wow_log_level[FW_MODULE_LOG_LEVEL_STRING_LENGTH];
284 uint8_t enable_fw_mod_wow_log_level_num;
285 bool sap_xlna_bypass;
286 #ifdef FEATURE_WLAN_RA_FILTERING
287 bool is_rate_limit_enabled;
288 #endif
289 #ifdef WLAN_FEATURE_TSF
290 uint32_t tsf_gpio_pin;
291 #ifdef WLAN_FEATURE_TSF_PLUS
292 uint32_t tsf_ptp_options;
293 bool tsf_sync_enable;
294 #ifdef WLAN_FEATURE_TSF_ACCURACY
295 struct wlan_fwol_tsf_accuracy_configs tsf_accuracy_configs;
296 #endif
297 #ifdef WLAN_FEATURE_TSF_PLUS_EXT_GPIO_IRQ
298 uint32_t tsf_irq_host_gpio_pin;
299 #endif
300 #ifdef WLAN_FEATURE_TSF_PLUS_EXT_GPIO_SYNC
301 uint32_t tsf_sync_host_gpio_pin;
302 #endif
303 #endif
304 #endif
305 #ifdef WLAN_FEATURE_SAE
306 bool sae_enable;
307 #endif
308 bool gcmp_enable;
309 uint8_t enable_tx_sch_delay;
310 uint32_t enable_secondary_rate;
311 #ifdef DHCP_SERVER_OFFLOAD
312 bool enable_dhcp_server_offload;
313 uint32_t dhcp_max_num_clients;
314 #endif
315 struct adaptive_dwelltime_params dwelltime_params;
316 uint32_t enable_ilp;
317 uint32_t sap_sho;
318 bool disable_hw_assist;
319 #ifdef WLAN_FEATURE_OFDM_SCRAMBLER_SEED
320 bool enable_ofdm_scrambler_seed;
321 #endif
322 };
323
324 /**
325 * struct wlan_fwol_thermal_throttle_info - FW offload thermal throttle info
326 * @level: thermal throttle level
327 * @pdev_id: pdev id
328 */
329 struct wlan_fwol_thermal_throttle_info {
330 enum thermal_throttle_level level;
331 uint32_t pdev_id;
332 };
333
334 /**
335 * struct wlan_fwol_capability_info - FW offload capability component
336 * @fw_thermal_stats_cap: Thermal Stats Fw capability
337 */
338 struct wlan_fwol_capability_info {
339 #ifdef THERMAL_STATS_SUPPORT
340 bool fw_thermal_stats_cap;
341 #endif
342 };
343
344 /**
345 * struct wlan_fwol_psoc_obj - FW offload psoc priv object
346 * @cfg: cfg items
347 * @cbs: callback functions
348 * @tx_ops: tx operations for target interface
349 * @rx_ops: rx operations for target interface
350 * @thermal_throttle: cached target thermal stats information
351 * @thermal_cbs: thermal notification callbacks to hdd layer
352 * @capability_info: fwol capability info
353 */
354 struct wlan_fwol_psoc_obj {
355 struct wlan_fwol_cfg cfg;
356 struct wlan_fwol_callbacks cbs;
357 struct wlan_fwol_tx_ops tx_ops;
358 struct wlan_fwol_rx_ops rx_ops;
359 #ifdef FW_THERMAL_THROTTLE_SUPPORT
360 struct wlan_fwol_thermal_throttle_info thermal_throttle;
361 struct fwol_thermal_callbacks thermal_cbs;
362 #endif
363 struct wlan_fwol_capability_info capability_info;
364 };
365
366 /**
367 * struct wlan_fwol_rx_event - event from south bound
368 * @psoc: psoc handle
369 * @event_id: event ID
370 * @get_elna_bypass_response: get eLNA bypass response
371 * @get_thermal_stats_response: get thermal stats response
372 */
373 struct wlan_fwol_rx_event {
374 struct wlan_objmgr_psoc *psoc;
375 enum wlan_fwol_southbound_event event_id;
376 union {
377 #ifdef WLAN_FEATURE_ELNA
378 struct get_elna_bypass_response get_elna_bypass_response;
379 #endif
380 #ifdef THERMAL_STATS_SUPPORT
381 struct thermal_throttle_info get_thermal_stats_response;
382 #endif
383 };
384 };
385
386 /**
387 * fwol_get_psoc_obj() - private API to get fwol object from psoc
388 * @psoc: psoc object
389 *
390 * Return: fwol object
391 */
392 struct wlan_fwol_psoc_obj *fwol_get_psoc_obj(struct wlan_objmgr_psoc *psoc);
393
394 /**
395 * fwol_cfg_on_psoc_enable() - Populate FWOL structure from CFG and INI
396 * @psoc: pointer to the psoc object
397 *
398 * Populate the FWOL CFG structure from CFG and INI values using CFG APIs
399 *
400 * Return: QDF_STATUS
401 */
402 QDF_STATUS fwol_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc);
403
404 /**
405 * fwol_cfg_on_psoc_disable() - Clear the CFG structure on psoc disable
406 * @psoc: pointer to the psoc object
407 *
408 * Clear the FWOL CFG structure on psoc disable
409 *
410 * Return: QDF_STATUS
411 */
412 QDF_STATUS fwol_cfg_on_psoc_disable(struct wlan_objmgr_psoc *psoc);
413
414 /**
415 * fwol_process_event() - API to process event from south bound
416 * @msg: south bound message
417 *
418 * Return: QDF_STATUS_SUCCESS on success
419 */
420 QDF_STATUS fwol_process_event(struct scheduler_msg *msg);
421
422 /**
423 * fwol_release_rx_event() - Release fw offload RX event
424 * @event: fw offload RX event
425 *
426 * Return: none
427 */
428 void fwol_release_rx_event(struct wlan_fwol_rx_event *event);
429
430 /**
431 * fwol_init_neighbor_report_cfg() - Populate default neighbor report CFG values
432 * @psoc: pointer to the psoc object
433 * @fwol_neighbor_report_cfg: Pointer to Neighbor report config data structure
434 *
435 * Return: QDF_STATUS
436 */
437 QDF_STATUS fwol_init_neighbor_report_cfg(struct wlan_objmgr_psoc *psoc,
438 struct wlan_fwol_neighbor_report_cfg
439 *fwol_neighbor_report_cfg);
440
441 /**
442 * fwol_init_adapt_dwelltime_in_cfg() - initialize adaptive dwell time params
443 * @psoc: Pointer to struct wlan_objmgr_psoc context
444 * @dwelltime_params: Pointer to dwell time params
445 *
446 * This function parses initialize the adaptive dwell params from ini.
447 *
448 * Return: QDF_STATUS
449 */
450 QDF_STATUS
451 fwol_init_adapt_dwelltime_in_cfg(
452 struct wlan_objmgr_psoc *psoc,
453 struct adaptive_dwelltime_params *dwelltime_params);
454
455 /**
456 * fwol_set_adaptive_dwelltime_config() - API to set adaptive dwell params
457 * config
458 * @dwelltime_params: adaptive_dwelltime_params structure
459 *
460 * Return: QDF Status
461 */
462 QDF_STATUS
463 fwol_set_adaptive_dwelltime_config(
464 struct adaptive_dwelltime_params *dwelltime_params);
465
466 /**
467 * fwol_set_ilp_config() - API to set ILP HW block config
468 * @pdev: pointer to the pdev object
469 * @enable_ilp: ILP HW block configuration with various options
470 *
471 * Return: QDF_STATUS
472 */
473 QDF_STATUS fwol_set_ilp_config(struct wlan_objmgr_pdev *pdev,
474 uint32_t enable_ilp);
475
476 /**
477 * fwol_set_sap_sho() - API to set SAP SHO config
478 * @psoc: pointer to the psoc object
479 * @vdev_id: vdev id
480 * @sap_sho: enable/disable config for SAP SHO
481 * SHO- SoftAP hardware offload – When enabled the beacon/probe resp
482 * will be offloaded to HW.
483 *
484 * Return: QDF_STATUS
485 */
486 QDF_STATUS fwol_set_sap_sho(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
487 uint32_t sap_sho);
488
489 /**
490 * fwol_configure_hw_assist() - API to configure HW assist feature in FW
491 * @pdev: pointer to the pdev object
492 * @disable_hw_assist: Flag to enable/disable HW assist feature
493 *
494 * Return: QDF_STATUS
495 */
496 QDF_STATUS fwol_configure_hw_assist(struct wlan_objmgr_pdev *pdev,
497 bool disable_hw_assist);
498
499 /**
500 * fwol_set_sap_wds_config() - API to configure WDS mode on SAP vdev
501 * @psoc: pointer to the psoc object
502 * @vdev_id: vdev id
503 *
504 * Return: QDF_STATUS
505 */
506 #ifdef FEATURE_WDS
507 QDF_STATUS
508 fwol_set_sap_wds_config(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id);
509 #else
510 static inline QDF_STATUS
fwol_set_sap_wds_config(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)511 fwol_set_sap_wds_config(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
512 {
513 return QDF_STATUS_SUCCESS;
514 }
515 #endif
516 #endif
517