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