1 /* 2 * Copyright (c) 2013, 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * Copyright (c) 2005-2006 Atheros Communications, Inc. 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: This file has main dfs structures. 21 */ 22 23 #ifndef _DFS_H_ 24 #define _DFS_H_ 25 26 #include <qdf_types.h> /* QDF_NBUF_EXEMPT_NO_EXEMPTION, etc. */ 27 #include <qdf_net_types.h> /* QDF_NBUF_EXEMPT_NO_EXEMPTION, etc. */ 28 #include <qdf_nbuf.h> /* qdf_nbuf_t, etc. */ 29 #include <qdf_util.h> /* qdf_assert */ 30 #include <qdf_lock.h> /* qdf_spinlock */ 31 #include <qdf_time.h> 32 #include <qdf_timer.h> 33 #include <qdf_hrtimer.h> 34 #include <qdf_str.h> /* qdf_str_lcopy */ 35 36 #include <wlan_dfs_ioctl.h> 37 #include "dfs_structs.h" 38 #include "dfs_channel.h" 39 #include "dfs_ioctl_private.h" 40 #include <i_qdf_types.h> /* For qdf_packed*/ 41 #include "queue.h" /* For STAILQ_ENTRY */ 42 #include <wlan_objmgr_psoc_obj.h> 43 #include <wlan_objmgr_pdev_obj.h> 44 #include <osdep.h> 45 #include <wlan_cmn.h> 46 #include "target_type.h" 47 #include <wlan_dfs_public_struct.h> 48 #include <reg_services_public_struct.h> 49 50 /* File Line and Submodule String */ 51 #define FLSM(x, str) #str " : " FL(x) 52 /* Cast to dfs type */ 53 #define DC(x) ((struct wlan_dfs *)(x)) 54 55 /** 56 * dfs_log() - dfs logging using submodule MASKs and QDF trace level. 57 * @dfs: The dfs object pointer or NULL if dfs is not defined. 58 * @sm: Submodule BITMASK. 59 * @level: QDF trace level. 60 * @args...: Variable argument list. 61 * 62 * The logging is controlled by two bitmasks: 63 * 1) submodule bitmask: sm 64 * 2) trace level masks: level 65 * 66 * The submodule(sm) cannot be empty even if argument dfs is NULL. 67 * Else the macro will create a compilation error. 68 * One may provide WLAN_DEBUG_DFS_ALWAYS when the argument @dfs is NULL. 69 * 70 * dfs_log(NULL, WLAN_DEBUG_DFS_ALWAYS, QDF_TRACE_LEVEL_INFO,"Error pulse"); 71 * 72 * Why DC(x) is required? 73 * Since NULL is defined as ((void *)(0)), if the argument "dfs" 74 * in a call to the macro "dfs_log" is NULL 75 * then during compilation (NULL)->dfs_debug_mask will dereference 76 * a (void *) type, which is illegal. Therefore, we need 77 * the cast: (DC(dfs))->dfs_debug_mask. 78 * 79 * dfs_log(NULL, WLAN_DEBUG_DFS, QDF_TRACE_LEVEL_INFO,"dfs is NULL"); 80 */ 81 #define dfs_log(dfs, sm, level, args...) do { \ 82 if (((dfs) == NULL) || \ 83 ((sm) == WLAN_DEBUG_DFS_ALWAYS) || \ 84 ((sm) & ((DC(dfs))->dfs_debug_mask))) { \ 85 QDF_TRACE(QDF_MODULE_ID_DFS, level, ## args); \ 86 } \ 87 } while (0) 88 89 #define dfs_logfl(dfs, level, sm, format, args...) \ 90 dfs_log(dfs, sm, level, FLSM(format, sm), ## args) 91 92 #define dfs_alert(dfs, sm, format, args...) \ 93 dfs_logfl(dfs, QDF_TRACE_LEVEL_FATAL, sm, format, ## args) 94 95 #define dfs_err(dfs, sm, format, args...) \ 96 dfs_logfl(dfs, QDF_TRACE_LEVEL_ERROR, sm, format, ## args) 97 98 #define dfs_warn(dfs, sm, format, args...) \ 99 dfs_logfl(dfs, QDF_TRACE_LEVEL_WARN, sm, format, ## args) 100 101 #define dfs_info(dfs, sm, format, args...) \ 102 dfs_logfl(dfs, QDF_TRACE_LEVEL_INFO, sm, format, ## args) 103 104 #define dfs_debug(dfs, sm, format, args...) \ 105 dfs_logfl(dfs, QDF_TRACE_LEVEL_DEBUG, sm, format, ## args) 106 107 #define DFS_MIN(a, b) ((a) < (b)?(a):(b)) 108 #define DFS_MAX(a, b) ((a) > (b)?(a) : (b)) 109 #define DFS_DIFF(a, b)(DFS_MAX(a, b) - DFS_MIN(a, b)) 110 111 /* 112 * Maximum number of radar events to be processed in a single iteration. 113 * Allows soft watchdog to run. 114 */ 115 #define MAX_EVENTS 100 116 117 /* 118 * Constants to use for chirping detection. 119 * 120 * All are unconverted as HW reports them. 121 * 122 * XXX Are these constants with or without fast clock 5GHz operation? 123 * XXX Peregrine reports pulses in microseconds, not hardware clocks! 124 */ 125 126 #define MAX_DUR_FOR_LOW_RSSI 4 127 128 /* 129 * Cascade has issue with reported duration especially when there is a 130 * crossover of chirp from one segment to another. It may report a value 131 * of duration that is well below 50us for a valid FCC type 5 chirping 132 * pulse. For now changing minimum duration as a work around. This will 133 * affect all chips but since we detect chirp with Merlin+, we may be OK 134 * for now. We need a more robust solution for this. 135 */ 136 #define MIN_BIN5_DUR_CAS 25 /* 50 * 1.25*/ 137 #define MIN_BIN5_DUR_MICROSEC_CAS 20 138 #define MIN_BIN5_DUR 63 /* 50 * 1.25*/ 139 #define MIN_BIN5_DUR_MICROSEC 50 140 #define MAYBE_BIN5_DUR 35 /* 28 * 1.25*/ 141 #define MAYBE_BIN5_DUR_MICROSEC 28 142 143 /* Conversion is already done using dfs->dur_multiplier */ 144 #define MAX_BIN5_DUR 145 /* use 145 for osprey */ 145 #define MAX_BIN5_DUR_MICROSEC 105 146 147 #define DFS_MARGIN_EQUAL(a, b, margin) ((DFS_DIFF(a, b)) <= margin) 148 #define DFS_MAX_STAGGERED_BURSTS 3 149 150 /* 151 * All filter thresholds in the radar filter tables are effective at a 50% 152 * channel loading. 153 */ 154 #define DFS_CHAN_LOADING_THRESH 50 155 #define DFS_EXT_CHAN_LOADING_THRESH 30 156 #define DFS_DEFAULT_PRI_MARGIN 6 157 #define DFS_DEFAULT_FIXEDPATTERN_PRI_MARGIN 4 158 159 #define WLAN_DFSQ_LOCK(_dfs) qdf_spin_lock_bh(&(_dfs)->dfs_radarqlock) 160 #define WLAN_DFSQ_UNLOCK(_dfs) qdf_spin_unlock_bh(&(_dfs)->dfs_radarqlock) 161 #define WLAN_DFSQ_LOCK_CREATE(_dfs) qdf_spinlock_create( \ 162 &(_dfs)->dfs_radarqlock) 163 #define WLAN_DFSQ_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \ 164 &(_dfs)->dfs_radarqlock) 165 166 #define WLAN_ARQ_LOCK(_dfs) qdf_spin_lock_bh(&(_dfs)->dfs_arqlock) 167 #define WLAN_ARQ_UNLOCK(_dfs) qdf_spin_unlock_bh(&(_dfs)->dfs_arqlock) 168 #define WLAN_ARQ_LOCK_CREATE(_dfs) qdf_spinlock_create(&(_dfs)->dfs_arqlock) 169 #define WLAN_ARQ_LOCK_DESTROY(_dfs) qdf_spinlock_destroy(&(_dfs)->dfs_arqlock) 170 171 #define WLAN_DFSEVENTQ_LOCK(_dfs) qdf_spin_lock_bh(&(_dfs)->dfs_eventqlock) 172 #define WLAN_DFSEVENTQ_UNLOCK(_dfs) qdf_spin_unlock_bh( \ 173 &(_dfs)->dfs_eventqlock) 174 #define WLAN_DFSEVENTQ_LOCK_CREATE(_dfs) qdf_spinlock_create( \ 175 &(_dfs)->dfs_eventqlock) 176 #define WLAN_DFSEVENTQ_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \ 177 &(_dfs)->dfs_eventqlock) 178 179 #define WLAN_DFSNOL_LOCK(_dfs) qdf_spin_lock_bh(&(_dfs)->dfs_nol_lock) 180 #define WLAN_DFSNOL_UNLOCK(_dfs) qdf_spin_unlock_bh(&(_dfs)->dfs_nol_lock) 181 #define WLAN_DFSNOL_LOCK_CREATE(_dfs) qdf_spinlock_create( \ 182 &(_dfs)->dfs_nol_lock) 183 #define WLAN_DFSNOL_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \ 184 &(_dfs)->dfs_nol_lock) 185 186 #define PRECAC_LIST_LOCK(_dfs) qdf_spin_lock_irqsave( \ 187 &(_dfs)->dfs_precac_lock) 188 #define PRECAC_LIST_UNLOCK(_dfs) qdf_spin_unlock_irqrestore( \ 189 &(_dfs)->dfs_precac_lock) 190 #define PRECAC_LIST_LOCK_CREATE(_dfs) qdf_spinlock_create( \ 191 &(_dfs)->dfs_precac_lock) 192 #define PRECAC_LIST_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \ 193 &(_dfs)->dfs_precac_lock) 194 195 #define WLAN_DFS_DATA_STRUCT_LOCK(_dfs) \ 196 qdf_spin_lock_bh(&(_dfs)->dfs_data_struct_lock) 197 #define WLAN_DFS_DATA_STRUCT_UNLOCK(_dfs) \ 198 qdf_spin_unlock_bh(&(_dfs)->dfs_data_struct_lock) 199 #define WLAN_DFS_DATA_STRUCT_LOCK_CREATE(_dfs) \ 200 qdf_spinlock_create(&(_dfs)->dfs_data_struct_lock) 201 #define WLAN_DFS_DATA_STRUCT_LOCK_DESTROY(_dfs) \ 202 qdf_spinlock_destroy(&(_dfs)->dfs_data_struct_lock) 203 204 /* Wrappers to call MLME radar during mode switch lock. */ 205 #define DFS_RADAR_MODE_SWITCH_LOCK(_dfs) \ 206 dfs_mlme_acquire_radar_mode_switch_lock((_dfs)->dfs_pdev_obj) 207 #define DFS_RADAR_MODE_SWITCH_UNLOCK(_dfs) \ 208 dfs_mlme_release_radar_mode_switch_lock((_dfs)->dfs_pdev_obj) 209 210 /* Mask for time stamp from descriptor */ 211 #define DFS_TSMASK 0xFFFFFFFF 212 /* Shift for time stamp from descriptor */ 213 #define DFS_TSSHIFT 32 214 /* 64 bit TSF wrap value */ 215 #define DFS_TSF_WRAP 0xFFFFFFFFFFFFFFFFULL 216 /* TS mask for 64 bit value */ 217 #define DFS_64BIT_TSFMASK 0x0000000000007FFFULL 218 219 #define DFS_AR_RADAR_RSSI_THR 5 /* in dB */ 220 #define DFS_AR_RADAR_RESET_INT 1 /* in secs */ 221 #define DFS_AR_RADAR_MAX_HISTORY 500 222 #define DFS_AR_REGION_WIDTH 128 223 #define DFS_AR_RSSI_THRESH_STRONG_PKTS 17 /* in dB */ 224 #define DFS_AR_RSSI_DOUBLE_THRESHOLD 15 /* in dB */ 225 #define DFS_AR_MAX_NUM_ACK_REGIONS 9 226 #define DFS_AR_ACK_DETECT_PAR_THRESH 20 227 #define DFS_AR_PKT_COUNT_THRESH 20 228 229 #define DFS_MAX_DL_SIZE 64 230 #define DFS_MAX_DL_MASK 0x3F 231 232 #define DFS_NOL_TIME DFS_NOL_TIMEOUT_US 233 /* 30 minutes in usecs */ 234 235 #define DFS_WAIT_TIME (60*1000000) /* 1 minute in usecs */ 236 237 #define DFS_DISABLE_TIME (3*60*1000000) /* 3 minutes in usecs */ 238 239 #define DFS_MAX_B5_SIZE 128 240 #define DFS_MAX_B5_MASK 0x0000007F /* 128 */ 241 242 /* Max number of overlapping filters */ 243 #define DFS_MAX_RADAR_OVERLAP 16 244 245 /* Max number of dfs events which can be q'd */ 246 #define DFS_MAX_EVENTS 1024 247 248 #define DFS_RADAR_EN 0x80000000 /* Radar detect is capable */ 249 #define DFS_AR_EN 0x40000000 /* AR detect is capable */ 250 /* Radar detect in second segment is capable */ 251 #define DFS_SECOND_SEGMENT_RADAR_EN 0x20000000 252 #define DFS_MAX_RSSI_VALUE 0x7fffffff /* Max rssi value */ 253 254 #define DFS_BIN_MAX_PULSES 60 /* max num of pulses in a burst */ 255 #define DFS_BIN5_PRI_LOWER_LIMIT 990 /* us */ 256 257 /* 258 * To cover the single pusle burst case, change from 2010 us to 259 * 2010000 us. 260 */ 261 262 /* 263 * This is reverted back to 2010 as larger value causes false 264 * bin5 detect (EV76432, EV76320) 265 */ 266 #define DFS_BIN5_PRI_HIGHER_LIMIT 2010 /* us */ 267 268 #define DFS_BIN5_WIDTH_MARGIN 4 /* us */ 269 #define DFS_BIN5_RSSI_MARGIN 5 /* dBm */ 270 271 /* 272 * Following threshold is not specified but should be 273 * okay statistically. 274 */ 275 #define DFS_BIN5_BRI_LOWER_LIMIT 300000 /* us */ 276 #define DFS_BIN5_BRI_UPPER_LIMIT 12000000 /* us */ 277 278 /* Max number of pulses kept in buffer */ 279 #define DFS_MAX_PULSE_BUFFER_SIZE 1024 280 #define DFS_MAX_PULSE_BUFFER_MASK 0x3ff 281 282 #define DFS_FAST_CLOCK_MULTIPLIER (800/11) 283 #define DFS_NO_FAST_CLOCK_MULTIPLIER (80) 284 #define DFS_BIG_SIDX 10000 285 286 /* Min value of valid psidx diff */ 287 #define DFS_MIN_PSIDX_DIFF 4 288 /* Max value of valid psidx diff */ 289 #define DFS_MAX_PSIDX_DIFF 16 290 291 /* 292 * Software use: channel interference used for as AR as well as RADAR 293 * interference detection. 294 */ 295 #define CHANNEL_INTERFERENCE 0x01 296 297 /* qdf_packed - denotes structure is packed. */ 298 #define qdf_packed __qdf_packed 299 300 #define SEG_ID_PRIMARY 0 301 #define SEG_ID_SECONDARY 1 302 303 /* MIN and MAX width for different regions */ 304 #define REG0_MIN_WIDTH 33 305 #define REG0_MAX_WIDTH 38 306 #define REG1_MIN_WIDTH 39 307 #define REG1_MAX_WIDTH 44 308 #define REG2_MIN_WIDTH 53 309 #define REG2_MAX_WIDTH 58 310 #define REG3_MIN_WIDTH 126 311 #define REG3_MAX_WIDTH 140 312 #define REG4_MIN_WIDTH 141 313 #define REG4_MAX_WIDTH 160 314 #define REG5_MIN_WIDTH 189 315 #define REG5_MAX_WIDTH 210 316 #define REG6_MIN_WIDTH 360 317 #define REG6_MAX_WIDTH 380 318 #define REG7_MIN_WIDTH 257 319 #define REG7_MAX_WIDTH 270 320 #define REG8_MIN_WIDTH 295 321 #define REG8_MAX_WIDTH 302 322 323 #define OVER_SAMPLING_FREQ 44000 324 #define SAMPLING_FREQ 40000 325 #define HUNDRED 100 326 #define NUM_BINS 128 327 #define THOUSAND 1000 328 329 /* Array offset to ETSI legacy pulse */ 330 #define ETSI_LEGACY_PULSE_ARR_OFFSET 4 331 332 #define ETSI_RADAR_EN302_502_FREQ_LOWER 5725 333 #define ETSI_RADAR_EN302_502_FREQ_UPPER 5865 334 335 #define DFS_NOL_ADD_CHAN_LOCKED(dfs, freq, timeout) \ 336 do { \ 337 WLAN_DFSNOL_LOCK(dfs); \ 338 dfs_nol_addchan(dfs, freq, timeout); \ 339 WLAN_DFSNOL_UNLOCK(dfs); \ 340 } while (0) 341 342 /* 343 * Free the NOL element in a thread. This is to avoid freeing the 344 * timer object from within timer callback function . The nol element 345 * contains the timer Object. 346 */ 347 #define DFS_NOL_DELETE_CHAN_LOCKED(dfs, freq, chwidth) \ 348 do { \ 349 WLAN_DFSNOL_LOCK(dfs); \ 350 dfs_nol_delete(dfs, freq, chwidth); \ 351 qdf_sched_work(NULL, &dfs->dfs_nol_elem_free_work); \ 352 WLAN_DFSNOL_UNLOCK(dfs); \ 353 } while (0) 354 355 #define DFS_GET_NOL_LOCKED(dfs, dfs_nol, nchan) \ 356 do { \ 357 WLAN_DFSNOL_LOCK(dfs); \ 358 dfs_get_nol(dfs, dfs_nol, nchan); \ 359 WLAN_DFSNOL_UNLOCK(dfs); \ 360 } while (0) 361 362 #define DFS_PRINT_NOL_LOCKED(dfs) \ 363 do { \ 364 WLAN_DFSNOL_LOCK(dfs); \ 365 dfs_print_nol(dfs); \ 366 WLAN_DFSNOL_UNLOCK(dfs); \ 367 } while (0) 368 369 #define DFS_NOL_FREE_LIST_LOCKED(dfs) \ 370 do { \ 371 WLAN_DFSNOL_LOCK(dfs); \ 372 dfs_nol_free_list(dfs); \ 373 WLAN_DFSNOL_UNLOCK(dfs); \ 374 } while (0) 375 376 /* Host sends the average parameters of the radar pulses and starts the status 377 * wait timer with this timeout. 378 */ 379 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 380 #define HOST_DFS_STATUS_WAIT_TIMER_MS 350 381 #endif 382 383 /* 384 * USENOL_DISABLE_NOL_HOST_AND_FW : Do not add radar hit channel to NOL 385 * in host and FW. Enable CSA on the same channel. 386 */ 387 #define USENOL_DISABLE_NOL_HOST_AND_FW 0 388 /* 389 * USENOL_ENABLE_NOL_HOST_AND_FW : Add the radar hit channel to NOL in 390 * host and FW (in case of FO). NOL timer cannot be configured by the user 391 * as FW does not allow manipulating NOL timeout. If noltimeout is configured, 392 * (say 1 min) FW will not be intimated about the configuration and hence NOL 393 * timer may elapse at different instances in host (after 1 min) and FW (after 394 * default 30 min) which could lead to DFS Violation if host tries to come up 395 * on the channel after host NOL timeout (of 1 min) as the FW would still 396 * have the channel in NOL list. 397 */ 398 #define USENOL_ENABLE_NOL_HOST_AND_FW 1 399 /* 400 * USENOL_ENABLE_NOL_HOST_DISABLE_NOL_FW : Add the radar hit channel to NOL 401 * in host. NOL timer can be configured by user. NOL in FW (for FO) is disabled. 402 */ 403 #define USENOL_ENABLE_NOL_HOST_DISABLE_NOL_FW 2 404 405 /** 406 * enum detector_id - Detector ID values. 407 * @DETECTOR_ID_0: Detector ID 0 (Non Agile). 408 * @DETECTOR_ID_1: Detector ID 1 (Non Agile in 80p80MHz supported devices, 409 * Agile detector in true 160MHz supported devices). 410 * @DETECTOR_ID_2: Detector ID 2 (Agile detector in 80p80MHZ supported devices). 411 * @AGILE_DETECTOR_ID_TRUE_160MHZ: Agile detector ID in true 160MHz devices. 412 * @AGILE_DETECTOR_11BE: Agile detector ID in true 320 MHz devices. 413 * @AGILE_DETECTOR_ID_80P80: Agile detector ID in 80p80MHz supported devices. 414 * @INVALID_DETECTOR_ID: Invalid detector id. 415 */ 416 enum detector_id { 417 DETECTOR_ID_0, 418 DETECTOR_ID_1, 419 DETECTOR_ID_2, 420 AGILE_DETECTOR_ID_TRUE_160MHZ = DETECTOR_ID_1, 421 AGILE_DETECTOR_11BE = DETECTOR_ID_1, 422 AGILE_DETECTOR_ID_80P80 = DETECTOR_ID_2, 423 INVALID_DETECTOR_ID, 424 }; 425 426 /** 427 * struct dfs_pulseparams - DFS pulse param structure. 428 * @p_time: Time for start of pulse in usecs. 429 * @p_dur: Duration of pulse in usecs. 430 * @p_rssi: RSSI of pulse. 431 * @p_seg_id: Segment id. 432 * @p_sidx: Sidx value. 433 * @p_delta_peak: Delta peak value. 434 * @p_psidx_diff: The difference in the FFT peak index between the short FFT 435 * and the first long FFT. 436 * @p_seq_num: Sequence number. 437 */ 438 struct dfs_pulseparams { 439 uint64_t p_time; 440 uint8_t p_dur; 441 uint8_t p_rssi; 442 uint8_t p_seg_id; 443 int16_t p_sidx; 444 int8_t p_delta_peak; 445 int16_t p_psidx_diff; 446 uint32_t p_seq_num; 447 } qdf_packed; 448 449 /** 450 * struct dfs_pulseline - Pulseline structure. 451 * @pl_elems: array of pulses in delay line. 452 * @pl_firstelem: Index of the first element. 453 * @pl_lastelem: Index of the last element. 454 * @pl_numelems: Number of elements in the delay line. 455 */ 456 struct dfs_pulseline { 457 struct dfs_pulseparams pl_elems[DFS_MAX_PULSE_BUFFER_SIZE]; 458 uint32_t pl_firstelem; 459 uint32_t pl_lastelem; 460 uint32_t pl_numelems; 461 } qdf_packed; 462 463 #define DFS_EVENT_CHECKCHIRP 0x01 /* Whether to check the chirp flag */ 464 #define DFS_EVENT_HW_CHIRP 0x02 /* hardware chirp */ 465 #define DFS_EVENT_SW_CHIRP 0x04 /* software chirp */ 466 /* Whether the event contains valid psidx diff value*/ 467 #define DFS_EVENT_VALID_PSIDX_DIFF 0x08 468 469 /* Use this only if the event has CHECKCHIRP set. */ 470 #define DFS_EVENT_ISCHIRP(e) \ 471 ((e)->re_flags & (DFS_EVENT_HW_CHIRP | DFS_EVENT_SW_CHIRP)) 472 473 /** 474 * DFS_EVENT_NOTCHIRP() - Check if event can be a chirp 475 * @e: event 476 * 477 * Check if the given event is to be rejected as not possibly 478 * a chirp. This means: 479 * (a) it's a hardware or software checked chirp, and 480 * (b) the HW/SW chirp bits are both 0. 481 */ 482 #define DFS_EVENT_NOTCHIRP(e) \ 483 (((e)->re_flags & (DFS_EVENT_CHECKCHIRP)) && (!DFS_EVENT_ISCHIRP((e)))) 484 485 /** 486 * struct dfs_event - DFS event structure. 487 * @re_full_ts: 64-bit full timestamp from interrupt time. 488 * @re_ts: Original 15 bit recv timestamp. 489 * @re_rssi: Rssi of radar event. 490 * @re_dur: Duration of radar pulse. 491 * @re_chanindex: Channel of event. 492 * @re_flags: Event flags. 493 * @re_freq: Centre frequency of event, KHz. 494 * @re_freq_lo: Lower bounds of frequency, KHz. 495 * @re_freq_hi: Upper bounds of frequency, KHz. 496 * @re_seg_id: HT80_80/HT160 use. 497 * @re_sidx: Seg index. 498 * @re_freq_offset_khz: Freq offset in KHz 499 * @re_peak_mag: Peak mag. 500 * @re_total_gain: Total gain. 501 * @re_mb_gain: Mb gain. 502 * @re_relpwr_db: Relpower in db. 503 * @re_delta_diff: Delta diff. 504 * @re_delta_peak: Delta peak. 505 * @re_psidx_diff: Psidx diff. 506 * @re_list: List of radar events. 507 */ 508 struct dfs_event { 509 uint64_t re_full_ts; 510 uint32_t re_ts; 511 uint8_t re_rssi; 512 uint8_t re_dur; 513 uint8_t re_chanindex; 514 uint8_t re_flags; 515 uint32_t re_freq; 516 uint32_t re_freq_lo; 517 uint32_t re_freq_hi; 518 uint8_t re_seg_id; 519 int re_sidx; 520 u_int re_freq_offset_khz; 521 int re_peak_mag; 522 int re_total_gain; 523 int re_mb_gain; 524 int re_relpwr_db; 525 uint8_t re_delta_diff; 526 int8_t re_delta_peak; 527 int16_t re_psidx_diff; 528 529 STAILQ_ENTRY(dfs_event) re_list; 530 } qdf_packed; 531 532 #define DFS_AR_MAX_ACK_RADAR_DUR 511 533 #define DFS_AR_MAX_NUM_PEAKS 3 534 #define DFS_AR_ARQ_SIZE 2048 /* 8K AR events for buffer size */ 535 #define DFS_AR_ARQ_SEQSIZE 2049 /* Sequence counter wrap for AR */ 536 537 #define DFS_RADARQ_SIZE 512 /* 1K radar events for buffer size */ 538 #define DFS_RADARQ_SEQSIZE 513 /* Sequence counter wrap for radar */ 539 /* Number of radar channels we keep state for */ 540 #define DFS_NUM_RADAR_STATES 64 541 /* Max number radar filters for each type */ 542 #define DFS_MAX_NUM_RADAR_FILTERS 10 543 /* Number of different radar types */ 544 #define DFS_MAX_RADAR_TYPES 32 545 /* Number of filter index table rows */ 546 #define DFS_NUM_FT_IDX_TBL_ROWS 256 547 548 /* RADAR filter pattern type 1*/ 549 #define WLAN_DFS_RF_PATTERN_TYPE_1 1 550 551 /** 552 * struct dfs_ar_state - DFS AR state structure. 553 * @ar_prevwidth: Previous width. 554 * @ar_phyerrcount: Phy error count. 555 * @ar_acksum: Acksum. 556 * @ar_packetthreshold: Thresh to determine traffic load. 557 * @ar_parthreshold: Thresh to determine peak. 558 * @ar_radarrssi: Rssi threshold for AR event. 559 * @ar_prevtimestamp: Prev time stamp. 560 * @ar_peaklist: Peak list. 561 */ 562 struct dfs_ar_state { 563 uint32_t ar_prevwidth; 564 uint32_t ar_phyerrcount[DFS_AR_MAX_ACK_RADAR_DUR]; 565 uint32_t ar_acksum; 566 uint32_t ar_packetthreshold; 567 uint32_t ar_parthreshold; 568 uint32_t ar_radarrssi; 569 uint16_t ar_prevtimestamp; 570 uint16_t ar_peaklist[DFS_AR_MAX_NUM_PEAKS]; 571 }; 572 573 /** 574 * struct dfs_delayelem - Delay Element. 575 * @de_time: Current "filter" time for start of pulse in usecs. 576 * @de_dur: Duration of pulse in usecs. 577 * @de_rssi: Rssi of pulse in dB. 578 * @de_ts: Time stamp for this delay element. 579 * @de_seg_id: Segment id for HT80_80/HT160 use. 580 * @de_sidx: Sidx value. 581 * @de_delta_peak: Delta peak. 582 * @de_psidx_diff: Psidx diff. 583 * @de_seq_num: Sequence number. 584 */ 585 struct dfs_delayelem { 586 uint32_t de_time; 587 uint8_t de_dur; 588 uint8_t de_rssi; 589 uint64_t de_ts; 590 uint8_t de_seg_id; 591 int16_t de_sidx; 592 int8_t de_delta_peak; 593 int16_t de_psidx_diff; 594 uint32_t de_seq_num; 595 } qdf_packed; 596 597 /** 598 * struct dfs_delayline - DFS Delay Line. 599 * @dl_elems: Array of pulses in delay line. 600 * @dl_last_ts: Last timestamp the delay line was used (in usecs). 601 * @dl_firstelem: Index of the first element. 602 * @dl_lastelem: Index of the last element. 603 * @dl_numelems: Number of elements in the delay line. 604 * The following is to handle fractional PRI pulses that can cause false 605 * detection. 606 * @dl_seq_num_start: Sequence number of first pulse that was part of 607 * threshold match. 608 * @dl_seq_num_stop: Sequence number of last pulse that was part of threshold 609 * match. 610 * The following is required because the first pulse may or may not be in the 611 * delay line but we will find it iin the pulse line using dl_seq_num_second's 612 * diff_ts value. 613 * @dl_seq_num_second: Sequence number of second pulse that was part of 614 * threshold match. 615 * @dl_search_pri: We need final search PRI to identify possible fractional 616 * PRI issue. 617 * @dl_min_sidx: Minimum sidx value of pulses used to match thershold. 618 * Used for sidx spread check. 619 * @dl_max_sidx: Maximum sidx value of pulses used to match thershold. 620 * Used for sidx spread check. 621 * @dl_delta_peak_match_count: Number of pulse in the delay line that had valid 622 * delta peak value. 623 * @dl_psidx_diff_match_count: Number of pulse in the delay line that had valid 624 * psidx diff value. 625 */ 626 struct dfs_delayline { 627 struct dfs_delayelem dl_elems[DFS_MAX_DL_SIZE]; 628 uint64_t dl_last_ts; 629 uint32_t dl_firstelem; 630 uint32_t dl_lastelem; 631 uint32_t dl_numelems; 632 uint32_t dl_seq_num_start; 633 uint32_t dl_seq_num_stop; 634 uint32_t dl_seq_num_second; 635 uint32_t dl_search_pri; 636 int16_t dl_min_sidx; 637 int8_t dl_max_sidx; 638 uint8_t dl_delta_peak_match_count; 639 uint8_t dl_psidx_diff_match_count; 640 } qdf_packed; 641 642 /** 643 * struct dfs_filter - Dfs filter. 644 * @rf_dl: Delay line of pulses for this filter. 645 * @rf_numpulses: Number of pulses in the filter. 646 * @rf_minpri: Min pri to be considered for this filter. 647 * @rf_maxpri: Max pri to be considered for this filter. 648 * @rf_threshold: Match filter output threshold for radar detect. 649 * @rf_filterlen: Length (in usecs) of the filter. 650 * @rf_patterntype: Fixed or variable pattern type. 651 * @rf_fixed_pri_radar_pulse: indicates if it is a fixed pri pulse. 652 * @rf_mindur: Min duration for this radar filter. 653 * @rf_maxdur: Max duration for this radar filter. 654 * @rf_ignore_pri_window: Ignore pri window. 655 * @rf_pulseid: Unique ID corresponding to the original filter ID. 656 * To reduce false detection, look at frequency spread. For now we will use 657 * sidx spread. But for HT160 frequency spread will be a better measure. 658 * @rf_sidx_spread: Maximum SIDX value spread in a matched sequence 659 * excluding FCC Bin 5. 660 * @rf_check_delta_peak: Minimum allowed delta_peak value for a pulse to be 661 * considetred for this filter's match. 662 */ 663 struct dfs_filter { 664 struct dfs_delayline rf_dl; 665 uint32_t rf_numpulses; 666 uint32_t rf_minpri; 667 uint32_t rf_maxpri; 668 uint32_t rf_threshold; 669 uint32_t rf_filterlen; 670 uint32_t rf_patterntype; 671 uint32_t rf_fixed_pri_radar_pulse; 672 uint32_t rf_mindur; 673 uint32_t rf_maxdur; 674 uint32_t rf_ignore_pri_window; 675 uint32_t rf_pulseid; 676 uint16_t rf_sidx_spread; 677 int8_t rf_check_delta_peak; 678 } qdf_packed; 679 680 /** 681 * struct dfs_filtertype - Structure of DFS Filter type. 682 * @ft_filters: Array of ptrs storing addresses for struct of dfs_filter. 683 * @ft_filterdur: Duration of pulse which specifies filter type. 684 * @ft_numfilters: Num filters of this type. 685 * @ft_last_ts: Last timestamp this filtertype was used (in usecs). 686 * @ft_mindur: Min pulse duration to be considered for this filter type. 687 * @ft_maxdur: Max pulse duration to be considered for this filter type. 688 * @ft_rssithresh: Min rssi to be considered for this filter type. 689 * @ft_numpulses: Num pulses in each filter of this type. 690 * @ft_patterntype: Fixed or variable pattern type. 691 * @ft_minpri: Min pri to be considered for this type. 692 * @ft_rssimargin: Rssi threshold margin. In Turbo Mode HW reports rssi 3dB 693 * lower than in non TURBO mode. This will offset that diff. 694 */ 695 struct dfs_filtertype { 696 struct dfs_filter *ft_filters[DFS_MAX_NUM_RADAR_FILTERS]; 697 uint32_t ft_filterdur; 698 uint32_t ft_numfilters; 699 uint64_t ft_last_ts; 700 uint32_t ft_mindur; 701 uint32_t ft_maxdur; 702 uint32_t ft_rssithresh; 703 uint32_t ft_numpulses; 704 uint32_t ft_patterntype; 705 uint32_t ft_minpri; 706 uint32_t ft_rssimargin; 707 }; 708 709 /** 710 * struct dfs_channel - Channel structure for dfs component. 711 * @dfs_ch_freq: Frequency in Mhz. 712 * @dfs_ch_flags: Channel flags. 713 * @dfs_ch_flagext: Extended channel flags. 714 * @dfs_ch_ieee: IEEE channel number. 715 * @dfs_ch_vhtop_ch_freq_seg1: IEEE Channel Center of primary segment 716 * @dfs_ch_vhtop_ch_freq_seg2: IEEE Channel Center applicable for 80+80MHz 717 * mode of operation. 718 * @dfs_ch_mhz_freq_seg1: Channel center frequency of primary segment in 719 * MHZ. 720 * @dfs_ch_mhz_freq_seg2: Channel center frequency of secondary segment 721 * in MHZ applicable only for 80+80MHZ mode of 722 * operation. 723 * @dfs_ch_punc_pattern: Bitmap representing puncturing patterns. 724 */ 725 struct dfs_channel { 726 uint16_t dfs_ch_freq; 727 uint64_t dfs_ch_flags; 728 uint16_t dfs_ch_flagext; 729 uint8_t dfs_ch_ieee; 730 uint8_t dfs_ch_vhtop_ch_freq_seg1; 731 uint8_t dfs_ch_vhtop_ch_freq_seg2; 732 uint16_t dfs_ch_mhz_freq_seg1; 733 uint16_t dfs_ch_mhz_freq_seg2; 734 #ifdef WLAN_FEATURE_11BE 735 /* If the bitmap is all 0 then nothing is punctured. If any bit is 1 736 * then corresponding 20MHz sub-channel is puntured. For example, for 737 * channel 100 (BW 240MHz), it will treated as a 320MHz channel and the 738 * bit-map will be b1111_0000_0000_0000 (where the most significant bit 739 * indicates the rightmost sub20channel and the least significant bit 740 * indicates the leftmost sub20channel). 741 */ 742 uint16_t dfs_ch_punc_pattern; 743 #endif 744 }; 745 746 /** 747 * struct dfs_state - DFS state. 748 * @rs_chan: Channel info. 749 * @rs_chanindex: Channel index in radar structure. 750 * @rs_numradarevents: Number of radar events. 751 * @rs_param: Phy param. 752 */ 753 struct dfs_state { 754 struct dfs_channel rs_chan; 755 uint8_t rs_chanindex; 756 uint32_t rs_numradarevents; 757 struct wlan_dfs_phyerr_param rs_param; 758 }; 759 760 #define DFS_NOL_TIMEOUT_S (30*60) /* 30 minutes in seconds */ 761 #define DFS_NOL_TIMEOUT_MS (DFS_NOL_TIMEOUT_S * 1000) 762 #define DFS_NOL_TIMEOUT_US (DFS_NOL_TIMEOUT_MS * 1000) 763 764 /** 765 * struct dfs_nolelem - DFS NOL element. 766 * @nolelem_list: NOL element list node 767 * @nol_dfs: Back pointer to dfs object. 768 * @nol_freq: Centre frequency. 769 * @nol_chwidth: Event width (MHz). 770 * @nol_start_us: NOL start time in us. 771 * @nol_timeout_ms: NOL timeout value in msec. 772 * @nol_timer: Per element NOL timer. 773 * @nol_next: Next element pointer. 774 */ 775 struct dfs_nolelem { 776 TAILQ_ENTRY(dfs_nolelem) nolelem_list; 777 struct wlan_dfs *nol_dfs; 778 uint32_t nol_freq; 779 uint32_t nol_chwidth; 780 uint64_t nol_start_us; 781 uint32_t nol_timeout_ms; 782 qdf_hrtimer_data_t nol_timer; 783 struct dfs_nolelem *nol_next; 784 }; 785 786 787 /** 788 * struct dfs_info - DFS Info. 789 * @rn_ftindex: Number of different types of radars. 790 * @rn_lastfull_ts: Last 64 bit timstamp from recv interrupt. 791 * @rn_last_ts: last 15 bit ts from recv descriptor. 792 * @rn_last_unique_ts: last unique 32 bit ts from recv descriptor. 793 * @rn_ts_prefix: Prefix to prepend to 15 bit recv ts. 794 * @rn_numbin5radars: Number of bin5 radar pulses to search for. 795 * @rn_fastdivGCval: Value of fast diversity gc limit from init file. 796 * @rn_minrssithresh: Min rssi for all radar types. 797 * @rn_maxpulsedur: Max pulse width in TSF ticks. 798 * @dfs_ext_chan_busy: Ext chan busy. 799 * @ext_chan_busy_ts: Ext chan busy time. 800 * @dfs_bin5_chirp_ts: Ext bin5 chrip time. 801 * @dfs_last_bin5_dur: Last bin5 during. 802 */ 803 struct dfs_info { 804 uint32_t rn_ftindex; 805 uint64_t rn_lastfull_ts; 806 uint16_t rn_last_ts; 807 uint32_t rn_last_unique_ts; 808 uint64_t rn_ts_prefix; 809 uint32_t rn_numbin5radars; 810 uint32_t rn_fastdivGCval; 811 int32_t rn_minrssithresh; 812 uint32_t rn_maxpulsedur; 813 uint8_t dfs_ext_chan_busy; 814 uint64_t ext_chan_busy_ts; 815 uint64_t dfs_bin5_chirp_ts; 816 uint8_t dfs_last_bin5_dur; 817 } qdf_packed; 818 819 /** 820 * struct dfs_bin5elem - BIN5 elements. 821 * @be_ts: Timestamp for the bin5 element. 822 * @be_rssi: Rssi for the bin5 element. 823 * @be_dur: Duration of bin5 element. 824 */ 825 struct dfs_bin5elem { 826 uint64_t be_ts; 827 uint32_t be_rssi; 828 uint32_t be_dur; 829 }; 830 831 /** 832 * struct dfs_bin5radars - BIN5 radars. 833 * @br_elems: List of bin5 elems that fall within the time window. 834 * @br_firstelem: Index of the first element. 835 * @br_lastelem: Index of the last element. 836 * @br_numelems: Number of elements in the delay line. 837 * @br_pulse: Original info about bin5 pulse. 838 */ 839 struct dfs_bin5radars { 840 struct dfs_bin5elem br_elems[DFS_MAX_B5_SIZE]; 841 uint32_t br_firstelem; 842 uint32_t br_lastelem; 843 uint32_t br_numelems; 844 struct dfs_bin5pulse br_pulse; 845 }; 846 847 /** 848 * struct dfs_stats - DFS stats. 849 * @num_radar_detects: Total num. of radar detects. 850 * @num_seg_two_radar_detects: Total num. of radar detected in secondary segment 851 * @total_phy_errors: Total PHY errors. 852 * @owl_phy_errors: OWL PHY errors. 853 * @pri_phy_errors: Primary channel phy errors. 854 * @ext_phy_errors: Extension channel phy errors. 855 * @dc_phy_errors: DC PHY errors. 856 * @early_ext_phy_errors: Extension channel early radar found error. 857 * @bwinfo_errors: Bogus bandwidth info received in descriptor. 858 * @datalen_discards: data length at least three bytes of payload. 859 * @rssi_discards: RSSI is not accurate. 860 * @last_reset_tstamp: Last reset timestamp. 861 */ 862 struct dfs_stats { 863 uint32_t num_radar_detects; 864 uint32_t num_seg_two_radar_detects; 865 uint32_t total_phy_errors; 866 uint32_t owl_phy_errors; 867 uint32_t pri_phy_errors; 868 uint32_t ext_phy_errors; 869 uint32_t dc_phy_errors; 870 uint32_t early_ext_phy_errors; 871 uint32_t bwinfo_errors; 872 uint32_t datalen_discards; 873 uint32_t rssi_discards; 874 uint64_t last_reset_tstamp; 875 }; 876 877 #define DFS_EVENT_LOG_SIZE 256 878 879 /** 880 * struct dfs_event_log - DFS event log. 881 * @ts: 64-bit full timestamp from interrupt time. 882 * @diff_ts: Diff timestamp. 883 * @rssi: Rssi of radar event. 884 * @dur: Duration of radar pulse. 885 * @is_chirp: Chirp flag. 886 * @seg_id: HT80_80/HT160 use. 887 * @sidx: Seg index. 888 * @freq_offset_khz: Freq offset in KHz 889 * @peak_mag: Peak mag. 890 * @total_gain: Total gain. 891 * @mb_gain: Mb gain. 892 * @relpwr_db: Relpower in db. 893 * @delta_diff: Delta diff. 894 * @delta_peak: Delta peak. 895 * @psidx_diff: Psidx diff. 896 */ 897 898 struct dfs_event_log { 899 uint64_t ts; 900 uint32_t diff_ts; 901 uint8_t rssi; 902 uint8_t dur; 903 int is_chirp; 904 uint8_t seg_id; 905 int sidx; 906 u_int freq_offset_khz; 907 int peak_mag; 908 int total_gain; 909 int mb_gain; 910 int relpwr_db; 911 uint8_t delta_diff; 912 int8_t delta_peak; 913 int16_t psidx_diff; 914 }; 915 916 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN 10 /*10 minutes*/ 917 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_S (WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN * 60) 918 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MS \ 919 ((WLAN_DFS_WEATHER_CHANNEL_WAIT_S) * 1000) /*in MS*/ 920 921 #define WLAN_DFS_WAIT_POLL_PERIOD 2 /* 2 seconds */ 922 #define WLAN_DFS_WAIT_POLL_PERIOD_MS \ 923 ((WLAN_DFS_WAIT_POLL_PERIOD) * 1000) /*in MS*/ 924 925 #define DFS_DEBUG_TIMEOUT_S 30 /* debug timeout is 30 seconds */ 926 #define DFS_DEBUG_TIMEOUT_MS (DFS_DEBUG_TIMEOUT_S * 1000) 927 928 #define RSSI_POSSIBLY_FALSE 50 929 #define SEARCH_FFT_REPORT_PEAK_MAG_THRSH 40 930 931 #define MIN_DFS_SUBCHAN_BW 20 /* Minimum bandwidth of each subchannel. */ 932 933 #define FREQ_OFFSET_BOUNDARY_FOR_80MHZ 40 934 935 #define FREQ_OFFSET_BOUNDARY_FOR_160MHZ 80 936 937 /** 938 * struct dfs_mode_switch_defer_params - Parameters storing DFS information 939 * before defer, as part of HW mode switch. 940 * 941 * @radar_params: Deferred radar parameters. 942 * @is_cac_completed: Boolean representing CAC completion event. 943 * @is_radar_detected: Boolean representing radar event. 944 */ 945 struct dfs_mode_switch_defer_params { 946 struct radar_found_info *radar_params; 947 bool is_cac_completed; 948 bool is_radar_detected; 949 }; 950 951 #ifdef QCA_SUPPORT_AGILE_DFS 952 #define DFS_PSOC_NO_IDX 0xFF 953 /** 954 * enum dfs_agile_sm_state - DFS AGILE SM states. 955 * @DFS_AGILE_S_INIT: Default state or the start state of the Agile SM. 956 * @DFS_AGILE_S_RUNNING: Agile Engine is being run. 957 * @DFS_AGILE_S_COMPLETE: The Agile Engine's minimum run is complete. 958 * However, it is still running. Used only for RCAC 959 * as RCAC needs to run continuously (uninterrupted) 960 * until the channel change. 961 * @DFS_AGILE_S_MAX: Max (invalid) state. 962 */ 963 enum dfs_agile_sm_state { 964 DFS_AGILE_S_INIT, 965 DFS_AGILE_S_RUNNING, 966 DFS_AGILE_S_COMPLETE, 967 DFS_AGILE_S_MAX, 968 }; 969 970 /** 971 * struct dfs_rcac_params - DFS Rolling CAC channel parameters. 972 * @rcac_pri_freq: Rolling CAC channel's primary frequency. 973 * @rcac_ch_params: Rolling CAC channel parameters. 974 */ 975 struct dfs_rcac_params { 976 qdf_freq_t rcac_pri_freq; 977 struct ch_params rcac_ch_params; 978 }; 979 #endif 980 981 /* 982 * NB: not using kernel-doc format since the kernel-doc script doesn't 983 * handle the TAILQ_HEAD() or STAILQ_HEAD() macros 984 * 985 * struct wlan_dfs - The main dfs structure. 986 * @dfs_debug_mask: Current debug bitmask. 987 * @dfs_curchan_radindex: Current channel radar index. 988 * @dfs_extchan_radindex: Extension channel radar index. 989 * @dfs_ar_state: AR state. 990 * @dfs_radar: Per-Channel Radar detector state. 991 * @dfs_radarf: One filter for each radar pulse type. 992 * @dfs_rinfo: State vars for radar processing. 993 * @dfs_b5radars: Array of bin5 radar events. 994 * @dfs_ftindextable: Map of radar durs to filter types. 995 * @dfs_defaultparams: Default phy params per radar state. 996 * @events: Events structure. 997 * @dfs_caps: Object of wlan_dfs_caps structure. 998 * @wlan_dfs_task_timer: Dfs wait timer. 999 * @dur_multiplier: Duration multiplier. 1000 * @wlan_dfs_isdfsregdomain: True when AP is in DFS domain 1001 * @dfs_phyerr_w53_counter: Phyerr w53 counter. 1002 * @dfs_seq_num: Sequence number. 1003 * @dfs_min_sidx: Minimum sidx of the received radar pulses. 1004 * @dfs_max_sidx: Maximum sidx of the received radar pulses. 1005 * @dfs_data_struct_lock: DFS data structure lock. This is to protect 1006 * all the filtering data structures. For 1007 * example: dfs_bin5radars, dfs_filtertype, 1008 * etc. 1009 * @dfs_lowest_pri_limit: 1010 * @dfs_eventq: Q of free dfs event objects. 1011 * @dfs_radarq: Q of radar events. 1012 * @dfs_arq: Q of AR events. 1013 * @dfs_host_wait_timer: The timer that is started from host after 1014 * sending the average radar parameters. 1015 * Before this timeout host expects its dfs 1016 * status from fw. 1017 * @dfs_average_pri: Average pri value of the received radar 1018 * pulses. 1019 * @dfs_average_duration: Average duration of the received radar 1020 * pulses. 1021 * @dfs_average_sidx: Average sidx of the received radar pulses. 1022 * @dfs_is_host_wait_running: Indicates if host dfs status wait timer is 1023 * running. 1024 * @dfs_average_params_sent: Indicates if host has sent the average 1025 * radar parameters. 1026 * @dfs_no_res_from_fw: Indicates no response from fw. 1027 * @dfs_spoof_check_failed: Indicates if the spoof check has failed. 1028 * @dfs_radar_found_chan: The channel on which radar was found. 1029 * @dfs_status_timeout_override: Used to change the timeout value of 1030 * dfs_host_wait_timer. 1031 * @dfs_allow_hw_pulses: Allow/Block HW pulses. When synthetic 1032 * pulses are injected, the HW pulses should 1033 * be blocked and this variable should be 1034 * false so that HW pulses and synthetic 1035 * pulses do not get mixed up. 1036 * @dfsdomain: Current DFS domain. 1037 * @dfs_proc_phyerr: Flags for Phy Errs to process. 1038 * @dfs_eventqlock: Lock for free dfs event list. 1039 * @dfs_radarqlock: Lock for dfs q. 1040 * @dfs_arqlock: Lock for AR q. 1041 * @dfs_nol: Non occupancy list for radar. 1042 * @dfs_nol_count: How many items? 1043 * @wlan_dfs_stats: DFS related stats. 1044 * @pulses: Pulse history. 1045 * @wlan_radar_tasksched: Radar task is scheduled. 1046 * @wlan_dfswait: Waiting on channel for radar detect. 1047 * @wlan_dfstest: Test timer in progress. 1048 * @wlan_dfstest_ieeechan: IEEE chan num to return to after a dfs mute 1049 * test. 1050 * @wlan_dfs_cac_time: CAC period. 1051 * @wlan_dfstesttime: Time to stay off chan during dfs test. 1052 * @wlan_dfstesttimer: Dfs mute test timer. 1053 * @dfs_bangradar_type: Radar simulation type. 1054 * @is_radar_found_on_secondary_seg: Radar on second segment. 1055 * @is_radar_during_precac: Radar found during precac. 1056 * @dfs_precac_lock: Lock to protect precac lists. 1057 * @dfs_precac_secondary_freq_mhz: Second segment freq in MHZ for precac. 1058 * Applicable to only legacy chips. 1059 * @dfs_precac_primary_freq_mhz: PreCAC Primary freq in MHZ applicable only 1060 * to legacy chips. 1061 * @dfs_defer_precac_channel_change: Defer precac channel change. 1062 * @dfs_autoswitch_des_mode: Desired PHY mode which has to be used 1063 * after precac. 1064 * @dfs_autoswitch_chan: Desired channel of dfs_channel structure 1065 * which will be prioritized for preCAC. 1066 * @dfs_precac_inter_chan_freq: Intermediate non-DFS freq used while 1067 * doing precac. 1068 * @wlan_dfs_false_rssi_thres: False RSSI Threshold. 1069 * @wlan_dfs_peak_mag: Peak mag. 1070 * @radar_log: Radar log. 1071 * @dfs_event_log_count: Event log count. 1072 * @dfs_event_log_on: Event log on. 1073 * @dfs_phyerr_count: Same as number of PHY radar interrupts. 1074 * @dfs_phyerr_reject_count: When TLV is supported, # of radar events 1075 * ignored after TLV is parsed. 1076 * @dfs_phyerr_queued_count: Number of radar events queued for matching 1077 * the filters. 1078 * @dfs_phyerr_freq_min: Phyerr min freq. 1079 * @dfs_phyerr_freq_max: Phyerr max freq. 1080 * @dfs_pri_multiplier: Allow pulse if they are within multiple of 1081 * PRI for the radar type. 1082 * @wlan_dfs_nol_timeout: NOL timeout. 1083 * @update_nol: Update NOL. 1084 * @dfs_nol_free_list: NOL free list. 1085 * @dfs_nol_elem_free_work: The work queue to free an NOL element. 1086 * @dfs_cac_timer: CAC timer. 1087 * @dfs_cac_valid_timer: Ignore CAC when this timer is running. 1088 * @dfs_cac_timeout_override: Overridden cac timeout. 1089 * @dfs_enable: DFS Enable. 1090 * @dfs_cac_timer_running: DFS CAC timer running. 1091 * @dfs_ignore_dfs: Ignore DFS. 1092 * @dfs_ignore_cac: Ignore CAC. 1093 * @dfs_cac_valid: DFS CAC valid. 1094 * @dfs_cac_valid_time: Time for which CAC will be valid and will 1095 * not be re-done. 1096 * @dfs_precac_timeout_override: Overridden precac timeout. 1097 * @dfs_disable_radar_marking: To mark or unmark NOL chan as radar hit. 1098 * @dfs_precac_list: PreCAC list (contains individual trees). 1099 * @dfs_precac_chwidth: PreCAC channel width enum. 1100 * @dfs_curchan: DFS current channel. 1101 * @dfs_prevchan: DFS previous channel. 1102 * @dfs_cac_started_chan: CAC started channel. 1103 * @dfs_pdev_obj: DFS pdev object. 1104 * @dfs_soc_obj: DFS soc object. 1105 * @dfs_psoc_idx: DFS psoc index 1106 * @dfs_agile_precac_freq_mhz: Freq in MHZ configured on Agile DFS engine. 1107 * @dfs_is_offload_enabled: Set if DFS offload enabled. 1108 * @dfs_is_bangradar_320_supported: Set if DFS 320MHZ enabled. 1109 * @dfs_is_radar_found_chan_freq_eq_center_freq: 1110 * Set if chan_freq parameter of the radar 1111 * found wmi event indicates channel center. 1112 * @dfs_use_nol: Use the NOL when radar found(default: TRUE) 1113 * @dfs_nol_lock: Lock to protect nol list. 1114 * @tx_leakage_threshold: Tx leakage threshold for dfs. 1115 * @dfs_use_nol_subchannel_marking: Use subchannel marking logic to add only 1116 * radar affected subchannel instead of all 1117 * bonding channels. 1118 * @dfs_spoof_test_done: Indicates if the sppof test is done. 1119 * @dfs_is_stadfs_enabled: Is STADFS enabled. 1120 * @dfs_seg_id: Segment ID of the radar hit channel. 1121 * @dfs_is_chirp: Radar Chirp in pulse present or not. 1122 * @dfs_bw_reduced: DFS bandwidth reduced channel bit. 1123 * @dfs_freq_offset: Frequency offset where radar was found. 1124 * @dfs_cac_aborted: DFS cac is aborted. 1125 * @dfs_nol_ie_bandwidth: Minimum Bandwidth of subchannels that 1126 * are added to NOL. 1127 * @dfs_nol_ie_startfreq: The centre frequency of the starting 1128 * subchannel in the current channel list 1129 * to be sent in NOL IE with RCSA. 1130 * @dfs_nol_ie_bitmap: The bitmap of radar affected subchannels 1131 * in the current channel list 1132 * to be sent in NOL IE with RCSA. 1133 * @dfs_is_rcsa_ie_sent: To send or to not send RCSA IE. 1134 * @dfs_is_nol_ie_sent: To send or to not send NOL IE. 1135 * @dfs_bw_expand_target_freq: User configured Channel frequency for 1136 * bandwidth expansion feature. 1137 * @dfs_bw_expand_des_mode: User configured Channel Phymode for 1138 * bandwidth expansion feature. 1139 * @dfs_use_bw_expand: User configured value for enabling or 1140 * disabling BW Expansion feature. 1141 * @dfs_use_puncture: User configured value for enabling or 1142 * disabling DFS puncturing feature. 1143 * @dfs_agile_precac_ucfg: User configuration for agile preCAC. 1144 * @dfs_agile_rcac_ucfg: User configuration for Rolling CAC. 1145 * @dfs_fw_adfs_support_320: Target Agile DFS support for 320 BW. 1146 * @dfs_fw_adfs_support_non_160: Target Agile DFS support for non-160 BWs. 1147 * @dfs_fw_adfs_support_160: Target Agile DFS support for 160 BW. 1148 * @dfs_defer_params: DFS deferred event parameters (allocated 1149 * only for the duration of defer alone). 1150 * @dfs_agile_detector_id: Agile detector ID for the DFS object. 1151 * @dfs_agile_rcac_freq_ucfg: User programmed Rolling CAC frequency in 1152 * MHZ. 1153 * @dfs_rcac_param: Primary frequency and Channel params of 1154 * the selected RCAC channel. 1155 * @dfs_chan_postnol_freq: Frequency the AP switches to, post NOL. 1156 * @dfs_chan_postnol_mode: Phymode the AP switches to, post NOL. 1157 * @dfs_chan_postnol_cfreq2: Secondary center frequency the AP 1158 * switches to, post NOL. 1159 * @dfs_channel_state_array: Stores the channel states like CAC STARTED, 1160 * CAC REQUIRED, CAC COMPLETED, NOL, 1161 * PRECAC STARTED, PRECAC COMPLETED etc. of 1162 * all the DFS channels. 1163 */ 1164 struct wlan_dfs { 1165 uint32_t dfs_debug_mask; 1166 #ifdef WLAN_DFS_PARTIAL_OFFLOAD 1167 int16_t dfs_curchan_radindex; 1168 int16_t dfs_extchan_radindex; 1169 struct dfs_ar_state dfs_ar_state; 1170 struct dfs_state dfs_radar[DFS_NUM_RADAR_STATES]; 1171 struct dfs_filtertype *dfs_radarf[DFS_MAX_RADAR_TYPES]; 1172 struct dfs_info dfs_rinfo; 1173 struct dfs_bin5radars *dfs_b5radars; 1174 int8_t **dfs_ftindextable; 1175 struct wlan_dfs_phyerr_param dfs_defaultparams; 1176 struct dfs_event *events; 1177 struct wlan_dfs_caps dfs_caps; 1178 qdf_timer_t wlan_dfs_task_timer; 1179 int dur_multiplier; 1180 uint16_t wlan_dfs_isdfsregdomain; 1181 int dfs_phyerr_w53_counter; 1182 uint32_t dfs_seq_num; 1183 int32_t dfs_min_sidx; 1184 int32_t dfs_max_sidx; 1185 qdf_spinlock_t dfs_data_struct_lock; 1186 uint16_t dfs_lowest_pri_limit; 1187 1188 STAILQ_HEAD(, dfs_event) dfs_eventq; 1189 STAILQ_HEAD(, dfs_event) dfs_radarq; 1190 STAILQ_HEAD(, dfs_event) dfs_arq; 1191 1192 #ifdef HOST_DFS_SPOOF_TEST 1193 qdf_timer_t dfs_host_wait_timer; 1194 uint32_t dfs_average_pri; 1195 uint32_t dfs_average_duration; 1196 uint32_t dfs_average_sidx; 1197 uint8_t dfs_is_host_wait_running:1, 1198 dfs_average_params_sent:1, 1199 dfs_no_res_from_fw:1, 1200 dfs_spoof_check_failed:1; 1201 struct dfs_channel dfs_radar_found_chan; 1202 int dfs_status_timeout_override; 1203 #endif 1204 #ifdef WLAN_DFS_SYNTHETIC_RADAR 1205 bool dfs_allow_hw_pulses; 1206 #endif 1207 #endif /* WLAN_DFS_PARTIAL_OFFLOAD */ 1208 uint32_t dfsdomain; 1209 uint32_t dfs_proc_phyerr; 1210 1211 qdf_spinlock_t dfs_eventqlock; 1212 1213 qdf_spinlock_t dfs_radarqlock; 1214 1215 qdf_spinlock_t dfs_arqlock; 1216 struct dfs_nolelem *dfs_nol; 1217 int dfs_nol_count; 1218 struct dfs_stats wlan_dfs_stats; 1219 struct dfs_pulseline *pulses; 1220 uint32_t wlan_radar_tasksched:1, 1221 wlan_dfswait:1, 1222 wlan_dfstest:1; 1223 uint8_t wlan_dfstest_ieeechan; 1224 uint32_t wlan_dfs_cac_time; 1225 uint32_t wlan_dfstesttime; 1226 qdf_timer_t wlan_dfstesttimer; 1227 enum dfs_bangradar_types dfs_bangradar_type; 1228 bool is_radar_found_on_secondary_seg; 1229 bool is_radar_during_precac; 1230 qdf_spinlock_t dfs_precac_lock; 1231 #ifdef CONFIG_CHAN_FREQ_API 1232 uint16_t dfs_precac_secondary_freq_mhz; 1233 uint16_t dfs_precac_primary_freq_mhz; 1234 #endif 1235 uint8_t dfs_defer_precac_channel_change; 1236 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 1237 enum wlan_phymode dfs_autoswitch_des_mode; 1238 #endif 1239 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 1240 #ifdef CONFIG_CHAN_FREQ_API 1241 struct dfs_channel *dfs_autoswitch_chan; 1242 uint16_t dfs_precac_inter_chan_freq; 1243 #endif 1244 #endif 1245 int wlan_dfs_false_rssi_thres; 1246 int wlan_dfs_peak_mag; 1247 struct dfs_event_log radar_log[DFS_EVENT_LOG_SIZE]; 1248 int dfs_event_log_count; 1249 int dfs_event_log_on; 1250 int dfs_phyerr_count; 1251 int dfs_phyerr_reject_count; 1252 int dfs_phyerr_queued_count; 1253 int dfs_phyerr_freq_min; 1254 int dfs_phyerr_freq_max; 1255 int dfs_pri_multiplier; 1256 int wlan_dfs_nol_timeout; 1257 bool update_nol; 1258 1259 TAILQ_HEAD(, dfs_nolelem) dfs_nol_free_list; 1260 qdf_work_t dfs_nol_elem_free_work; 1261 1262 qdf_hrtimer_data_t dfs_cac_timer; 1263 qdf_timer_t dfs_cac_valid_timer; 1264 int dfs_cac_timeout_override; 1265 uint8_t dfs_enable:1, 1266 dfs_cac_timer_running:1, 1267 dfs_ignore_dfs:1, 1268 dfs_ignore_cac:1, 1269 dfs_cac_valid:1; 1270 uint32_t dfs_cac_valid_time; 1271 int dfs_precac_timeout_override; 1272 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 1273 uint8_t dfs_disable_radar_marking; 1274 #endif 1275 TAILQ_HEAD(, dfs_precac_entry) dfs_precac_list; 1276 enum phy_ch_width dfs_precac_chwidth; 1277 1278 struct dfs_channel *dfs_curchan; 1279 struct dfs_channel *dfs_prevchan; 1280 struct dfs_channel dfs_cac_started_chan; 1281 struct wlan_objmgr_pdev *dfs_pdev_obj; 1282 struct dfs_soc_priv_obj *dfs_soc_obj; 1283 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1284 uint8_t dfs_psoc_idx; 1285 #endif 1286 #ifdef CONFIG_CHAN_FREQ_API 1287 uint16_t dfs_agile_precac_freq_mhz; 1288 #endif 1289 bool dfs_is_offload_enabled; 1290 bool dfs_is_bangradar_320_supported; 1291 bool dfs_is_radar_found_chan_freq_eq_center_freq; 1292 int dfs_use_nol; 1293 qdf_spinlock_t dfs_nol_lock; 1294 uint16_t tx_leakage_threshold; 1295 bool dfs_use_nol_subchannel_marking; 1296 uint8_t dfs_spoof_test_done:1; 1297 bool dfs_is_stadfs_enabled; 1298 uint8_t dfs_seg_id; 1299 uint8_t dfs_is_chirp; 1300 bool dfs_bw_reduced; 1301 int32_t dfs_freq_offset; 1302 bool dfs_cac_aborted; 1303 #if defined(QCA_DFS_RCSA_SUPPORT) 1304 uint8_t dfs_nol_ie_bandwidth; 1305 uint16_t dfs_nol_ie_startfreq; 1306 uint8_t dfs_nol_ie_bitmap; 1307 bool dfs_is_rcsa_ie_sent; 1308 bool dfs_is_nol_ie_sent; 1309 #endif 1310 #if defined(QCA_DFS_BW_EXPAND) 1311 qdf_freq_t dfs_bw_expand_target_freq; 1312 enum wlan_phymode dfs_bw_expand_des_mode; 1313 bool dfs_use_bw_expand; 1314 #endif 1315 bool dfs_use_puncture; 1316 uint8_t dfs_agile_precac_ucfg:1, 1317 #if defined(QCA_SUPPORT_ADFS_RCAC) 1318 dfs_agile_rcac_ucfg:1, 1319 #endif 1320 #ifdef WLAN_FEATURE_11BE 1321 dfs_fw_adfs_support_320:1, 1322 #endif 1323 dfs_fw_adfs_support_non_160:1, 1324 dfs_fw_adfs_support_160:1; 1325 struct dfs_mode_switch_defer_params dfs_defer_params; 1326 uint8_t dfs_agile_detector_id; 1327 #if defined(QCA_SUPPORT_ADFS_RCAC) 1328 uint16_t dfs_agile_rcac_freq_ucfg; 1329 struct dfs_rcac_params dfs_rcac_param; 1330 #endif 1331 #if defined(QCA_SUPPORT_DFS_CHAN_POSTNOL) 1332 qdf_freq_t dfs_chan_postnol_freq; 1333 enum phy_ch_width dfs_chan_postnol_mode; 1334 qdf_freq_t dfs_chan_postnol_cfreq2; 1335 #endif 1336 #if defined(WLAN_DISP_CHAN_INFO) 1337 enum channel_dfs_state dfs_channel_state_array[NUM_DFS_CHANS]; 1338 #endif /* WLAN_DISP_CHAN_INFO */ 1339 #ifdef QCA_SUPPORT_AGILE_DFS 1340 #endif 1341 }; 1342 1343 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1344 /** 1345 * struct wlan_dfs_priv - dfs private struct with agile capability info 1346 * @dfs: pointer to wlan_dfs object. 1347 * @agile_precac_active: agile precac active information for wlan_dfs_priv obj 1348 */ 1349 struct wlan_dfs_priv { 1350 struct wlan_dfs *dfs; 1351 bool agile_precac_active; 1352 }; 1353 #endif 1354 1355 /** 1356 * struct dfs_soc_priv_obj - dfs private data 1357 * @psoc: pointer to PSOC object information 1358 * @pdev: pointer to PDEV object information 1359 * @dfs_is_phyerr_filter_offload: For some chip like Rome indicates too many 1360 * phyerr packets in a short time, which causes 1361 * OS hang. If this field is configured as true, 1362 * FW will do the pre-check, filter out some 1363 * kinds of invalid phyerrors and indicate 1364 * radar detection related information to host. 1365 * @dfs_priv: array of dfs private structs with agile capability info 1366 * @num_dfs_privs: array size of dfs private structs for given psoc. 1367 * @cur_agile_dfs_index: index of the current dfs object using the Agile Engine. 1368 * It is used to index struct wlan_dfs_priv dfs_priv[] array. 1369 * @dfs_precac_timer: agile precac timer 1370 * @dfs_precac_timer_running: precac timer running flag 1371 * @precac_state_started: true if pre-CAC has started 1372 * @ocac_status: Off channel CAC complete status 1373 * @dfs_psoc_nolinfo: dfs NOL data for all radios. 1374 * @dfs_rcac_timer: Agile RCAC (Rolling CAC) timer. 1375 * @dfs_agile_sm_hdl: The handle for the state machine that drives Agile 1376 * Engine. 1377 * @dfs_agile_sm_cur_state: Current state of the Agile State Machine. 1378 * @dfs_agile_sm_lock: Agile state machine lock. 1379 */ 1380 struct dfs_soc_priv_obj { 1381 struct wlan_objmgr_psoc *psoc; 1382 struct wlan_objmgr_pdev *pdev; 1383 bool dfs_is_phyerr_filter_offload; 1384 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1385 struct wlan_dfs_priv dfs_priv[WLAN_UMAC_MAX_PDEVS]; 1386 uint8_t num_dfs_privs; 1387 uint8_t cur_agile_dfs_index; 1388 qdf_hrtimer_data_t dfs_precac_timer; 1389 uint8_t dfs_precac_timer_running; 1390 bool precac_state_started; 1391 bool ocac_status; 1392 #endif 1393 struct dfsreq_nolinfo *dfs_psoc_nolinfo; 1394 #ifdef QCA_SUPPORT_ADFS_RCAC 1395 qdf_hrtimer_data_t dfs_rcac_timer; 1396 #endif 1397 #ifdef QCA_SUPPORT_AGILE_DFS 1398 struct wlan_sm *dfs_agile_sm_hdl; 1399 enum dfs_agile_sm_state dfs_agile_sm_cur_state; 1400 qdf_spinlock_t dfs_agile_sm_lock; 1401 #endif 1402 }; 1403 1404 /** 1405 * enum dfs_debug - This should match the table from if_ath.c. 1406 * @WLAN_DEBUG_DFS: Minimal DFS debug. 1407 * @WLAN_DEBUG_DFS1: Normal DFS debug. 1408 * @WLAN_DEBUG_DFS2: Maximal DFS debug. 1409 * @WLAN_DEBUG_DFS3: Matched filterID display. 1410 * @WLAN_DEBUG_DFS_PHYERR: Phy error parsing. 1411 * @WLAN_DEBUG_DFS_NOL: NOL related entries. 1412 * @WLAN_DEBUG_DFS_PHYERR_SUM: PHY error summary. 1413 * @WLAN_DEBUG_DFS_PHYERR_PKT: PHY error payload. 1414 * @WLAN_DEBUG_DFS_BIN5: BIN5 checks. 1415 * @WLAN_DEBUG_DFS_BIN5_FFT: BIN5 FFT check. 1416 * @WLAN_DEBUG_DFS_BIN5_PULSE: BIN5 pulse check. 1417 * @WLAN_DEBUG_DFS_FALSE_DET: False detection debug related prints. 1418 * @WLAN_DEBUG_DFS_FALSE_DET2: Second level check to confirm poisitive 1419 * detection. 1420 * @WLAN_DEBUG_DFS_RANDOM_CHAN: Random channel selection. 1421 * @WLAN_DEBUG_DFS_AGILE: Agile PreCAC/RCAC 1422 * @WLAN_DEBUG_DFS_MAX: Max flag 1423 * @WLAN_DEBUG_DFS_ALWAYS: Always debug 1424 */ 1425 enum dfs_debug { 1426 WLAN_DEBUG_DFS = 0x00000100, 1427 WLAN_DEBUG_DFS1 = 0x00000200, 1428 WLAN_DEBUG_DFS2 = 0x00000400, 1429 WLAN_DEBUG_DFS3 = 0x00000800, 1430 WLAN_DEBUG_DFS_PHYERR = 0x00001000, 1431 WLAN_DEBUG_DFS_NOL = 0x00002000, 1432 WLAN_DEBUG_DFS_PHYERR_SUM = 0x00004000, 1433 WLAN_DEBUG_DFS_PHYERR_PKT = 0x00008000, 1434 WLAN_DEBUG_DFS_BIN5 = 0x00010000, 1435 WLAN_DEBUG_DFS_BIN5_FFT = 0x00020000, 1436 WLAN_DEBUG_DFS_BIN5_PULSE = 0x00040000, 1437 WLAN_DEBUG_DFS_FALSE_DET = 0x00080000, 1438 WLAN_DEBUG_DFS_FALSE_DET2 = 0x00100000, 1439 WLAN_DEBUG_DFS_RANDOM_CHAN = 0x00200000, 1440 WLAN_DEBUG_DFS_AGILE = 0x00400000, 1441 WLAN_DEBUG_DFS_MAX = 0x80000000, 1442 WLAN_DEBUG_DFS_ALWAYS = WLAN_DEBUG_DFS_MAX 1443 }; 1444 1445 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 1446 /** 1447 * enum host_dfs_spoof_check_status - DFS spoof check status values 1448 * @HOST_DFS_STATUS_CHECK_PASSED: Host indicates RADAR detected and the FW 1449 * confirms it to be spoof radar to host. 1450 * @HOST_DFS_STATUS_CHECK_FAILED: Host doesn't indicate RADAR detected or spoof 1451 * radar parameters by 1452 * WMI_HOST_DFS_RADAR_FOUND_CMDID doesn't match. 1453 * @HOST_DFS_STATUS_CHECK_HW_RADAR: Host indicates RADAR detected and the FW 1454 * confirms it to be real HW radar to host. 1455 */ 1456 enum host_dfs_spoof_check_status { 1457 HOST_DFS_STATUS_CHECK_PASSED = 0, 1458 HOST_DFS_STATUS_CHECK_FAILED = 1, 1459 HOST_DFS_STATUS_CHECK_HW_RADAR = 2 1460 }; 1461 #endif 1462 1463 /** 1464 * struct dfs_phy_err - DFS phy error. 1465 * @fulltsf: 64-bit TSF as read from MAC. 1466 * @is_pri: Detected on primary channel. 1467 * @is_ext: Detected on extension channel. 1468 * @is_dc: Detected at DC. 1469 * @is_early: Early detect. 1470 * @do_check_chirp: Whether to check hw_chirp/sw_chirp. 1471 * @is_hw_chirp: Hardware-detected chirp. 1472 * @is_sw_chirp: Software detected chirp. 1473 * @rs_tstamp: 32 bit TSF from RX descriptor (event). 1474 * @freq: Centre frequency of event - KHz. 1475 * @freq_lo: Lower bounds of frequency - KHz. 1476 * @freq_hi: Upper bounds of frequency - KHz. 1477 * @rssi: Pulse RSSI. 1478 * @dur: Pulse duration, raw (not uS). 1479 * @seg_id: HT80_80/HT160 use. 1480 * @sidx: Seg index. 1481 * @freq_offset_khz: Freq offset in KHz. 1482 * @peak_mag: Peak mag. 1483 * @total_gain: Total gain. 1484 * @mb_gain: Mb gain. 1485 * @relpwr_db: Relpower in DB. 1486 * @pulse_delta_diff: Pulse delta diff. 1487 * @pulse_delta_peak: Pulse delta peak. 1488 * @pulse_psidx_diff: Pulse psidx diff. 1489 * 1490 * Chirp notes! 1491 * 1492 * Pre-Sowl chips don't do FFT reports, so chirp pulses simply show up 1493 * as long duration pulses. 1494 * 1495 * The bin5 checking code would simply look for a chirp pulse of the correct 1496 * duration (within MIN_BIN5_DUR and MAX_BIN5_DUR) and add it to the "chirp" 1497 * pattern. 1498 * 1499 * For Sowl and later, an FFT was done on longer duration frames. If those 1500 * frames looked like a chirp, their duration was adjusted to fall within 1501 * the chirp duration limits. If the pulse failed the chirp test (it had 1502 * no FFT data or the FFT didn't meet the chirping requirements) then the 1503 * pulse duration was adjusted to be greater than MAX_BIN5_DUR, so it 1504 * would always fail chirp detection. 1505 * 1506 * This is pretty horrible. 1507 * 1508 * The eventual goal for chirp handling is thus: 1509 * 1510 * 1)In case someone ever wants to do chirp detection with this code on 1511 * chips that don't support chirp detection, you can still do it based 1512 * on pulse duration. That's your problem to solve. 1513 * 1514 * 2)For chips that do hardware chirp detection or FFT, the "do_check_chirp" 1515 * bit should be set. 1516 * 1517 * 3)Then, either is_hw_chirp or is_sw_chirp is set, indicating that 1518 * the hardware or software post-processing of the chirp event found 1519 * that indeed it was a chirp. 1520 * 1521 * 4)Finally, the bin5 code should just check whether the chirp bits are 1522 * set and behave appropriately, falling back onto the duration checks 1523 * if someone wishes to use this on older hardware (or with disabled 1524 * FFTs, for whatever reason.) 1525 * 1526 * XXX TODO: 1527 * 1528 * 1)add duration in uS and raw duration, so the PHY error parsing 1529 * code is responsible for doing the duration calculation; 1530 * 2)add ts in raw and corrected, so the PHY error parsing 1531 * code is responsible for doing the offsetting, not the radar 1532 * event code. 1533 */ 1534 struct dfs_phy_err { 1535 uint64_t fulltsf; 1536 uint32_t is_pri:1, 1537 is_ext:1, 1538 is_dc:1, 1539 is_early:1, 1540 do_check_chirp:1, 1541 is_hw_chirp:1, 1542 is_sw_chirp:1; 1543 uint32_t rs_tstamp; 1544 uint32_t freq; 1545 uint32_t freq_lo; 1546 uint32_t freq_hi; 1547 uint8_t rssi; 1548 uint8_t dur; 1549 uint8_t seg_id; 1550 int sidx; 1551 u_int freq_offset_khz; 1552 int peak_mag; 1553 int total_gain; 1554 int mb_gain; 1555 int relpwr_db; 1556 uint8_t pulse_delta_diff; 1557 int8_t pulse_delta_peak; 1558 int16_t pulse_psidx_diff; 1559 }; 1560 1561 /** 1562 * struct rx_radar_status - Parsed radar status 1563 * @raw_tsf: Raw tsf 1564 * @tsf_offset: TSF offset. 1565 * @rssi: RSSI. 1566 * @pulse_duration: Pulse duration. 1567 * @is_chirp: Is chirp. 1568 * @delta_peak: Delta peak. 1569 * @delta_diff: Delta diff. 1570 * @sidx: Starting frequency. 1571 * @freq_offset: Frequency offset. 1572 * @agc_total_gain: AGC total gain. 1573 * @agc_mb_gain: AGC MB gain. 1574 */ 1575 struct rx_radar_status { 1576 uint32_t raw_tsf; 1577 uint32_t tsf_offset; 1578 int rssi; 1579 int pulse_duration; 1580 int is_chirp:1; 1581 int delta_peak; 1582 int delta_diff; 1583 int sidx; 1584 int freq_offset; /* in KHz */ 1585 int agc_total_gain; 1586 int agc_mb_gain; 1587 }; 1588 1589 /** 1590 * struct rx_search_fft_report - FFT report. 1591 * @total_gain_db: Total gain in Db. 1592 * @base_pwr_db: Base power in Db. 1593 * @fft_chn_idx: FFT channel index. 1594 * @peak_sidx: Peak sidx. 1595 * @relpwr_db: Real power in Db. 1596 * @avgpwr_db: Average power in Db. 1597 * @peak_mag: Peak Mag. 1598 * @num_str_bins_ib: Num dtr BINs IB 1599 * @seg_id: Segment ID 1600 */ 1601 struct rx_search_fft_report { 1602 uint32_t total_gain_db; 1603 uint32_t base_pwr_db; 1604 int fft_chn_idx; 1605 int peak_sidx; 1606 int relpwr_db; 1607 int avgpwr_db; 1608 int peak_mag; 1609 int num_str_bins_ib; 1610 int seg_id; 1611 }; 1612 1613 /** 1614 * dfs_process_radarevent() - process the radar event generated for a pulse. 1615 * @dfs: Pointer to wlan_dfs structure. 1616 * @chan: Current channel. 1617 * 1618 * There is currently no way to specify that a radar event has occurred on 1619 * a specific channel, so the current methodology is to mark both the pri 1620 * and ext channels as being unavailable. This should be fixed for 802.11ac 1621 * or we'll quickly run out of valid channels to use. 1622 * 1623 * If Radar found, this marks the channel (and the extension channel, if HT40) 1624 * as having seen a radar event. It marks CHAN_INTERFERENCE and will add it to 1625 * the local NOL implementation. This is only done for 'usenol=1', as the other 1626 * two modes don't do radar notification or CAC/CSA/NOL; it just notes there 1627 * was a radar. 1628 */ 1629 void dfs_process_radarevent(struct wlan_dfs *dfs, 1630 struct dfs_channel *chan); 1631 1632 /** 1633 * dfs_nol_addchan() - Add channel to NOL. 1634 * @dfs: Pointer to wlan_dfs structure. 1635 * @freq: frequency to add to NOL. 1636 * @dfs_nol_timeout: NOL timeout. 1637 */ 1638 void dfs_nol_addchan(struct wlan_dfs *dfs, 1639 uint16_t freq, 1640 uint32_t dfs_nol_timeout); 1641 1642 /** 1643 * dfs_get_nol() - Get NOL. 1644 * @dfs: Pointer to wlan_dfs structure. 1645 * @dfs_nol: Pointer to dfsreq_nolelem structure to save the channels from NOL. 1646 * @nchan: Number of channels. 1647 */ 1648 void dfs_get_nol(struct wlan_dfs *dfs, 1649 struct dfsreq_nolelem *dfs_nol, 1650 int *nchan); 1651 1652 /** 1653 * dfs_set_nol() - Set NOL. 1654 * @dfs: Pointer to wlan_dfs structure. 1655 * @dfs_nol: Pointer to dfsreq_nolelem structure. 1656 * @nchan: Number of channels. 1657 */ 1658 void dfs_set_nol(struct wlan_dfs *dfs, 1659 struct dfsreq_nolelem *dfs_nol, 1660 int nchan); 1661 1662 /** 1663 * dfs_nol_update() - NOL update 1664 * @dfs: Pointer to wlan_dfs structure. 1665 * 1666 * Notify the driver/umac that it should update the channel radar/NOL flags 1667 * based on the current NOL list. 1668 */ 1669 void dfs_nol_update(struct wlan_dfs *dfs); 1670 1671 /** 1672 * dfs_nol_timer_cleanup() - NOL timer cleanup. 1673 * @dfs: Pointer to wlan_dfs structure. 1674 * 1675 * Cancels the NOL timer and frees the NOL elements. 1676 */ 1677 void dfs_nol_timer_cleanup(struct wlan_dfs *dfs); 1678 1679 /** 1680 * dfs_nol_timer_detach() - Free NOL timer. 1681 * @dfs: Pointer to wlan_dfs structure. 1682 */ 1683 void dfs_nol_timer_detach(struct wlan_dfs *dfs); 1684 1685 /** 1686 * dfs_nol_workqueue_cleanup() - Flushes NOL workqueue. 1687 * @dfs: Pointer to wlan_dfs structure. 1688 * 1689 * Flushes the NOL workqueue. 1690 */ 1691 void dfs_nol_workqueue_cleanup(struct wlan_dfs *dfs); 1692 1693 /** 1694 * dfs_retain_bin5_burst_pattern() - Retain the BIN5 burst pattern. 1695 * @dfs: Pointer to wlan_dfs structure. 1696 * @diff_ts: Timestamp diff. 1697 * @old_dur: Old duration. 1698 */ 1699 uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs, 1700 uint32_t diff_ts, 1701 uint8_t old_dur); 1702 1703 /** 1704 * dfs_bin5_check_pulse() - BIN5 check pulse. 1705 * @dfs: Pointer to wlan_dfs structure. 1706 * @re: Pointer to dfs_event structure. 1707 * @br: Pointer to dfs_bin5radars structure. 1708 * 1709 * Reject the pulse if: 1710 * 1) It's outside the RSSI threshold; 1711 * 2) It's outside the pulse duration; 1712 * 3) It's been verified by HW/SW chirp checking 1713 * and neither of those found a chirp. 1714 */ 1715 int dfs_bin5_check_pulse(struct wlan_dfs *dfs, 1716 struct dfs_event *re, 1717 struct dfs_bin5radars *br); 1718 1719 /** 1720 * dfs_bin5_addpulse() - BIN5 add pulse. 1721 * @dfs: Pointer to wlan_dfs structure. 1722 * @br: Pointer to dfs_bin5radars structure. 1723 * @re: Pointer to dfs_event structure. 1724 * @thists: Timestamp. 1725 */ 1726 int dfs_bin5_addpulse(struct wlan_dfs *dfs, 1727 struct dfs_bin5radars *br, 1728 struct dfs_event *re, 1729 uint64_t thists); 1730 1731 /** 1732 * dfs_bin5_check() - BIN5 check. 1733 * @dfs: Pointer to wlan_dfs structure. 1734 * 1735 * If the dfs structure is NULL (which should be illegal if everything is working 1736 * properly, then signify that a bin5 radar was found. 1737 */ 1738 int dfs_bin5_check(struct wlan_dfs *dfs); 1739 1740 /** 1741 * dfs_check_chirping() - Check chirping. 1742 * @dfs: Pointer to wlan_dfs structure. 1743 * @buf: Phyerr buffer 1744 * @datalen: Phyerr buf length 1745 * @is_ctl: detected on primary channel. 1746 * @is_ext: detected on extension channel. 1747 * @slope: Slope 1748 * @is_dc: DC found 1749 * 1750 * This examines the FFT data contained in the PHY error information to figure 1751 * out whether the pulse is moving across frequencies. 1752 */ 1753 int dfs_check_chirping(struct wlan_dfs *dfs, 1754 void *buf, 1755 uint16_t datalen, 1756 int is_ctl, 1757 int is_ext, 1758 int *slope, 1759 int *is_dc); 1760 1761 /** 1762 * dfs_get_random_bin5_dur() - Get random BIN5 duration. 1763 * @dfs: Pointer to wlan_dfs structure. 1764 * @tstamp: Timestamp. 1765 * 1766 * Chirping pulses may get cut off at DC and report lower durations. 1767 * This function will compute a suitable random duration for each pulse. 1768 * Duration must be between 50 and 100 us, but remember that in 1769 * wlan_process_phyerr() which calls this function, we are dealing with the 1770 * HW reported duration (unconverted). dfs_process_radarevent() will 1771 * actually convert the duration into the correct value. 1772 * This function doesn't take into account whether the hardware 1773 * is operating in 5GHz fast clock mode or not. 1774 * And this function doesn't take into account whether the hardware 1775 * is peregrine or not. 1776 */ 1777 int dfs_get_random_bin5_dur(struct wlan_dfs *dfs, 1778 uint64_t tstamp); 1779 1780 /** 1781 * dfs_print_delayline() - Prints delayline. 1782 * @dfs: Pointer to wlan_dfs structure. 1783 * @dl: Pointer to dfs_delayline structure. 1784 */ 1785 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1786 void dfs_print_delayline(struct wlan_dfs *dfs, 1787 struct dfs_delayline *dl); 1788 #else 1789 static inline 1790 void dfs_print_delayline(struct wlan_dfs *dfs, struct dfs_delayline *dl) 1791 { 1792 } 1793 #endif 1794 1795 /** 1796 * dfs_print_nol() - Print NOL elements. 1797 * @dfs: Pointer to wlan_dfs structure. 1798 */ 1799 void dfs_print_nol(struct wlan_dfs *dfs); 1800 1801 /** 1802 * dfs_print_filter() - Prints the filter. 1803 * @dfs: Pointer to wlan_dfs structure. 1804 * @rf: Pointer to dfs_filter structure. 1805 */ 1806 void dfs_print_filter(struct wlan_dfs *dfs, 1807 struct dfs_filter *rf); 1808 1809 /** 1810 * dfs_getchanstate() - Get chan state. 1811 * @dfs: Pointer to wlan_dfs structure. 1812 * @index: To save the index of dfs_radar[] 1813 * @ext_chan_flag: Extension channel flag; 1814 */ 1815 struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, uint8_t *index, 1816 int ext_chan_flag); 1817 1818 /** 1819 * dfs_round() - DFS found. 1820 * @val: Convert durations to TSF ticks. 1821 * 1822 * Return: TSF ticks. 1823 */ 1824 uint32_t dfs_round(int32_t val); 1825 1826 /** 1827 * dfs_reset_alldelaylines() - Reset alldelaylines. 1828 * @dfs: Pointer to wlan_dfs structure. 1829 */ 1830 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1831 void dfs_reset_alldelaylines(struct wlan_dfs *dfs); 1832 #else 1833 static inline void dfs_reset_alldelaylines(struct wlan_dfs *dfs) 1834 { 1835 } 1836 #endif 1837 1838 /** 1839 * dfs_reset_delayline() - Clear only a single delay line. 1840 * @dl: Pointer to dfs_delayline structure. 1841 */ 1842 void dfs_reset_delayline(struct dfs_delayline *dl); 1843 1844 /** 1845 * dfs_reset_filter_delaylines() - Reset filter delaylines. 1846 * @dft: Pointer to dfs_filtertype structure. 1847 */ 1848 void dfs_reset_filter_delaylines(struct dfs_filtertype *dft); 1849 1850 /** 1851 * dfs_reset_radarq() - Reset radar queue. 1852 * @dfs: Pointer to wlan_dfs structure. 1853 */ 1854 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1855 void dfs_reset_radarq(struct wlan_dfs *dfs); 1856 #else 1857 static inline void dfs_reset_radarq(struct wlan_dfs *dfs) 1858 { 1859 } 1860 #endif 1861 1862 /** 1863 * dfs_add_pulse() - Adds pulse to the queue. 1864 * @dfs: Pointer to wlan_dfs structure. 1865 * @rf: Pointer to dfs_filter structure. 1866 * @re: Pointer to dfs_event structure. 1867 * @deltaT: deltaT value. 1868 * @this_ts: Last time stamp. 1869 */ 1870 void dfs_add_pulse(struct wlan_dfs *dfs, 1871 struct dfs_filter *rf, 1872 struct dfs_event *re, 1873 uint32_t deltaT, 1874 uint64_t this_ts); 1875 1876 /** 1877 * dfs_bin_check() - BIN check 1878 * @dfs: Pointer to wlan_dfs structure. 1879 * @rf: Pointer to dfs_filter structure. 1880 * @deltaT: deltaT value. 1881 * @width: Width 1882 * @ext_chan_flag: Extension channel flag. 1883 */ 1884 int dfs_bin_check(struct wlan_dfs *dfs, 1885 struct dfs_filter *rf, 1886 uint32_t deltaT, 1887 uint32_t width, 1888 int ext_chan_flag); 1889 1890 /** 1891 * dfs_bin_pri_check() - BIN PRI check 1892 * @dfs: Pointer to wlan_dfs structure. 1893 * @rf: Pointer to dfs_filter structure. 1894 * @dl: Pointer to dfs_delayline structure. 1895 * @score: Primary score. 1896 * @refpri: Current "filter" time for start of pulse in usecs. 1897 * @refdur: Duration value. 1898 * @ext_chan_flag: Extension channel flag. 1899 * @fundamentalpri: Highest PRI. 1900 */ 1901 int dfs_bin_pri_check(struct wlan_dfs *dfs, 1902 struct dfs_filter *rf, 1903 struct dfs_delayline *dl, 1904 uint32_t score, 1905 uint32_t refpri, 1906 uint32_t refdur, 1907 int ext_chan_flag, 1908 int fundamentalpri); 1909 1910 /** 1911 * dfs_staggered_check() - Detection implementation for staggered PRIs. 1912 * @dfs: Pointer to wlan_dfs structure. 1913 * @rf: Pointer to dfs_filter structure. 1914 * @deltaT: Delta of the Timestamp. 1915 * @width: Duration of radar pulse. 1916 * 1917 * Return: 1 on success and 0 on failure. 1918 */ 1919 int dfs_staggered_check(struct wlan_dfs *dfs, 1920 struct dfs_filter *rf, 1921 uint32_t deltaT, 1922 uint32_t width); 1923 1924 /** 1925 * dfs_get_pri_margin() - Get Primary margin. 1926 * @dfs: Pointer to wlan_dfs structure. 1927 * @is_extchan_detect: Extension channel detect. 1928 * @is_fixed_pattern: Fixed pattern. 1929 * 1930 * For the extension channel, if legacy traffic is present, we see a lot of 1931 * false alarms, so make the PRI margin narrower depending on the busy % for 1932 * the extension channel. 1933 * 1934 * Return: Returns pri_margin. 1935 */ 1936 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1937 int dfs_get_pri_margin(struct wlan_dfs *dfs, 1938 int is_extchan_detect, 1939 int is_fixed_pattern); 1940 #else 1941 static inline 1942 int dfs_get_pri_margin(struct wlan_dfs *dfs, 1943 int is_extchan_detect, 1944 int is_fixed_pattern) 1945 { 1946 return 0; 1947 } 1948 #endif 1949 1950 /** 1951 * dfs_get_filter_threshold() - Get filter threshold. 1952 * @dfs: Pointer to wlan_dfs structure. 1953 * @rf: Pointer to dfs_filter structure. 1954 * @is_extchan_detect: Extension channel detect. 1955 * 1956 * For the extension channel, if legacy traffic is present, we see a lot of 1957 * false alarms, so make the thresholds higher depending on the busy % for the 1958 * extension channel. 1959 * 1960 * Return: Returns threshold. 1961 */ 1962 int dfs_get_filter_threshold(struct wlan_dfs *dfs, 1963 struct dfs_filter *rf, 1964 int is_extchan_detect); 1965 1966 #if defined(MOBILE_DFS_SUPPORT) 1967 /** 1968 * dfs_process_ar_event() - Process the ar event. 1969 * @dfs: Pointer to wlan_dfs structure. 1970 * @chan: Current channel structure. 1971 */ 1972 static inline void dfs_process_ar_event(struct wlan_dfs *dfs, 1973 struct dfs_channel *chan) 1974 { 1975 } 1976 1977 /** 1978 * dfs_reset_ar() - resets the ar state. 1979 * @dfs: pointer to wlan_dfs structure. 1980 */ 1981 static inline void dfs_reset_ar(struct wlan_dfs *dfs) 1982 { 1983 } 1984 1985 /** 1986 * dfs_reset_arq() - resets the ar queue. 1987 * @dfs: pointer to wlan_dfs structure. 1988 */ 1989 static inline void dfs_reset_arq(struct wlan_dfs *dfs) 1990 { 1991 } 1992 1993 #else 1994 void dfs_process_ar_event(struct wlan_dfs *dfs, 1995 struct dfs_channel *chan); 1996 1997 void dfs_reset_ar(struct wlan_dfs *dfs); 1998 void dfs_reset_arq(struct wlan_dfs *dfs); 1999 #endif 2000 2001 /** 2002 * dfs_is_radar_enabled() - check if radar detection is enabled. 2003 * @dfs: Pointer to wlan_dfs structure. 2004 * @ignore_dfs: if 1 then radar detection is disabled.. 2005 */ 2006 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2007 void dfs_is_radar_enabled(struct wlan_dfs *dfs, 2008 int *ignore_dfs); 2009 #else 2010 static inline void dfs_is_radar_enabled(struct wlan_dfs *dfs, 2011 int *ignore_dfs) 2012 { 2013 } 2014 #endif 2015 2016 /** 2017 * dfs_process_phyerr_bb_tlv() - Parses the PHY error and populates the 2018 * dfs_phy_err struct. 2019 * @dfs: Pointer to wlan_dfs structure. 2020 * @buf: Phyerr buffer 2021 * @datalen: Phyerr buf len 2022 * @rssi: RSSI 2023 * @ext_rssi: Extension RSSI. 2024 * @rs_tstamp: Time stamp. 2025 * @fulltsf: TSF64. 2026 * @e: Pointer to dfs_phy_err structure. 2027 * 2028 * Return: Returns 1. 2029 */ 2030 int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs, 2031 void *buf, 2032 uint16_t datalen, 2033 uint8_t rssi, 2034 uint8_t ext_rssi, 2035 uint32_t rs_tstamp, 2036 uint64_t fulltsf, 2037 struct dfs_phy_err *e); 2038 2039 /** 2040 * dfs_reset() - DFS reset 2041 * @dfs: Pointer to wlan_dfs structure. 2042 */ 2043 void dfs_reset(struct wlan_dfs *dfs); 2044 2045 /** 2046 * dfs_radar_enable() - Enables the radar. 2047 * @dfs: Pointer to wlan_dfs structure. 2048 * @no_cac: If no_cac is 0, it cancels the CAC. 2049 * @opmode: Operational mode 2050 */ 2051 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2052 void dfs_radar_enable(struct wlan_dfs *dfs, 2053 int no_cac, uint32_t opmode); 2054 #else 2055 static inline void dfs_radar_enable(struct wlan_dfs *dfs, 2056 int no_cac, uint32_t opmode) 2057 { 2058 } 2059 #endif 2060 2061 /** 2062 * dfs_process_phyerr() - Process phyerr. 2063 * @dfs: Pointer to wlan_dfs structure. 2064 * @buf: Phyerr buffer. 2065 * @datalen: phyerr buffer length. 2066 * @r_rssi: RSSI. 2067 * @r_ext_rssi: Extension channel RSSI. 2068 * @r_rs_tstamp: Timestamp. 2069 * @r_fulltsf: TSF64. 2070 */ 2071 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2072 void dfs_process_phyerr(struct wlan_dfs *dfs, 2073 void *buf, 2074 uint16_t datalen, 2075 uint8_t r_rssi, 2076 uint8_t r_ext_rssi, 2077 uint32_t r_rs_tstamp, 2078 uint64_t r_fulltsf); 2079 #else 2080 static inline void dfs_process_phyerr(struct wlan_dfs *dfs, 2081 void *buf, 2082 uint16_t datalen, 2083 uint8_t r_rssi, 2084 uint8_t r_ext_rssi, 2085 uint32_t r_rs_tstamp, 2086 uint64_t r_fulltsf) 2087 { 2088 } 2089 #endif 2090 2091 #ifdef QCA_SUPPORT_DFS_CHAN_POSTNOL 2092 /** 2093 * dfs_switch_to_postnol_chan_if_nol_expired() - Find if NOL is expired 2094 * in the postNOL channel configured. If true, trigger channel change. 2095 * @dfs: Pointer to DFS of wlan_dfs structure. 2096 * 2097 * Return: True, if channel change is triggered, else false. 2098 */ 2099 bool dfs_switch_to_postnol_chan_if_nol_expired(struct wlan_dfs *dfs); 2100 #else 2101 static inline bool 2102 dfs_switch_to_postnol_chan_if_nol_expired(struct wlan_dfs *dfs) 2103 { 2104 return false; 2105 } 2106 #endif 2107 2108 #ifdef MOBILE_DFS_SUPPORT 2109 /** 2110 * dfs_process_phyerr_filter_offload() - Process radar event. 2111 * @dfs: Pointer to wlan_dfs structure. 2112 * @wlan_radar_event: Pointer to radar_event_info structure. 2113 * 2114 * Return: None 2115 */ 2116 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2117 void dfs_process_phyerr_filter_offload(struct wlan_dfs *dfs, 2118 struct radar_event_info *wlan_radar_event); 2119 #else 2120 static inline void dfs_process_phyerr_filter_offload( 2121 struct wlan_dfs *dfs, 2122 struct radar_event_info *wlan_radar_event) 2123 { 2124 } 2125 #endif 2126 #endif 2127 2128 /** 2129 * dfs_get_radars() - Based on the chipset, calls init radar table functions. 2130 * @dfs: Pointer to wlan_dfs structure. 2131 */ 2132 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2133 void dfs_get_radars(struct wlan_dfs *dfs); 2134 #else 2135 static inline void dfs_get_radars(struct wlan_dfs *dfs) 2136 { 2137 } 2138 #endif 2139 2140 /** 2141 * dfs_attach() - Wrapper function to allocate memory for wlan_dfs members. 2142 * @dfs: Pointer to wlan_dfs structure. 2143 */ 2144 int dfs_attach(struct wlan_dfs *dfs); 2145 2146 2147 /** 2148 * dfs_create_object() - Creates DFS object. 2149 * @dfs: Pointer to wlan_dfs structure. 2150 */ 2151 int dfs_create_object(struct wlan_dfs **dfs); 2152 2153 /** 2154 * dfs_destroy_object() - Destroys the DFS object. 2155 * @dfs: Pointer to wlan_dfs structure. 2156 */ 2157 void dfs_destroy_object(struct wlan_dfs *dfs); 2158 2159 /** 2160 * dfs_detach() - Wrapper function to free dfs variables. 2161 * @dfs: Pointer to wlan_dfs structure. 2162 */ 2163 void dfs_detach(struct wlan_dfs *dfs); 2164 2165 #ifdef QCA_SUPPORT_DFS_CAC 2166 /** 2167 * dfs_stacac_stop() - Clear the STA CAC timer. 2168 * @dfs: Pointer to wlan_dfs structure. 2169 */ 2170 void dfs_stacac_stop(struct wlan_dfs *dfs); 2171 2172 /** 2173 * dfs_is_cac_required() - Check if DFS CAC is required for the current channel. 2174 * @dfs: Pointer to wlan_dfs structure. 2175 * @cur_chan: Pointer to current channel of dfs_channel structure. 2176 * @prev_chan: Pointer to previous channel of dfs_channel structure. 2177 * @continue_current_cac: If AP can start CAC then this variable indicates 2178 * whether to continue with the current CAC or restart the CAC. This variable 2179 * is valid only if this function returns true. 2180 * @is_vap_restart: Flag to indicate if vap is restarted/started. 2181 * True: VAP restart. False: VAP start 2182 * 2183 * Return: true if AP requires CAC or can continue current CAC, else false. 2184 */ 2185 bool dfs_is_cac_required(struct wlan_dfs *dfs, 2186 struct dfs_channel *cur_chan, 2187 struct dfs_channel *prev_chan, 2188 bool *continue_current_cac, 2189 bool is_vap_restart); 2190 2191 /** 2192 * dfs_send_dfs_events_for_chan() - Send CAC RESET events 2193 * @dfs: Pointer to wlan_dfs structure. 2194 * @chan: Pointer to dfs_channel structure. 2195 * @event: WLAN_DFS_EVENTS values 2196 */ 2197 void dfs_send_dfs_events_for_chan(struct wlan_dfs *dfs, 2198 struct dfs_channel *chan, 2199 enum WLAN_DFS_EVENTS event); 2200 2201 /** 2202 * dfs_cac_stop() - Clear the AP CAC timer. 2203 * @dfs: Pointer to wlan_dfs structure. 2204 */ 2205 void dfs_cac_stop(struct wlan_dfs *dfs); 2206 2207 /** 2208 * dfs_cancel_cac_timer() - Cancels the CAC timer. 2209 * @dfs: Pointer to wlan_dfs structure. 2210 */ 2211 void dfs_cancel_cac_timer(struct wlan_dfs *dfs); 2212 2213 /** 2214 * dfs_start_cac_timer() - Starts the CAC timer. 2215 * @dfs: Pointer to wlan_dfs structure. 2216 */ 2217 void dfs_start_cac_timer(struct wlan_dfs *dfs); 2218 2219 /** 2220 * dfs_cac_valid_reset_for_freq() - Cancels the dfs_cac_valid_timer timer. 2221 * @dfs: Pointer to wlan_dfs structure. 2222 * @prevchan_freq: Prevchan frequency 2223 * @prevchan_flags: Prevchan flags. 2224 */ 2225 #ifdef CONFIG_CHAN_FREQ_API 2226 void dfs_cac_valid_reset_for_freq(struct wlan_dfs *dfs, 2227 uint16_t prevchan_freq, 2228 uint32_t prevchan_flags); 2229 #endif 2230 2231 /** 2232 * dfs_get_override_cac_timeout() - Get override CAC timeout value. 2233 * @dfs: Pointer to DFS object. 2234 * @cac_timeout: Pointer to save the CAC timeout value. 2235 */ 2236 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, 2237 int *cac_timeout); 2238 2239 /** 2240 * dfs_override_cac_timeout() - Override the default CAC timeout. 2241 * @dfs: Pointer to DFS object. 2242 * @cac_timeout: CAC timeout value. 2243 */ 2244 int dfs_override_cac_timeout(struct wlan_dfs *dfs, 2245 int cac_timeout); 2246 2247 /** 2248 * dfs_is_ap_cac_timer_running() - Returns the dfs cac timer. 2249 * @dfs: Pointer to wlan_dfs structure. 2250 */ 2251 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs); 2252 2253 /** 2254 * dfs_cac_timer_attach() - Initialize cac timers. 2255 * @dfs: Pointer to wlan_dfs structure. 2256 */ 2257 void dfs_cac_timer_attach(struct wlan_dfs *dfs); 2258 2259 /** 2260 * dfs_cac_timer_reset() - Cancel dfs cac timers. 2261 * @dfs: Pointer to wlan_dfs structure. 2262 */ 2263 void dfs_cac_timer_reset(struct wlan_dfs *dfs); 2264 2265 /** 2266 * dfs_cac_timer_detach() - Free dfs cac timers. 2267 * @dfs: Pointer to wlan_dfs structure. 2268 */ 2269 void dfs_cac_timer_detach(struct wlan_dfs *dfs); 2270 2271 /** 2272 * dfs_deliver_cac_state_events() - Deliver the DFS CAC events namely 2273 * WLAN_EV_CAC_STARTED on cac started channel(current channel) and 2274 * WLAN_EV_CAC_RESET on previous dfs channel. 2275 * 2276 * @dfs: Pointer to wlan_dfs structure. 2277 */ 2278 #if defined(WLAN_DISP_CHAN_INFO) 2279 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs); 2280 #else 2281 static inline 2282 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs) 2283 { 2284 } 2285 #endif 2286 #else 2287 static inline 2288 void dfs_stacac_stop(struct wlan_dfs *dfs) 2289 { 2290 } 2291 2292 static inline 2293 bool dfs_is_cac_required(struct wlan_dfs *dfs, 2294 struct dfs_channel *cur_chan, 2295 struct dfs_channel *prev_chan, 2296 bool *continue_current_cac, 2297 bool is_vap_restart) 2298 { 2299 return false; 2300 } 2301 2302 static inline 2303 void dfs_cac_stop(struct wlan_dfs *dfs) 2304 { 2305 } 2306 2307 static inline 2308 void dfs_send_dfs_events_for_chan(struct wlan_dfs *dfs, 2309 struct dfs_channel *chan, 2310 enum WLAN_DFS_EVENTS event) 2311 { 2312 } 2313 2314 static inline 2315 void dfs_cancel_cac_timer(struct wlan_dfs *dfs) 2316 { 2317 } 2318 2319 static inline 2320 void dfs_start_cac_timer(struct wlan_dfs *dfs) 2321 { 2322 } 2323 2324 #ifdef CONFIG_CHAN_FREQ_API 2325 static inline 2326 void dfs_cac_valid_reset_for_freq(struct wlan_dfs *dfs, 2327 uint16_t prevchan_freq, 2328 uint32_t prevchan_flags) 2329 { 2330 } 2331 #endif 2332 2333 static inline 2334 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, 2335 int *cac_timeout) 2336 { 2337 return 0; 2338 } 2339 2340 static inline 2341 int dfs_override_cac_timeout(struct wlan_dfs *dfs, 2342 int cac_timeout) 2343 { 2344 return 0; 2345 } 2346 2347 static inline 2348 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs) 2349 { 2350 return 0; 2351 } 2352 2353 static inline 2354 void dfs_cac_timer_attach(struct wlan_dfs *dfs) 2355 { 2356 } 2357 2358 static inline 2359 void dfs_cac_timer_reset(struct wlan_dfs *dfs) 2360 { 2361 } 2362 2363 static inline 2364 void dfs_cac_timer_detach(struct wlan_dfs *dfs) 2365 { 2366 } 2367 2368 static inline 2369 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs) 2370 { 2371 } 2372 #endif 2373 /** 2374 * dfs_set_update_nol_flag() - Sets update_nol flag. 2375 * @dfs: Pointer to wlan_dfs structure. 2376 * @val: update_nol flag. 2377 */ 2378 void dfs_set_update_nol_flag(struct wlan_dfs *dfs, 2379 bool val); 2380 2381 /** 2382 * dfs_get_update_nol_flag() - Returns update_nol flag. 2383 * @dfs: Pointer to wlan_dfs structure. 2384 */ 2385 bool dfs_get_update_nol_flag(struct wlan_dfs *dfs); 2386 2387 /** 2388 * dfs_get_use_nol() - Get usenol. 2389 * @dfs: Pointer to wlan_dfs structure. 2390 */ 2391 int dfs_get_use_nol(struct wlan_dfs *dfs); 2392 2393 /** 2394 * dfs_get_nol_timeout() - Get NOL timeout. 2395 * @dfs: Pointer to wlan_dfs structure. 2396 */ 2397 int dfs_get_nol_timeout(struct wlan_dfs *dfs); 2398 2399 /** 2400 * dfs_control()- Used to process ioctls related to DFS. 2401 * @dfs: Pointer to wlan_dfs structure. 2402 * @id: Command type. 2403 * @indata: Input buffer. 2404 * @insize: size of the input buffer. 2405 * @outdata: A buffer for the results. 2406 * @outsize: Size of the output buffer. 2407 */ 2408 int dfs_control(struct wlan_dfs *dfs, 2409 u_int id, 2410 void *indata, 2411 uint32_t insize, 2412 void *outdata, 2413 uint32_t *outsize); 2414 2415 /** 2416 * dfs_getnol() - Wrapper function for dfs_get_nol() 2417 * @dfs: Pointer to wlan_dfs structure. 2418 * @dfs_nolinfo: Pointer to dfsreq_nolinfo structure. 2419 */ 2420 void dfs_getnol(struct wlan_dfs *dfs, 2421 void *dfs_nolinfo); 2422 2423 /** 2424 * dfs_clear_nolhistory() - unmarks WLAN_CHAN_CLR_HISTORY_RADAR flag for 2425 * all the channels in dfs_ch_channels. 2426 * @dfs: Pointer to wlan_dfs structure. 2427 */ 2428 #if !defined(MOBILE_DFS_SUPPORT) 2429 void dfs_clear_nolhistory(struct wlan_dfs *dfs); 2430 #else 2431 static inline void 2432 dfs_clear_nolhistory(struct wlan_dfs *dfs) 2433 { 2434 } 2435 #endif 2436 2437 /** 2438 * ol_if_dfs_configure() - Initialize the RADAR table for offload chipsets. 2439 * @dfs: Pointer to wlan_dfs structure. 2440 * 2441 * This is called during a channel change or regulatory domain 2442 * reset; in order to fetch the new configuration information and 2443 * program the DFS pattern matching module. 2444 * 2445 * Eventually this should be split into "fetch config" (which can 2446 * happen at regdomain selection time) and "configure DFS" (which 2447 * can happen at channel config time) so as to minimise overheads 2448 * when doing channel changes. However, this'll do for now. 2449 */ 2450 void ol_if_dfs_configure(struct wlan_dfs *dfs); 2451 2452 /** 2453 * dfs_init_radar_filters() - Init Radar filters. 2454 * @dfs: Pointer to wlan_dfs structure. 2455 * @radar_info: Pointer to wlan_dfs_radar_tab_info structure. 2456 */ 2457 int dfs_init_radar_filters(struct wlan_dfs *dfs, 2458 struct wlan_dfs_radar_tab_info *radar_info); 2459 2460 /** 2461 * dfs_print_filters() - Print the filters. 2462 * @dfs: Pointer to wlan_dfs structure. 2463 */ 2464 void dfs_print_filters(struct wlan_dfs *dfs); 2465 2466 /** 2467 * dfs_clear_stats() - Clear stats. 2468 * @dfs: Pointer to wlan_dfs structure. 2469 */ 2470 void dfs_clear_stats(struct wlan_dfs *dfs); 2471 2472 /** 2473 * dfs_radar_disable() - Disables the radar. 2474 * @dfs: Pointer to wlan_dfs structure. 2475 */ 2476 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2477 int dfs_radar_disable(struct wlan_dfs *dfs); 2478 #else 2479 static inline int dfs_radar_disable(struct wlan_dfs *dfs) 2480 { 2481 return 0; 2482 } 2483 #endif 2484 2485 /** 2486 * dfs_get_debug_info() - Get debug info. 2487 * @dfs: Pointer to wlan_dfs structure. 2488 * @data: void pointer to the data to save dfs_proc_phyerr. 2489 */ 2490 int dfs_get_debug_info(struct wlan_dfs *dfs, 2491 void *data); 2492 2493 2494 /** 2495 * dfs_nol_timer_init() - Initialize NOL timers. 2496 * @dfs: Pointer to wlan_dfs structure. 2497 */ 2498 void dfs_nol_timer_init(struct wlan_dfs *dfs); 2499 2500 /** 2501 * dfs_nol_attach() - Initialize NOL variables. 2502 * @dfs: Pointer to wlan_dfs structure. 2503 */ 2504 void dfs_nol_attach(struct wlan_dfs *dfs); 2505 2506 /** 2507 * dfs_nol_detach() - Detach NOL variables. 2508 * @dfs: Pointer to wlan_dfs structure. 2509 */ 2510 void dfs_nol_detach(struct wlan_dfs *dfs); 2511 2512 /** 2513 * dfs_print_nolhistory() - Print NOL history. 2514 * @dfs: Pointer to wlan_dfs structure. 2515 */ 2516 void dfs_print_nolhistory(struct wlan_dfs *dfs); 2517 2518 /** 2519 * dfs_find_precac_secondary_vht80_chan() - Get a VHT80 channel with the 2520 * precac primary center frequency. 2521 * @dfs: Pointer to wlan_dfs structure. 2522 * @chan: Pointer to dfs channel structure. 2523 */ 2524 void dfs_find_precac_secondary_vht80_chan(struct wlan_dfs *dfs, 2525 struct dfs_channel *chan); 2526 2527 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 2528 /** 2529 * dfs_precac_csa() - Automatically switch the channel to the DFS channel 2530 * on which PreCAC was completed without finding a RADAR. 2531 * Use CSA with TBTT_COUNT to switch the channel. 2532 * @dfs: Pointer to dfs handler. 2533 * 2534 * Return: Void 2535 */ 2536 void dfs_precac_csa(struct wlan_dfs *dfs); 2537 #endif 2538 2539 /** 2540 * dfs_phyerr_param_copy() - Function to copy src buf to dest buf. 2541 * @dst: dest buf. 2542 * @src: src buf. 2543 */ 2544 void dfs_phyerr_param_copy(struct wlan_dfs_phyerr_param *dst, 2545 struct wlan_dfs_phyerr_param *src); 2546 2547 /** 2548 * dfs_get_thresholds() - Get the threshold value. 2549 * @dfs: Pointer to wlan_dfs structure. 2550 * @param: Pointer to wlan_dfs_phyerr_param structure. 2551 */ 2552 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2553 int dfs_get_thresholds(struct wlan_dfs *dfs, 2554 struct wlan_dfs_phyerr_param *param); 2555 #else 2556 static inline int dfs_get_thresholds(struct wlan_dfs *dfs, 2557 struct wlan_dfs_phyerr_param *param) 2558 { 2559 return 0; 2560 } 2561 #endif 2562 2563 /** 2564 * dfs_set_thresholds() - Sets the threshold value. 2565 * @dfs: Pointer to wlan_dfs structure. 2566 * @threshtype: DFS ioctl param type. 2567 * @value: Threshold value. 2568 */ 2569 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2570 int dfs_set_thresholds(struct wlan_dfs *dfs, 2571 const uint32_t threshtype, 2572 const uint32_t value); 2573 #else 2574 static inline int dfs_set_thresholds(struct wlan_dfs *dfs, 2575 const uint32_t threshtype, 2576 const uint32_t value) 2577 { 2578 return 0; 2579 } 2580 #endif 2581 2582 /** 2583 * dfs_check_intersect_excl() - Check whether curfreq falls within lower_freq 2584 * and upper_freq, exclusively. 2585 * @low_freq : lower bound frequency value. 2586 * @high_freq: upper bound frequency value. 2587 * @chan_freq: Current frequency value to be checked. 2588 * 2589 * Return: returns true if overlap found, else returns false. 2590 */ 2591 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2592 bool dfs_check_intersect_excl(int low_freq, int high_freq, int chan_freq); 2593 #else 2594 static inline bool dfs_check_intersect_excl(int low_freq, int high_freq, 2595 int chan_freq) 2596 { 2597 return false; 2598 } 2599 #endif 2600 2601 /** 2602 * dfs_check_etsi_overlap() - Check whether given frequency centre/channel 2603 * width entry overlap with frequency spread in any way. 2604 * @center_freq : current channel centre frequency. 2605 * @chan_width : current channel width. 2606 * @en302_502_freq_low : overlap frequency lower bound. 2607 * @en302_502_freq_high : overlap frequency upper bound. 2608 * 2609 * Return: returns 1 if overlap found, else returns 0. 2610 */ 2611 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2612 int dfs_check_etsi_overlap(int center_freq, int chan_width, 2613 int en302_502_freq_low, int en302_502_freq_high); 2614 #else 2615 static inline int dfs_check_etsi_overlap(int center_freq, int chan_width, 2616 int en302_502_freq_low, 2617 int en302_502_freq_high) 2618 { 2619 return 0; 2620 } 2621 #endif 2622 2623 /** 2624 * dfs_is_en302_502_applicable() - Check whether current channel frequecy spread 2625 * overlaps with EN 302 502 radar type 2626 * frequency range. 2627 *@dfs: Pointer to wlan_dfs structure. 2628 * 2629 * Return: returns true if overlap found, else returns false. 2630 */ 2631 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2632 bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs); 2633 #else 2634 static inline bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs) 2635 { 2636 return false; 2637 } 2638 #endif 2639 2640 #ifdef CONFIG_CHAN_FREQ_API 2641 /** 2642 * dfs_set_current_channel_for_freq() - Set DFS current channel. 2643 * @dfs: Pointer to wlan_dfs structure. 2644 * @dfs_chan_freq: Frequency in Mhz. 2645 * @dfs_chan_flags: Channel flags. 2646 * @dfs_chan_flagext: Extended channel flags. 2647 * @dfs_chan_ieee: IEEE channel number. 2648 * @dfs_chan_vhtop_freq_seg1: Channel Center frequency1. 2649 * @dfs_chan_vhtop_freq_seg2: Channel Center frequency2. 2650 * @dfs_chan_mhz_freq_seg1: Channel center frequency of primary segment in MHZ. 2651 * @dfs_chan_mhz_freq_seg2: Channel center frequency of secondary segment in MHZ 2652 * applicable only for 80+80MHZ mode of operation. 2653 * @dfs_chan_op_puncture_bitmap: Static channel puncturing of current channel. 2654 * @is_channel_updated: boolean to represent channel update. 2655 */ 2656 void dfs_set_current_channel_for_freq(struct wlan_dfs *dfs, 2657 uint16_t dfs_chan_freq, 2658 uint64_t dfs_chan_flags, 2659 uint16_t dfs_chan_flagext, 2660 uint8_t dfs_chan_ieee, 2661 uint8_t dfs_chan_vhtop_freq_seg1, 2662 uint8_t dfs_chan_vhtop_freq_seg2, 2663 uint16_t dfs_chan_mhz_freq_seg1, 2664 uint16_t dfs_chan_mhz_freq_seg2, 2665 uint16_t dfs_chan_op_puncture_bitmap, 2666 bool *is_channel_updated); 2667 #endif 2668 /** 2669 * dfs_get_nol_chfreq_and_chwidth() - Get channel freq and width from NOL list. 2670 * @dfs_nol: Pointer to NOL channel entry. 2671 * @nol_chfreq: Pointer to save channel frequency. 2672 * @nol_chwidth: Pointer to save channel width. 2673 * @index: Index to dfs_nol list. 2674 */ 2675 void dfs_get_nol_chfreq_and_chwidth(struct dfsreq_nolelem *dfs_nol, 2676 uint32_t *nol_chfreq, 2677 uint32_t *nol_chwidth, 2678 int index); 2679 2680 /** 2681 * bin5_rules_check_internal() - This is a extension of dfs_bin5_check(). 2682 * @dfs: Pointer to wlan_dfs structure. 2683 * @br: Pointer to dfs_bin5radars structure. 2684 * @bursts: Bursts. 2685 * @numevents: Number of events. 2686 * @prev: prev index. 2687 * @i: Index. 2688 * @this: index to br_elems[] 2689 * @index: index array. 2690 */ 2691 void bin5_rules_check_internal(struct wlan_dfs *dfs, 2692 struct dfs_bin5radars *br, 2693 uint32_t *bursts, 2694 uint32_t *numevents, 2695 uint32_t prev, 2696 uint32_t i, 2697 uint32_t this, 2698 int *index); 2699 2700 /** 2701 * dfs_main_task_testtimer_init() - Initialize dfs task testtimer. 2702 * @dfs: Pointer to wlan_dfs structure. 2703 */ 2704 void dfs_main_task_testtimer_init(struct wlan_dfs *dfs); 2705 2706 /** 2707 * dfs_stop() - Clear dfs timers. 2708 * @dfs: Pointer to wlan_dfs structure. 2709 */ 2710 void dfs_stop(struct wlan_dfs *dfs); 2711 2712 /** 2713 * dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 2714 * @dfs: Pointer to wlan_dfs structure. 2715 * @flags: New channel flags 2716 * @flagext: New Extended flags 2717 */ 2718 void dfs_update_cur_chan_flags(struct wlan_dfs *dfs, 2719 uint64_t flags, 2720 uint16_t flagext); 2721 2722 /** 2723 * wlan_psoc_get_dfs_txops() - Get dfs_tx_ops pointer 2724 * @psoc: Pointer to psoc structure. 2725 * 2726 * Return: Pointer to dfs_tx_ops. 2727 */ 2728 struct wlan_lmac_if_dfs_tx_ops * 2729 wlan_psoc_get_dfs_txops(struct wlan_objmgr_psoc *psoc); 2730 2731 /** 2732 * dfs_nol_free_list() - Free NOL elements. 2733 * @dfs: Pointer to wlan_dfs structure. 2734 */ 2735 void dfs_nol_free_list(struct wlan_dfs *dfs); 2736 2737 /** 2738 * dfs_second_segment_radar_disable() - Disables the second segment radar. 2739 * @dfs: Pointer to wlan_dfs structure. 2740 * 2741 * This is called when AP detects the radar, to (potentially) disable 2742 * the radar code. 2743 * 2744 * Return: returns 0. 2745 */ 2746 int dfs_second_segment_radar_disable(struct wlan_dfs *dfs); 2747 2748 /** 2749 * dfs_fetch_nol_ie_info() - Fill NOL information to be sent with RCSA. 2750 * @dfs: Pointer to wlan_dfs structure. 2751 * @nol_ie_bandwidth: Minimum subchannel bandwidth. 2752 * @nol_ie_startfreq: Radar affected channel list's first subchannel's 2753 * centre frequency. 2754 * @nol_ie_bitmap: NOL bitmap denoting affected subchannels. 2755 */ 2756 #if defined(QCA_DFS_RCSA_SUPPORT) 2757 void dfs_fetch_nol_ie_info(struct wlan_dfs *dfs, uint8_t *nol_ie_bandwidth, 2758 uint16_t *nol_ie_startfreq, uint8_t *nol_ie_bitmap); 2759 #else 2760 static inline 2761 void dfs_fetch_nol_ie_info(struct wlan_dfs *dfs, uint8_t *nol_ie_bandwidth, 2762 uint16_t *nol_ie_startfreq, uint8_t *nol_ie_bitmap) 2763 { 2764 *nol_ie_bandwidth = 0; 2765 *nol_ie_startfreq = 0; 2766 *nol_ie_bitmap = 0; 2767 } 2768 #endif 2769 2770 /** 2771 * dfs_set_rcsa_flags() - Set flags that are required for sending RCSA and 2772 * NOL IE. 2773 * @dfs: Pointer to wlan_dfs structure. 2774 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 2775 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 2776 */ 2777 #if defined(QCA_DFS_RCSA_SUPPORT) 2778 void dfs_set_rcsa_flags(struct wlan_dfs *dfs, bool is_rcsa_ie_sent, 2779 bool is_nol_ie_sent); 2780 #else 2781 static inline 2782 void dfs_set_rcsa_flags(struct wlan_dfs *dfs, bool is_rcsa_ie_sent, 2783 bool is_nol_ie_sent) 2784 { 2785 } 2786 #endif 2787 2788 /** 2789 * dfs_get_rcsa_flags() - Get flags that are required for sending RCSA and 2790 * NOL IE. 2791 * @dfs: Pointer to wlan_dfs structure. 2792 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 2793 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 2794 */ 2795 #if defined(QCA_DFS_RCSA_SUPPORT) 2796 void dfs_get_rcsa_flags(struct wlan_dfs *dfs, bool *is_rcsa_ie_sent, 2797 bool *is_nol_ie_sent); 2798 #else 2799 static inline 2800 void dfs_get_rcsa_flags(struct wlan_dfs *dfs, bool *is_rcsa_ie_sent, 2801 bool *is_nol_ie_sent) 2802 { 2803 *is_rcsa_ie_sent = false; 2804 *is_nol_ie_sent = false; 2805 } 2806 #endif 2807 2808 /** 2809 * dfs_process_nol_ie_bitmap() - Update NOL with external radar information. 2810 * @dfs: Pointer to wlan_dfs structure. 2811 * @nol_ie_bandwidth: Minimum subchannel bandwidth. 2812 * @nol_ie_startfreq: Radar affected channel list's first subchannel's 2813 * centre frequency. 2814 * @nol_ie_bitmap: Bitmap denoting radar affected subchannels. 2815 * 2816 * Return: True if NOL IE should be propagated, else false. 2817 */ 2818 #if defined(QCA_DFS_RCSA_SUPPORT) 2819 bool dfs_process_nol_ie_bitmap(struct wlan_dfs *dfs, uint8_t nol_ie_bandwidth, 2820 uint16_t nol_ie_startfreq, 2821 uint8_t nol_ie_bitmap); 2822 #else 2823 static inline 2824 bool dfs_process_nol_ie_bitmap(struct wlan_dfs *dfs, uint8_t nol_ie_bandwidth, 2825 uint16_t nol_ie_startfreq, 2826 uint8_t nol_ie_bitmap) 2827 { 2828 return false; 2829 } 2830 #endif 2831 2832 /** 2833 * dfs_task_testtimer_reset() - stop dfs test timer. 2834 * @dfs: Pointer to wlan_dfs structure. 2835 */ 2836 void dfs_task_testtimer_reset(struct wlan_dfs *dfs); 2837 2838 /** 2839 * dfs_is_freq_in_nol() - check if given channel in nol list 2840 * @dfs: Pointer to wlan_dfs structure 2841 * @freq: channel frequency 2842 * 2843 * check if given channel in nol list. 2844 * 2845 * Return: true if channel in nol, false else 2846 */ 2847 bool dfs_is_freq_in_nol(struct wlan_dfs *dfs, uint32_t freq); 2848 2849 /** 2850 * dfs_task_testtimer_detach() - Free dfs test timer. 2851 * @dfs: Pointer to wlan_dfs structure. 2852 */ 2853 void dfs_task_testtimer_detach(struct wlan_dfs *dfs); 2854 2855 /** 2856 * dfs_timer_detach() - Free dfs timers. 2857 * @dfs: Pointer to wlan_dfs structure. 2858 */ 2859 void dfs_timer_detach(struct wlan_dfs *dfs); 2860 2861 /** 2862 * dfs_is_disable_radar_marking_set() - Check if radar marking is set on 2863 * NOL chan. 2864 * @dfs: Pointer to wlan_dfs structure. 2865 * @disable_radar_marking: Is radar marking disabled. 2866 */ 2867 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 2868 int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs, 2869 bool *disable_radar_marking); 2870 #else 2871 static inline int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs, 2872 bool *disable_radar_marking) 2873 { 2874 return QDF_STATUS_SUCCESS; 2875 } 2876 #endif 2877 /** 2878 * dfs_get_disable_radar_marking() - Get the value of disable radar marking. 2879 * @dfs: Pointer to wlan_dfs structure. 2880 */ 2881 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 2882 bool dfs_get_disable_radar_marking(struct wlan_dfs *dfs); 2883 #else 2884 static inline bool dfs_get_disable_radar_marking(struct wlan_dfs *dfs) 2885 { 2886 return false; 2887 } 2888 #endif 2889 2890 /** 2891 * dfs_reset_agile_config() - Reset the ADFS config variables. 2892 * @dfs_soc: Pointer to dfs_soc_priv_obj. 2893 */ 2894 #ifdef QCA_SUPPORT_AGILE_DFS 2895 void dfs_reset_agile_config(struct dfs_soc_priv_obj *dfs_soc); 2896 #endif 2897 2898 /** 2899 * dfs_reinit_timers() - Reinit timers in DFS. 2900 * @dfs: Pointer to wlan_dfs. 2901 */ 2902 int dfs_reinit_timers(struct wlan_dfs *dfs); 2903 2904 /** 2905 * dfs_reset_dfs_prevchan() - Reset DFS previous channel structure. 2906 * @dfs: Pointer to wlan_dfs object. 2907 * 2908 * Return: None. 2909 */ 2910 void dfs_reset_dfs_prevchan(struct wlan_dfs *dfs); 2911 2912 /** 2913 * dfs_init_tmp_psoc_nol() - Init temporary psoc NOL structure. 2914 * @dfs: Pointer to wlan_dfs object. 2915 * @num_radios: Num of radios in the PSOC. 2916 * 2917 * Return: void. 2918 */ 2919 void dfs_init_tmp_psoc_nol(struct wlan_dfs *dfs, uint8_t num_radios); 2920 2921 /** 2922 * dfs_deinit_tmp_psoc_nol() - De-init temporary psoc NOL structure. 2923 * @dfs: Pointer to wlan_dfs object. 2924 * 2925 * Return: void. 2926 */ 2927 void dfs_deinit_tmp_psoc_nol(struct wlan_dfs *dfs); 2928 2929 /** 2930 * dfs_save_dfs_nol_in_psoc() - Save NOL data of given pdev. 2931 * @dfs: Pointer to wlan_dfs object. 2932 * @pdev_id: The pdev ID which will have the NOL data. 2933 * 2934 * Based on the frequency of the NOL channel, copy it to the target pdev_id 2935 * structure in psoc. 2936 * 2937 * Return: void. 2938 */ 2939 void dfs_save_dfs_nol_in_psoc(struct wlan_dfs *dfs, uint8_t pdev_id); 2940 2941 /** 2942 * dfs_reinit_nol_from_psoc_copy() - Reinit saved NOL data to corresponding 2943 * DFS object. 2944 * @dfs: Pointer to wlan_dfs object. 2945 * @pdev_id: pdev_id of the given dfs object. 2946 * @low_5ghz_freq: The low 5GHz frequency value of the target pdev id. 2947 * @high_5ghz_freq: The high 5GHz frequency value of the target pdev id. 2948 * 2949 * Return: void. 2950 */ 2951 void dfs_reinit_nol_from_psoc_copy(struct wlan_dfs *dfs, 2952 uint8_t pdev_id, 2953 uint16_t low_5ghz_freq, 2954 uint16_t high_5ghz_freq); 2955 2956 /** 2957 * dfs_is_hw_mode_switch_in_progress() - Check if HW mode switch in progress. 2958 * @dfs: Pointer to wlan_dfs object. 2959 * 2960 * Return: True if mode switch is in progress, else false. 2961 */ 2962 #ifdef QCA_HW_MODE_SWITCH 2963 bool dfs_is_hw_mode_switch_in_progress(struct wlan_dfs *dfs); 2964 #else 2965 static inline 2966 bool dfs_is_hw_mode_switch_in_progress(struct wlan_dfs *dfs) 2967 { 2968 return false; 2969 } 2970 #endif 2971 2972 /** 2973 * dfs_start_mode_switch_defer_timer() - start mode switch defer timer. 2974 * @dfs: Pointer to wlan_dfs object. 2975 * 2976 * Return: void. 2977 */ 2978 void dfs_start_mode_switch_defer_timer(struct wlan_dfs *dfs); 2979 2980 /** 2981 * dfs_complete_deferred_tasks() - Process mode switch completion event and 2982 * handle deferred tasks. 2983 * @dfs: Pointer to wlan_dfs object. 2984 * 2985 * Return: void. 2986 */ 2987 void dfs_complete_deferred_tasks(struct wlan_dfs *dfs); 2988 2989 /** 2990 * dfs_process_cac_completion() - Process DFS CAC completion event. 2991 * @dfs: Pointer to wlan_dfs object. 2992 * 2993 * Return: void. 2994 */ 2995 void dfs_process_cac_completion(struct wlan_dfs *dfs); 2996 2997 #ifdef WLAN_DFS_TRUE_160MHZ_SUPPORT 2998 /** 2999 * dfs_is_true_160mhz_supported() - Find if true 160MHz is supported. 3000 * @dfs: Pointer to wlan_dfs object. 3001 * 3002 * Return: True if true 160MHz is supported, else false. 3003 */ 3004 bool dfs_is_true_160mhz_supported(struct wlan_dfs *dfs); 3005 3006 /** 3007 * dfs_is_restricted_80p80mhz_supported() - Find if restricted 80p80mhz is 3008 * supported. 3009 * @dfs: Pointer to wlan_dfs object. 3010 * 3011 * Return: True if restricted 160MHz is supported, else false. 3012 */ 3013 bool dfs_is_restricted_80p80mhz_supported(struct wlan_dfs *dfs); 3014 #else 3015 static inline bool dfs_is_true_160mhz_supported(struct wlan_dfs *dfs) 3016 { 3017 return false; 3018 } 3019 3020 static inline bool dfs_is_restricted_80p80mhz_supported(struct wlan_dfs *dfs) 3021 { 3022 return false; 3023 } 3024 #endif /* WLAN_DFS_TRUE_160MHZ_SUPPORT */ 3025 3026 /** 3027 * dfs_get_agile_detector_id() - Find the Agile detector ID for given DFS. 3028 * @dfs: Pointer to wlan_dfs object. 3029 * 3030 * Return: Agile detector value (uint8_t). 3031 */ 3032 #ifdef QCA_SUPPORT_AGILE_DFS 3033 uint8_t dfs_get_agile_detector_id(struct wlan_dfs *dfs); 3034 #else 3035 static inline uint8_t dfs_get_agile_detector_id(struct wlan_dfs *dfs) 3036 { 3037 return INVALID_DETECTOR_ID; 3038 } 3039 #endif 3040 3041 /** 3042 * dfs_is_new_chan_subset_of_old_chan() - Find if new channel is subset of 3043 * old channel. 3044 * @dfs: Pointer to wlan_dfs structure. 3045 * @new_chan: Pointer to new channel of dfs_channel structure. 3046 * @old_chan: Pointer to old channel of dfs_channel structure. 3047 * 3048 * Return: True if new channel is subset of old channel, else false. 3049 */ 3050 bool dfs_is_new_chan_subset_of_old_chan(struct wlan_dfs *dfs, 3051 struct dfs_channel *new_chan, 3052 struct dfs_channel *old_chan); 3053 3054 /** 3055 * dfs_find_dfs_sub_channels_for_freq() - Given a dfs channel, find its 3056 * HT20 subset channels. 3057 * @dfs: Pointer to wlan_dfs structure. 3058 * @chan: Pointer to dfs_channel structure. 3059 * @subchan_arr: Pointer to subchannels array. 3060 * 3061 * Return: Number of sub channels. 3062 */ 3063 uint8_t dfs_find_dfs_sub_channels_for_freq(struct wlan_dfs *dfs, 3064 struct dfs_channel *chan, 3065 uint16_t *subchan_arr); 3066 3067 /** 3068 * dfs_clear_cac_started_chan() - Clear dfs cac started channel. 3069 * @dfs: Pointer to wlan_dfs structure. 3070 */ 3071 void dfs_clear_cac_started_chan(struct wlan_dfs *dfs); 3072 3073 #ifdef QCA_DFS_BANGRADAR 3074 /** 3075 * dfs_bang_radar() - Handles all type of Bangradar. 3076 * @dfs: Pointer to wlan_dfs structure. 3077 * @indata: reference to input data 3078 * @insize: input data size 3079 * 3080 */ 3081 int dfs_bang_radar(struct wlan_dfs *dfs, void *indata, uint32_t insize); 3082 #else 3083 static inline int 3084 dfs_bang_radar(struct wlan_dfs *dfs, void *indata, uint32_t insize) 3085 { 3086 return 0; 3087 } 3088 #endif 3089 3090 #if defined(QCA_SUPPORT_DFS_CHAN_POSTNOL) 3091 void dfs_postnol_attach(struct wlan_dfs *dfs); 3092 #else 3093 static inline void dfs_postnol_attach(struct wlan_dfs *dfs) 3094 { 3095 } 3096 #endif 3097 3098 #ifdef CONFIG_HOST_FIND_CHAN 3099 /** 3100 * wlan_is_chan_radar() - Checks if a given dfs channel is in NOL or not. 3101 * @dfs: Pointer to wlan_dfs structure. 3102 * @chan: Pointer to the dfs channel structure. 3103 * 3104 * Return: True if the channel has detected radar, else false. 3105 */ 3106 bool wlan_is_chan_radar(struct wlan_dfs *dfs, struct dfs_channel *chan); 3107 3108 /** 3109 * wlan_is_chan_history_radar() - Checks if a given dfs channel is in NOL 3110 * history or not. 3111 * @dfs: Pointer to wlan_dfs structure. 3112 * @chan: Pointer to the dfs channel structure. 3113 * 3114 * Return: True if the channel is marked as radar history, else false. 3115 */ 3116 bool wlan_is_chan_history_radar(struct wlan_dfs *dfs, struct dfs_channel *chan); 3117 #else 3118 static inline bool 3119 wlan_is_chan_radar(struct wlan_dfs *dfs, struct dfs_channel *chan) 3120 { 3121 return false; 3122 } 3123 3124 static inline bool 3125 wlan_is_chan_history_radar(struct wlan_dfs *dfs, struct dfs_channel *chan) 3126 { 3127 return false; 3128 } 3129 #endif /* CONFIG_HOST_FIND_CHAN */ 3130 3131 #if defined(QCA_SUPPORT_ADFS_RCAC) && \ 3132 defined(WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT) && \ 3133 defined(QCA_SUPPORT_AGILE_DFS) 3134 /** 3135 * dfs_restart_rcac_on_nol_expiry() - If the chosen desired channel is 3136 * radar infected during RCAC, trigger RCAC on desired channel after 3137 * NOL expiry. 3138 * @dfs: Pointer to wlan_dfs structure. 3139 * 3140 * Return: True if rcac is started, false otherwise 3141 */ 3142 bool dfs_restart_rcac_on_nol_expiry(struct wlan_dfs *dfs); 3143 #else 3144 static inline bool 3145 dfs_restart_rcac_on_nol_expiry(struct wlan_dfs *dfs) 3146 { 3147 return false; 3148 } 3149 #endif 3150 3151 /** 3152 * dfs_chan_to_ch_width() - Outputs the channel width in MHz of the given input 3153 * dfs_channel. 3154 * @chan: Pointer to the input dfs_channel structure. 3155 * 3156 * Return: Channel width in MHz. (uint16) -EINVAL on invalid channel. 3157 */ 3158 uint16_t dfs_chan_to_ch_width(struct dfs_channel *chan); 3159 #endif /* _DFS_H_ */ 3160