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