1 /* 2 * Copyright (c) 2017-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 /* 21 * DOC: contains scan init/deinit public api 22 */ 23 24 #ifndef _WLAN_SCAN_MAIN_API_H_ 25 #define _WLAN_SCAN_MAIN_API_H_ 26 27 #include <qdf_atomic.h> 28 #include <wlan_objmgr_psoc_obj.h> 29 #include <wlan_objmgr_pdev_obj.h> 30 #include <wlan_objmgr_vdev_obj.h> 31 #include <wlan_scan_public_structs.h> 32 #include "wlan_scan_cache_db.h" 33 #include "wlan_scan_11d.h" 34 #include "cfg_scan.h" 35 36 #define scm_alert(params...) \ 37 QDF_TRACE_FATAL(QDF_MODULE_ID_SCAN, params) 38 #define scm_err(params...) \ 39 QDF_TRACE_ERROR(QDF_MODULE_ID_SCAN, params) 40 #define scm_warn(params...) \ 41 QDF_TRACE_WARN(QDF_MODULE_ID_SCAN, params) 42 #define scm_notice(params...) \ 43 QDF_TRACE_INFO(QDF_MODULE_ID_SCAN, params) 44 #define scm_info(params...) \ 45 QDF_TRACE_INFO(QDF_MODULE_ID_SCAN, params) 46 #define scm_debug(params...) \ 47 QDF_TRACE_DEBUG(QDF_MODULE_ID_SCAN, params) 48 49 /* Rate Limited Logs */ 50 #define scm_alert_rl(params...) \ 51 QDF_TRACE_FATAL_RL(QDF_MODULE_ID_SCAN, params) 52 #define scm_err_rl(params...) \ 53 QDF_TRACE_ERROR_RL(QDF_MODULE_ID_SCAN, params) 54 #define scm_warn_rl(params...) \ 55 QDF_TRACE_WARN_RL(QDF_MODULE_ID_SCAN, params) 56 #define scm_info_rl(params...) \ 57 QDF_TRACE_INFO_RL(QDF_MODULE_ID_SCAN, params) 58 #define scm_debug_rl(params...) \ 59 QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_SCAN, params) 60 61 #define scm_nofl_alert(params...) \ 62 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_SCAN, params) 63 #define scm_nofl_err(params...) \ 64 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SCAN, params) 65 #define scm_nofl_warn(params...) \ 66 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_SCAN, params) 67 #define scm_nofl_info(params...) \ 68 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_SCAN, params) 69 #define scm_nofl_debug(params...) \ 70 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_SCAN, params) 71 72 #define scm_hex_dump(level, data, buf_len) \ 73 qdf_trace_hex_dump(QDF_MODULE_ID_SCAN, level, data, buf_len) 74 75 #define MAX_SCAN_EVENT_HANDLERS_PER_PDEV 100 76 #define WLAN_MAX_MODULE_NAME 40 77 #define WLAN_MAX_REQUESTORS 200 78 #define WLAN_SCAN_ID_MASK 0x00000FFF 79 #define WLAN_HOST_SCAN_REQ_ID_PREFIX 0x0000A000 80 #define SCAN_NPROBES_DEFAULT 2 81 #define WLAN_P2P_SOCIAL_CHANNELS 3 82 83 #define SCAN_BURST_SCAN_MAX_NUM_OFFCHANNELS (3) 84 #define SCAN_SCAN_IDLE_TIME_DEFAULT (25) 85 #define SCAN_3PORT_CONC_SCAN_MAX_BURST_DURATION (25) 86 #define SCAN_CTS_DURATION_MS_MAX (32) 87 #define SCAN_ROAM_SCAN_CHANNEL_SWITCH_TIME (4) 88 #define SCAN_DWELL_TIME_PROBE_TIME_MAP_SIZE (11) 89 #define SCAN_GO_MIN_ACTIVE_SCAN_BURST_DURATION (40) 90 #define SCAN_GO_MAX_ACTIVE_SCAN_BURST_DURATION (240) 91 #define SCAN_P2P_SCAN_MAX_BURST_DURATION (240) 92 #define SCAN_GO_BURST_SCAN_MAX_NUM_OFFCHANNELS (6) 93 94 /* MAX RNR entries per channel*/ 95 #define WLAN_MAX_RNR_COUNT 15 96 97 /* 98 * Maximum numbers of callback functions that may be invoked 99 * for a particular scan event. 100 */ 101 #define MAX_SCAN_EVENT_LISTENERS (MAX_SCAN_EVENT_HANDLERS_PER_PDEV + 1) 102 103 /** 104 * struct probe_time_dwell_time - probe time, dwell time map 105 * @dwell_time: dwell time 106 * @probe_time: repeat probe time 107 */ 108 struct probe_time_dwell_time { 109 uint8_t dwell_time; 110 uint8_t probe_time; 111 }; 112 113 /* 114 * For the requestor id: 115 * bit 0~12 is used for real requestor id. 116 * bit 13~15 is used for requestor prefix. 117 * bit 16~19 is used by specific user to aware it is issued by himself. 118 * bit 20~31 is reserved. 119 */ 120 #define WLAN_SCAN_REQUESTER_ID_PREFIX 0x0000A000 121 #define WLAN_SCAN_REQUESTER_ID_MASK 0x00001FFF 122 123 #define SCM_NUM_RSSI_CAT 15 124 #define SCAN_STA_MIRACAST_MCC_REST_TIME 400 125 126 #define SCAN_TIMEOUT_GRACE_PERIOD 10 127 #define SCAN_MAX_BSS_PDEV 100 128 #define SCAN_PRIORITY SCAN_PRIORITY_LOW 129 130 /* DBS Scan policy selection ext flags */ 131 #define SCAN_FLAG_EXT_DBS_SCAN_POLICY_MASK 0x00000003 132 #define SCAN_FLAG_EXT_DBS_SCAN_POLICY_BIT 0 133 #define SCAN_DBS_POLICY_DEFAULT 0x0 134 #define SCAN_DBS_POLICY_FORCE_NONDBS 0x1 135 #define SCAN_DBS_POLICY_IGNORE_DUTY 0x2 136 #define SCAN_DBS_POLICY_MAX 0x3 137 /* Minimum number of channels for enabling DBS Scan */ 138 #define SCAN_MIN_CHAN_DBS_SCAN_THRESHOLD 8 139 /* 140 * Enable Reception of Public Action frame with this flag 141 */ 142 #define SCAN_FLAG_EXT_FILTER_PUBLIC_ACTION_FRAME 0x4 143 144 /* Indicate to scan all PSC channel */ 145 #define SCAN_FLAG_EXT_6GHZ_SCAN_ALL_PSC_CH 0x8 146 147 /* Indicate to scan all NON-PSC channel */ 148 #define SCAN_FLAG_EXT_6GHZ_SCAN_ALL_NON_PSC_CH 0x10 149 150 /* Indicate to save scan result matching hint from scan client */ 151 #define SCAN_FLAG_EXT_6GHZ_MATCH_HINT 0x20 152 153 /* Skip any channel on which RNR information is not received */ 154 #define SCAN_FLAG_EXT_6GHZ_SKIP_NON_RNR_CH 0x40 155 156 /* Indicate client hint req is high priority than FW rnr or FILS discovery */ 157 #define SCAN_FLAG_EXT_6GHZ_CLIENT_HIGH_PRIORITY 0x80 158 159 /* RRM scan type indication */ 160 #define SCAN_FLAG_EXT_RRM_SCAN_IND 0x400 161 162 /* Probe request frame with unicast RA indication */ 163 #define SCAN_FLAG_EXT_FORCE_UNICAST_RA 0x1000 164 165 /* Passive dwell time if bt_a2dp is enabled. Time in msecs*/ 166 #define PASSIVE_DWELL_TIME_BT_A2DP_ENABLED 28 167 168 /* Aux Scan Flags */ 169 #define SCAN_FLAG_EXT_AUX_LOW_LATENCY_SCAN 0x00008000 170 #define SCAN_FLAG_EXT_AUX_RELIABLE_SCAN 0x00010000 171 #define SCAN_FLAG_EXT_AUX_LOW_POWER_SCAN 0x00040000 172 #define SCAN_FLAG_EXT_AUX_FAST_SCAN 0x00020000 173 174 #define SCAN_FLAG_EXT_STOP_IF_BSSID_FOUND 0x00080000 175 /** 176 * struct cb_handler - defines scan event handler 177 * call back function and arguments 178 * @func: handler function pointer 179 * @arg: argument to handler function 180 */ 181 struct cb_handler { 182 scan_event_handler func; 183 void *arg; 184 }; 185 186 /** 187 * struct pdev_scan_ev_handler - pdev scan event handlers 188 * @handler_cnt: number of valid entries in @cb_handler 189 * @cb_handlers: array of registered scan handlers 190 */ 191 struct pdev_scan_ev_handler { 192 uint32_t handler_cnt; 193 struct cb_handler cb_handlers[MAX_SCAN_EVENT_HANDLERS_PER_PDEV]; 194 }; 195 196 /** 197 * struct global_scan_ev_handlers - per pdev registered scan event handlers 198 * @pdev_ev_handlers: per pdev registered scan event handlers 199 */ 200 struct global_scan_ev_handlers { 201 struct pdev_scan_ev_handler pdev_ev_handlers[WLAN_UMAC_MAX_PDEVS]; 202 }; 203 204 /** 205 * struct scan_requester_info - defines scan requester id 206 * and event handler mapping 207 * @requester: requester ID allocated 208 * @module: module name of requester 209 * @ev_handler: event handlerto be invoked 210 */ 211 struct scan_requester_info { 212 wlan_scan_requester requester; 213 uint8_t module[WLAN_MAX_MODULE_NAME]; 214 struct cb_handler ev_handler; 215 }; 216 217 /** 218 * struct pdev_scan_info - defines per pdev scan info 219 * @wide_band_scan: wide band scan capability 220 * @last_scan_time: time of last scan start on this pdev 221 * @custom_chan_list: scan only these channels 222 * @conf_bssid: configured bssid of the hidden AP 223 * @conf_ssid: configured desired ssid 224 * @chan_scan_info: channel list scan info 225 */ 226 struct pdev_scan_info { 227 bool wide_band_scan; 228 qdf_time_t last_scan_time; 229 struct chan_list custom_chan_list; 230 uint8_t conf_bssid[QDF_MAC_ADDR_SIZE]; 231 struct wlan_ssid conf_ssid; 232 struct chan_list_scan_info chan_scan_info; 233 }; 234 235 /** 236 * struct scan_vdev_obj - scan vdev obj 237 * @pno_match_evt_received: pno match received 238 * @pno_in_progress: pno in progress 239 * @scan_disabled: if scan is disabled for this vdev 240 * @first_scan_done: Whether its the first scan or not for this particular vdev. 241 */ 242 struct scan_vdev_obj { 243 bool pno_match_evt_received; 244 bool pno_in_progress; 245 uint32_t scan_disabled; 246 bool first_scan_done; 247 }; 248 249 #ifdef FEATURE_WLAN_SCAN_PNO 250 /** 251 * struct pno_def_config - def configuration for PNO 252 * @pno_offload_enabled: flag to check if PNO offload is enabled/disabled 253 * @channel_prediction: config PNO channel prediction feature status 254 * @top_k_num_of_channels: def top K number of channels are used for tanimoto 255 * distance calculation. 256 * @stationary_thresh: def threshold val to determine that STA is stationary. 257 * @adaptive_dwell_mode: def adaptive dwelltime mode for pno scan 258 * @channel_prediction_full_scan: def periodic timer upon which full scan needs 259 * to be triggered. 260 * @dfs_chnl_scan_enabled: Enable dfs channel PNO scan 261 * @scan_support_enabled: PNO scan support enabled/disabled 262 * @scan_timer_repeat_value: PNO scan timer repeat value 263 * @slow_scan_multiplier: PNO slow scan timer multiplier 264 * @max_sched_scan_plan_interval: PNO scan interval 265 * @max_sched_scan_plan_iterations: PNO scan number of iterations 266 * @scan_backoff_multiplier: Scan banckoff multiplier 267 * @pno_wake_lock: pno wake lock 268 * @pno_runtime_pm_lock: pno runtime pm lock 269 * @pno_cb: callback to call on PNO completion 270 * @mawc_params: Configuration parameters for NLO MAWC. 271 * @user_config_sched_scan_plan: if enabled set user confing sched scan plan 272 */ 273 struct pno_def_config { 274 bool pno_offload_enabled; 275 bool channel_prediction; 276 uint8_t top_k_num_of_channels; 277 uint8_t stationary_thresh; 278 enum scan_dwelltime_adaptive_mode adaptive_dwell_mode; 279 uint32_t channel_prediction_full_scan; 280 bool dfs_chnl_scan_enabled; 281 bool scan_support_enabled; 282 uint32_t scan_timer_repeat_value; 283 uint32_t slow_scan_multiplier; 284 uint32_t max_sched_scan_plan_interval; 285 uint32_t max_sched_scan_plan_iterations; 286 uint8_t scan_backoff_multiplier; 287 qdf_wake_lock_t pno_wake_lock; 288 qdf_runtime_lock_t pno_runtime_pm_lock; 289 struct cb_handler pno_cb; 290 struct nlo_mawc_params mawc_params; 291 bool user_config_sched_scan_plan; 292 }; 293 #endif 294 295 #ifdef FEATURE_WLAN_EXTSCAN 296 /** 297 * struct extscan_def_config - def configuration for EXTSCAN 298 * @extscan_enabled: enable extscan 299 * @extscan_passive_max_chn_time: max passive channel time 300 * @extscan_passive_min_chn_time: min passive channel time 301 * @extscan_active_max_chn_time: max active channel time 302 * @extscan_active_min_chn_time: min active channel time 303 */ 304 struct extscan_def_config { 305 bool extscan_enabled; 306 uint32_t extscan_passive_max_chn_time; 307 uint32_t extscan_passive_min_chn_time; 308 uint32_t extscan_active_max_chn_time; 309 uint32_t extscan_active_min_chn_time; 310 }; 311 #endif 312 313 /** 314 * struct scan_default_params - default scan parameters to be used 315 * @active_dwell: default active dwell time 316 * @allow_dfs_chan_in_first_scan: first scan should contain dfs channels or not. 317 * @allow_dfs_chan_in_scan: Scan DFS channels or not. 318 * @skip_dfs_chan_in_p2p_search: Skip DFS channels in p2p search. 319 * @use_wake_lock_in_user_scan: if wake lock will be acquired during user scan 320 * @active_dwell_2g: default active dwell time for 2G channels, if it's not zero 321 * @min_dwell_time_6g: default min dwell time for 6G channels 322 * @active_dwell_6g: default active dwell time for 6G channels 323 * @passive_dwell_6g: default passive dwell time for 6G channels 324 * @active_dwell_time_6g_conc: default concurrent active dwell time for 6G 325 * @passive_dwell_time_6g_conc: default concurrent passive dwell time for 6G 326 * @passive_dwell:default passive dwell time 327 * @max_rest_time: default max rest time 328 * @sta_miracast_mcc_rest_time: max rest time for miracast and mcc 329 * @min_rest_time: default min rest time 330 * @idle_time: default idle time 331 * @conc_active_dwell: default concurrent active dwell time 332 * @conc_passive_dwell: default concurrent passive dwell time 333 * @conc_max_rest_time: default concurrent max rest time 334 * @conc_min_rest_time: default concurrent min rest time 335 * @conc_idle_time: default concurrent idle time 336 * @conc_chlist_trim: enable to trim concurrent scan channel list 337 * @repeat_probe_time: default repeat probe time 338 * @probe_spacing_time: default probe spacing time 339 * @probe_delay: default probe delay 340 * @burst_duration: default burst duration 341 * @max_scan_time: default max scan time 342 * @num_probes: default maximum number of probes to sent 343 * @scan_cache_aging_time: default scan cache aging time 344 * @select_5ghz_margin: Prefer connecting to 5 GHz AP even if 345 * its RSSI is lower by @select_5ghz_margin dbm than 2.4 GHz AP. 346 * applicable if prefer_5ghz is set. 347 * @enable_mac_spoofing: enable mac address spoof in scan 348 * @usr_cfg_probe_rpt_time: 349 * @usr_cfg_num_probes: 350 * @max_bss_per_pdev: maximum number of bss entries to be maintained per pdev 351 * @max_active_scans_allowed: maximum number of active parallel scan allowed 352 * per psoc 353 * @sta_scan_burst_duration: 354 * @p2p_scan_burst_duration: 355 * @go_scan_burst_duration: 356 * @ap_scan_burst_duration: 357 * @scan_mode_6g: scan mode in 6 GHz 358 * @duty_cycle_6ghz: Enable optimization on 6 GHz channels for every full scan 359 * except the duty cycle. So that every nth scan(depending on 360 * duty cycle) is a full scan and rest are all optimized scans 361 * @enable_connected_scan: enable scans after connection 362 * @scan_priority: default scan priority 363 * @adaptive_dwell_time_mode: adaptive dwell mode with connection 364 * @adaptive_dwell_time_mode_nc: adaptive dwell mode without connection 365 * @honour_nl_scan_policy_flags: honour nl80211 scan policy flags 366 * @extscan_adaptive_dwell_mode: Adaptive dwell mode during ext scan 367 * @skip_6g_and_indoor_freq: skip 6 GHz and 5 GHz indoor freq channel for 368 * STA scan if hw is non-DBS and SAP is present 369 * @last_scan_ageout_time: use last full scan results for provided time in ms 370 * @scan_f_passive: passively scan all channels including active channels 371 * @scan_f_bcast_probe: add wild card ssid prbreq even if ssid_list is specified 372 * @scan_f_cck_rates: add cck rates to rates/xrates ie in prb req 373 * @scan_f_ofdm_rates: add ofdm rates to rates/xrates ie in prb req 374 * @scan_f_chan_stat_evnt: enable indication of chan load and noise floor 375 * @scan_f_filter_prb_req: filter Probe request frames 376 * @scan_f_bypass_dfs_chn: when set, do not scan DFS channels 377 * @scan_f_continue_on_err:continue scan even if few certain errors have occurred 378 * @scan_f_offchan_mgmt_tx: allow mgmt transmission during off channel scan 379 * @scan_f_offchan_data_tx: allow data transmission during off channel scan 380 * @scan_f_promisc_mode: scan with promiscuous mode 381 * @scan_f_capture_phy_err: enable capture ppdu with phy errors 382 * @scan_f_strict_passive_pch: do passive scan on passive channels 383 * @scan_f_half_rate: enable HALF (10MHz) rate support 384 * @scan_f_quarter_rate: set Quarter (5MHz) rate support 385 * @scan_f_force_active_dfs_chn: allow to send probe req on DFS channel 386 * @scan_f_add_tpc_ie_in_probe: add TPC ie in probe req frame 387 * @scan_f_add_ds_ie_in_probe: add DS ie in probe req frame 388 * @scan_f_add_spoofed_mac_in_probe: use random mac address for TA in probe 389 * @scan_f_add_rand_seq_in_probe: use random sequence number in probe 390 * @scan_f_en_ie_allowlist_in_probe: enable ie allowlist in probe 391 * @scan_f_forced: force scan even in presence of data traffic 392 * @scan_f_2ghz: scan 2.4 GHz channels 393 * @scan_f_5ghz: scan 5 GHz channels 394 * @scan_f_wide_band: scan in 40 MHz or higher bandwidth 395 * @scan_flags: variable to read and set scan_f_* flags in one shot 396 * can be used to dump all scan_f_* flags for debug 397 * @scan_ev_started: notify scan started event 398 * @scan_ev_completed: notify scan completed event 399 * @scan_ev_bss_chan: notify bss chan event 400 * @scan_ev_foreign_chan: notify foreign chan event 401 * @scan_ev_dequeued: notify scan request dequeued event 402 * @scan_ev_preempted: notify scan preempted event 403 * @scan_ev_start_failed: notify scan start failed event 404 * @scan_ev_restarted: notify scan restarted event 405 * @scan_ev_foreign_chn_exit: notify foreign chan exit event 406 * @scan_ev_invalid: notify invalid scan request event 407 * @scan_ev_gpio_timeout: notify gpio timeout event 408 * @scan_ev_suspended: notify scan suspend event 409 * @scan_ev_resumed: notify scan resumed event 410 * @scan_events: variable to read and set scan_ev_* flags in one shot 411 * can be used to dump all scan_ev_* flags for debug 412 */ 413 struct scan_default_params { 414 uint32_t active_dwell; 415 bool allow_dfs_chan_in_first_scan; 416 bool allow_dfs_chan_in_scan; 417 bool skip_dfs_chan_in_p2p_search; 418 bool use_wake_lock_in_user_scan; 419 uint32_t active_dwell_2g; 420 uint32_t min_dwell_time_6g; 421 uint32_t active_dwell_6g; 422 uint32_t passive_dwell_6g; 423 uint32_t active_dwell_time_6g_conc; 424 uint32_t passive_dwell_time_6g_conc; 425 uint32_t passive_dwell; 426 uint32_t max_rest_time; 427 uint32_t sta_miracast_mcc_rest_time; 428 uint32_t min_rest_time; 429 uint32_t idle_time; 430 uint32_t conc_active_dwell; 431 uint32_t conc_passive_dwell; 432 uint32_t conc_max_rest_time; 433 uint32_t conc_min_rest_time; 434 uint32_t conc_idle_time; 435 bool conc_chlist_trim; 436 uint32_t repeat_probe_time; 437 uint32_t probe_spacing_time; 438 uint32_t probe_delay; 439 uint32_t burst_duration; 440 uint32_t max_scan_time; 441 uint32_t num_probes; 442 qdf_time_t scan_cache_aging_time; 443 uint32_t select_5ghz_margin; 444 bool enable_mac_spoofing; 445 uint32_t usr_cfg_probe_rpt_time; 446 uint32_t usr_cfg_num_probes; 447 uint16_t max_bss_per_pdev; 448 uint32_t max_active_scans_allowed; 449 uint8_t sta_scan_burst_duration; 450 uint8_t p2p_scan_burst_duration; 451 uint8_t go_scan_burst_duration; 452 uint8_t ap_scan_burst_duration; 453 enum scan_mode_6ghz scan_mode_6g; 454 uint8_t duty_cycle_6ghz; 455 bool enable_connected_scan; 456 enum scan_priority scan_priority; 457 enum scan_dwelltime_adaptive_mode adaptive_dwell_time_mode; 458 enum scan_dwelltime_adaptive_mode adaptive_dwell_time_mode_nc; 459 bool honour_nl_scan_policy_flags; 460 enum scan_dwelltime_adaptive_mode extscan_adaptive_dwell_mode; 461 bool skip_6g_and_indoor_freq; 462 uint32_t last_scan_ageout_time; 463 union { 464 struct { 465 uint32_t scan_f_passive:1, 466 scan_f_bcast_probe:1, 467 scan_f_cck_rates:1, 468 scan_f_ofdm_rates:1, 469 scan_f_chan_stat_evnt:1, 470 scan_f_filter_prb_req:1, 471 scan_f_bypass_dfs_chn:1, 472 scan_f_continue_on_err:1, 473 scan_f_offchan_mgmt_tx:1, 474 scan_f_offchan_data_tx:1, 475 scan_f_promisc_mode:1, 476 scan_f_capture_phy_err:1, 477 scan_f_strict_passive_pch:1, 478 scan_f_half_rate:1, 479 scan_f_quarter_rate:1, 480 scan_f_force_active_dfs_chn:1, 481 scan_f_add_tpc_ie_in_probe:1, 482 scan_f_add_ds_ie_in_probe:1, 483 scan_f_add_spoofed_mac_in_probe:1, 484 scan_f_add_rand_seq_in_probe:1, 485 scan_f_en_ie_allowlist_in_probe:1, 486 scan_f_forced:1, 487 scan_f_2ghz:1, 488 scan_f_5ghz:1, 489 scan_f_wide_band:1; 490 }; 491 uint32_t scan_flags; 492 }; 493 union { 494 struct { 495 uint32_t scan_ev_started:1, 496 scan_ev_completed:1, 497 scan_ev_bss_chan:1, 498 scan_ev_foreign_chan:1, 499 scan_ev_dequeued:1, 500 scan_ev_preempted:1, 501 scan_ev_start_failed:1, 502 scan_ev_restarted:1, 503 scan_ev_foreign_chn_exit:1, 504 scan_ev_invalid:1, 505 scan_ev_gpio_timeout:1, 506 scan_ev_suspended:1, 507 scan_ev_resumed:1; 508 }; 509 uint32_t scan_events; 510 }; 511 }; 512 513 /** 514 * struct scan_cb - nif/sif function callbacks 515 * @inform_beacon: cb to indicate frame to OS 516 * @update_beacon: cb to indicate frame to MLME 517 * @unlink_bss: cb to unlink bss from kernel cache 518 * @inform_mbssid_bcn_prb_rsp: cb to indicate frames with mbssid 519 */ 520 struct scan_cb { 521 update_beacon_cb inform_beacon; 522 update_beacon_cb update_beacon; 523 update_beacon_cb unlink_bss; 524 update_mbssid_bcn_prb_rsp inform_mbssid_bcn_prb_rsp; 525 /* Define nif/sif function callbacks here */ 526 }; 527 528 /** 529 * struct wlan_scan_obj - scan object definition 530 * @scan_disabled: if scan is disabled 531 * @scan_db: scan cache data base 532 * @cc_db: pointer of country code data base 533 * @lock: spin lock 534 * @scan_def: default scan parameters 535 * @cb: nif/sif function callbacks 536 * @requesters: requester allocation pool 537 * @scan_ids: last allocated scan id 538 * @global_evhandlers: registered scan event handlers 539 * @pdev_info: pointer to pdev info 540 * @pno_cfg: default pno configuration 541 * @extscan_cfg: default extscan configuration 542 * @ie_allowlist: default ie allowlist attrs 543 * @bt_a2dp_enabled: if bt a2dp is enabled 544 * @miracast_enabled: miracast enabled 545 * @disable_timeout: command timeout disabled 546 * @drop_bcn_on_chan_mismatch: drop bcn if channel mismatch 547 * @obss_scan_offload: if obss scan offload is enabled 548 * @drop_bcn_on_invalid_freq: drop bcn if freq is invalid in IEs (DS/HT/HE) 549 * @scan_start_request_buff: buffer used to pass 550 * scan config to event handlers 551 * @rnr_channel_db: RNR channel list database 552 * @scan_listener_cb_exe_dur: 553 * @scm_scan_event_duration: 554 * @scm_scan_to_post_scan_duration: 555 * @duty_cycle_cnt_6ghz: Scan count to track the full scans and decide whether 556 * to optimizate 6g channels in the scan request based 557 * on the ini scan_mode_6ghz_duty_cycle. 558 * @allow_bss_with_incomplete_ie: Continue scan entry even if any corrupted 559 * IEs are present. 560 * @aux_mac_support: advertise aux mac support from FW 561 */ 562 struct wlan_scan_obj { 563 uint32_t scan_disabled; 564 qdf_spinlock_t lock; 565 qdf_atomic_t scan_ids; 566 struct scan_dbs scan_db[WLAN_UMAC_MAX_PDEVS]; 567 struct scan_country_code_db *cc_db; 568 struct scan_default_params scan_def; 569 struct scan_cb cb; 570 struct scan_requester_info requesters[WLAN_MAX_REQUESTORS]; 571 struct global_scan_ev_handlers global_evhandlers; 572 struct pdev_scan_info pdev_info[WLAN_UMAC_MAX_PDEVS]; 573 #ifdef FEATURE_WLAN_SCAN_PNO 574 struct pno_def_config pno_cfg; 575 #endif 576 #ifdef FEATURE_WLAN_EXTSCAN 577 struct extscan_def_config extscan_cfg; 578 #endif 579 struct probe_req_allowlist_attr ie_allowlist; 580 bool bt_a2dp_enabled; 581 bool miracast_enabled; 582 bool disable_timeout; 583 bool drop_bcn_on_chan_mismatch; 584 bool drop_bcn_on_invalid_freq; 585 bool obss_scan_offload; 586 struct scan_start_request scan_start_request_buff; 587 #ifdef FEATURE_6G_SCAN_CHAN_SORT_ALGO 588 struct channel_list_db rnr_channel_db; 589 #endif 590 #ifdef ENABLE_SCAN_PROFILE 591 uint64_t scan_listener_cb_exe_dur[MAX_SCAN_EVENT_LISTENERS]; 592 uint64_t scm_scan_event_duration; 593 uint64_t scm_scan_to_post_scan_duration; 594 #endif 595 uint16_t duty_cycle_cnt_6ghz; 596 bool allow_bss_with_incomplete_ie; 597 bool aux_mac_support; 598 }; 599 600 #ifdef ENABLE_SCAN_PROFILE 601 static inline scm_duration_init(struct wlan_scan_obj * scan)602 void scm_duration_init(struct wlan_scan_obj *scan) 603 { 604 if (!scan) 605 return; 606 607 scan->scm_scan_event_duration = 0; 608 scan->scm_scan_to_post_scan_duration = 0; 609 } 610 611 static inline scm_event_duration_start(struct wlan_scan_obj * scan)612 void scm_event_duration_start(struct wlan_scan_obj *scan) 613 { 614 if (!scan) 615 return; 616 617 scan->scm_scan_event_duration = 618 qdf_ktime_to_ms(qdf_ktime_get()); 619 } 620 621 static inline scm_event_duration_end(struct wlan_scan_obj * scan)622 void scm_event_duration_end(struct wlan_scan_obj *scan) 623 { 624 if (!scan) 625 return; 626 627 scan->scm_scan_event_duration = 628 (qdf_ktime_to_ms(qdf_ktime_get()) - 629 scan->scm_scan_event_duration); 630 } 631 632 static inline scm_to_post_scan_duration_set(struct wlan_scan_obj * scan)633 void scm_to_post_scan_duration_set(struct wlan_scan_obj *scan) 634 { 635 if (!scan) 636 return; 637 638 scan->scm_scan_to_post_scan_duration = 639 (qdf_ktime_to_ms(qdf_ktime_get()) - 640 scan->scm_scan_event_duration); 641 } 642 643 static inline scm_listener_cb_exe_dur_start(struct wlan_scan_obj * scan,uint8_t index)644 void scm_listener_cb_exe_dur_start(struct wlan_scan_obj *scan, uint8_t index) 645 { 646 if (!scan || (index >= MAX_SCAN_EVENT_LISTENERS)) 647 return; 648 649 scan->scan_listener_cb_exe_dur[index] = 650 qdf_ktime_to_ms(qdf_ktime_get()); 651 } 652 653 static inline scm_listener_cb_exe_dur_end(struct wlan_scan_obj * scan,uint8_t index)654 void scm_listener_cb_exe_dur_end(struct wlan_scan_obj *scan, uint8_t index) 655 { 656 if (!scan || (index >= MAX_SCAN_EVENT_LISTENERS)) 657 return; 658 659 scan->scan_listener_cb_exe_dur[index] = 660 (qdf_ktime_to_ms(qdf_ktime_get()) - 661 scan->scan_listener_cb_exe_dur[index]); 662 } 663 664 static inline scm_listener_duration_init(struct wlan_scan_obj * scan)665 void scm_listener_duration_init(struct wlan_scan_obj *scan) 666 { 667 if (!scan) 668 return; 669 670 qdf_mem_set(&scan->scan_listener_cb_exe_dur, 671 sizeof(uint64_t) * MAX_SCAN_EVENT_LISTENERS, 672 0); 673 } 674 #else 675 static inline scm_duration_init(struct wlan_scan_obj * scan)676 void scm_duration_init(struct wlan_scan_obj *scan) 677 { 678 } 679 680 static inline scm_event_duration_start(struct wlan_scan_obj * scan)681 void scm_event_duration_start(struct wlan_scan_obj *scan) 682 { 683 } 684 685 static inline scm_event_duration_end(struct wlan_scan_obj * scan)686 void scm_event_duration_end(struct wlan_scan_obj *scan) 687 { 688 } 689 690 static inline scm_to_post_scan_duration_set(struct wlan_scan_obj * scan)691 void scm_to_post_scan_duration_set(struct wlan_scan_obj *scan) 692 { 693 } 694 695 static inline scm_listener_cb_exe_dur_start(struct wlan_scan_obj * scan,uint8_t index)696 void scm_listener_cb_exe_dur_start(struct wlan_scan_obj *scan, uint8_t index) 697 { 698 } 699 700 static inline scm_listener_cb_exe_dur_end(struct wlan_scan_obj * scan,uint8_t index)701 void scm_listener_cb_exe_dur_end(struct wlan_scan_obj *scan, uint8_t index) 702 { 703 } 704 705 static inline scm_listener_duration_init(struct wlan_scan_obj * scan)706 void scm_listener_duration_init(struct wlan_scan_obj *scan) 707 { 708 } 709 #endif 710 711 /** 712 * wlan_psoc_get_scan_obj() - private API to get scan object from psoc 713 * @psoc: psoc object 714 * 715 * Return: scan object 716 */ 717 #define wlan_psoc_get_scan_obj(psoc) \ 718 wlan_psoc_get_scan_obj_fl(psoc, \ 719 __func__, __LINE__) 720 721 static inline struct wlan_scan_obj * wlan_psoc_get_scan_obj_fl(struct wlan_objmgr_psoc * psoc,const char * func,uint32_t line)722 wlan_psoc_get_scan_obj_fl(struct wlan_objmgr_psoc *psoc, 723 const char *func, uint32_t line) 724 { 725 struct wlan_scan_obj *scan_obj; 726 727 scan_obj = (struct wlan_scan_obj *) 728 wlan_objmgr_psoc_get_comp_private_obj(psoc, 729 WLAN_UMAC_COMP_SCAN); 730 if (!scan_obj) { 731 scm_err("%s:%u, Failed to get scan object", func, line); 732 return NULL; 733 } 734 return scan_obj; 735 } 736 737 /** 738 * wlan_pdev_get_scan_obj() - private API to get scan object from pdev 739 * @pdev: pdev object 740 * 741 * Return: scan object 742 */ 743 static inline struct wlan_scan_obj * wlan_pdev_get_scan_obj(struct wlan_objmgr_pdev * pdev)744 wlan_pdev_get_scan_obj(struct wlan_objmgr_pdev *pdev) 745 { 746 struct wlan_objmgr_psoc *psoc; 747 748 psoc = wlan_pdev_get_psoc(pdev); 749 750 return wlan_psoc_get_scan_obj(psoc); 751 } 752 753 /** 754 * wlan_vdev_get_scan_obj() - private API to get scan object from vdev 755 * @vdev: vdev object 756 * 757 * Return: scan object 758 */ 759 static inline struct wlan_scan_obj * wlan_vdev_get_scan_obj(struct wlan_objmgr_vdev * vdev)760 wlan_vdev_get_scan_obj(struct wlan_objmgr_vdev *vdev) 761 { 762 struct wlan_objmgr_pdev *pdev; 763 764 pdev = wlan_vdev_get_pdev(vdev); 765 766 return wlan_pdev_get_scan_obj(pdev); 767 } 768 769 /** 770 * wlan_get_vdev_scan_obj() - private API to get scan object vdev 771 * @vdev: vdev object 772 * 773 * Return: scan object 774 */ 775 static inline struct scan_vdev_obj * wlan_get_vdev_scan_obj(struct wlan_objmgr_vdev * vdev)776 wlan_get_vdev_scan_obj(struct wlan_objmgr_vdev *vdev) 777 { 778 struct scan_vdev_obj *scan_vdev_obj; 779 780 scan_vdev_obj = (struct scan_vdev_obj *) 781 wlan_objmgr_vdev_get_comp_private_obj(vdev, 782 WLAN_UMAC_COMP_SCAN); 783 784 return scan_vdev_obj; 785 } 786 787 /** 788 * wlan_scan_vdev_get_pdev_id() - private API to get pdev id from vdev object 789 * @vdev: vdev object 790 * 791 * Return: parent pdev id 792 */ 793 static inline uint8_t wlan_scan_vdev_get_pdev_id(struct wlan_objmgr_vdev * vdev)794 wlan_scan_vdev_get_pdev_id(struct wlan_objmgr_vdev *vdev) 795 { 796 struct wlan_objmgr_pdev *pdev; 797 798 pdev = wlan_vdev_get_pdev(vdev); 799 800 return wlan_objmgr_pdev_get_pdev_id(pdev); 801 } 802 803 /** 804 * wlan_pdev_get_pdev_scan_ev_handlers() - private API to get 805 * pdev scan event handlers 806 * @pdev: pdev object 807 * 808 * Return: pdev_scan_ev_handler object 809 */ 810 static inline struct pdev_scan_ev_handler* wlan_pdev_get_pdev_scan_ev_handlers(struct wlan_objmgr_pdev * pdev)811 wlan_pdev_get_pdev_scan_ev_handlers(struct wlan_objmgr_pdev *pdev) 812 { 813 uint8_t pdevid; 814 struct wlan_scan_obj *scan = NULL; 815 816 if (!pdev) 817 goto err; 818 819 pdevid = wlan_objmgr_pdev_get_pdev_id(pdev); 820 scan = wlan_pdev_get_scan_obj(pdev); 821 if (!scan) 822 goto err; 823 824 return &scan->global_evhandlers.pdev_ev_handlers[pdevid]; 825 826 err: 827 scm_err("NULL pointer, pdev: 0x%pK, scan_obj: 0x%pK", 828 pdev, scan); 829 return NULL; 830 } 831 832 /** 833 * wlan_vdev_get_pdev_scan_ev_handlers() - private API to get 834 * pdev scan event handlers 835 * @vdev: vdev object 836 * 837 * Return: pdev_scan_ev_handler object 838 */ 839 static inline struct pdev_scan_ev_handler* wlan_vdev_get_pdev_scan_ev_handlers(struct wlan_objmgr_vdev * vdev)840 wlan_vdev_get_pdev_scan_ev_handlers(struct wlan_objmgr_vdev *vdev) 841 { 842 struct wlan_objmgr_pdev *pdev; 843 844 pdev = wlan_vdev_get_pdev(vdev); 845 846 return wlan_pdev_get_pdev_scan_ev_handlers(pdev); 847 } 848 849 /** 850 * wlan_scan_psoc_get_def_params() - private API to get scan defaults 851 * @psoc: psoc object 852 * 853 * Return: scan defaults 854 */ 855 static inline struct scan_default_params* wlan_scan_psoc_get_def_params(struct wlan_objmgr_psoc * psoc)856 wlan_scan_psoc_get_def_params(struct wlan_objmgr_psoc *psoc) 857 { 858 struct wlan_scan_obj *scan = NULL; 859 860 if (!psoc) { 861 scm_err("null psoc"); 862 return NULL; 863 } 864 scan = wlan_psoc_get_scan_obj(psoc); 865 866 if (!scan) 867 return NULL; 868 869 return &scan->scan_def; 870 } 871 872 /** 873 * wlan_vdev_get_def_scan_params() - private API to get scan defaults 874 * @vdev: vdev object 875 * 876 * Return: scan defaults 877 */ 878 static inline struct scan_default_params* wlan_vdev_get_def_scan_params(struct wlan_objmgr_vdev * vdev)879 wlan_vdev_get_def_scan_params(struct wlan_objmgr_vdev *vdev) 880 { 881 struct wlan_objmgr_psoc *psoc = NULL; 882 883 if (!vdev) { 884 scm_err("null vdev"); 885 return NULL; 886 } 887 psoc = wlan_vdev_get_psoc(vdev); 888 889 return wlan_scan_psoc_get_def_params(psoc); 890 } 891 892 /** 893 * wlan_scan_psoc_set_disable() - private API to disable scans for psoc 894 * @psoc: psoc on which scans need to be disabled 895 * @reason: reason for enable/disabled 896 * 897 * Return: QDF_STATUS. 898 */ 899 static inline QDF_STATUS wlan_scan_psoc_set_disable(struct wlan_objmgr_psoc * psoc,enum scan_disable_reason reason)900 wlan_scan_psoc_set_disable(struct wlan_objmgr_psoc *psoc, 901 enum scan_disable_reason reason) 902 { 903 struct wlan_scan_obj *scan_obj; 904 905 scan_obj = wlan_psoc_get_scan_obj(psoc); 906 if (!scan_obj) { 907 scm_err("Failed to get scan object"); 908 return QDF_STATUS_E_NULL_VALUE; 909 } 910 911 scan_obj->scan_disabled |= reason; 912 913 scm_debug("Psoc scan_disabled %x", scan_obj->scan_disabled); 914 915 return QDF_STATUS_SUCCESS; 916 } 917 918 static inline QDF_STATUS wlan_scan_psoc_set_enable(struct wlan_objmgr_psoc * psoc,enum scan_disable_reason reason)919 wlan_scan_psoc_set_enable(struct wlan_objmgr_psoc *psoc, 920 enum scan_disable_reason reason) 921 { 922 struct wlan_scan_obj *scan_obj; 923 924 scan_obj = wlan_psoc_get_scan_obj(psoc); 925 if (!scan_obj) { 926 scm_err("Failed to get scan object"); 927 return QDF_STATUS_E_NULL_VALUE; 928 } 929 930 scan_obj->scan_disabled &= ~reason; 931 scm_debug("Psoc scan_disabled %x", scan_obj->scan_disabled); 932 933 return QDF_STATUS_SUCCESS; 934 } 935 936 /** 937 * wlan_scan_psoc_created_notification() - scan psoc create handler 938 * @psoc: psoc object 939 * @arg_list: Argument list 940 * 941 * Return: QDF_STATUS 942 */ 943 QDF_STATUS wlan_scan_psoc_created_notification(struct wlan_objmgr_psoc *psoc, 944 void *arg_list); 945 946 /** 947 * wlan_scan_psoc_destroyed_notification() - scan psoc delete handler 948 * @psoc: psoc object 949 * @arg_list: Argument list 950 * 951 * Return: QDF_STATUS 952 */ 953 QDF_STATUS wlan_scan_psoc_destroyed_notification(struct wlan_objmgr_psoc *psoc, 954 void *arg_list); 955 956 /** 957 * wlan_scan_vdev_created_notification() - scan psoc create handler 958 * @vdev: vdev object 959 * @arg_list: Argument list 960 * 961 * Return: QDF_STATUS 962 */ 963 QDF_STATUS wlan_scan_vdev_created_notification(struct wlan_objmgr_vdev *vdev, 964 void *arg_list); 965 966 /** 967 * wlan_scan_vdev_destroyed_notification() - scan psoc delete handler 968 * @vdev: vdev object 969 * @arg_list: Argument list 970 * 971 * Return: QDF_STATUS 972 */ 973 QDF_STATUS wlan_scan_vdev_destroyed_notification(struct wlan_objmgr_vdev *vdev, 974 void *arg_list); 975 976 #endif 977