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 * @dfs_ch_punc_pattern: Bitmap representing puncturing patterns. 718 */ 719 struct dfs_channel { 720 uint16_t dfs_ch_freq; 721 uint64_t dfs_ch_flags; 722 uint16_t dfs_ch_flagext; 723 uint8_t dfs_ch_ieee; 724 uint8_t dfs_ch_vhtop_ch_freq_seg1; 725 uint8_t dfs_ch_vhtop_ch_freq_seg2; 726 uint16_t dfs_ch_mhz_freq_seg1; 727 uint16_t dfs_ch_mhz_freq_seg2; 728 #ifdef WLAN_FEATURE_11BE 729 /* If the bitmap is all 0 then nothing is punctured. If any bit is 1 730 * then corresponding 20MHz sub-channel is puntured. For example, for 731 * channel 100 (BW 240MHz), it will treated as a 320MHz channel and the 732 * bit-map will be b1111_0000_0000_0000 (where the most significant bit 733 * indicates the rightmost sub20channel and the least significant bit 734 * indicates the leftmost sub20channel). 735 */ 736 uint16_t dfs_ch_punc_pattern; 737 #endif 738 }; 739 740 /** 741 * struct dfs_state - DFS state. 742 * @rs_chan: Channel info. 743 * @rs_chanindex: Channel index in radar structure. 744 * @rs_numradarevents: Number of radar events. 745 * @rs_param: Phy param. 746 */ 747 struct dfs_state { 748 struct dfs_channel rs_chan; 749 uint8_t rs_chanindex; 750 uint32_t rs_numradarevents; 751 struct wlan_dfs_phyerr_param rs_param; 752 }; 753 754 #define DFS_NOL_TIMEOUT_S (30*60) /* 30 minutes in seconds */ 755 #define DFS_NOL_TIMEOUT_MS (DFS_NOL_TIMEOUT_S * 1000) 756 #define DFS_NOL_TIMEOUT_US (DFS_NOL_TIMEOUT_MS * 1000) 757 758 /** 759 * struct dfs_nolelem - DFS NOL element. 760 * @nol_dfs Back pointer to dfs object. 761 * @nol_freq: Centre frequency. 762 * @nol_chwidth: Event width (MHz). 763 * @nol_start_us: NOL start time in us. 764 * @nol_timeout_ms: NOL timeout value in msec. 765 * @nol_timer: Per element NOL timer. 766 * @nol_next: Next element pointer. 767 */ 768 struct dfs_nolelem { 769 TAILQ_ENTRY(dfs_nolelem) nolelem_list; 770 struct wlan_dfs *nol_dfs; 771 uint32_t nol_freq; 772 uint32_t nol_chwidth; 773 uint64_t nol_start_us; 774 uint32_t nol_timeout_ms; 775 qdf_timer_t nol_timer; 776 struct dfs_nolelem *nol_next; 777 }; 778 779 780 /** 781 * struct dfs_info - DFS Info. 782 * @rn_ftindex: Number of different types of radars. 783 * @rn_lastfull_ts: Last 64 bit timstamp from recv interrupt. 784 * @rn_last_ts: last 15 bit ts from recv descriptor. 785 * @rn_last_unique_ts: last unique 32 bit ts from recv descriptor. 786 * @rn_ts_prefix: Prefix to prepend to 15 bit recv ts. 787 * @rn_numbin5radars: Number of bin5 radar pulses to search for. 788 * @rn_fastdivGCval: Value of fast diversity gc limit from init file. 789 * @rn_minrssithresh: Min rssi for all radar types. 790 * @rn_maxpulsedur: Max pulse width in TSF ticks. 791 * @dfs_ext_chan_busy: Ext chan busy. 792 * @ext_chan_busy_ts: Ext chan busy time. 793 * @dfs_bin5_chirp_ts: Ext bin5 chrip time. 794 * @dfs_last_bin5_dur: Last bin5 during. 795 */ 796 struct dfs_info { 797 uint32_t rn_ftindex; 798 uint64_t rn_lastfull_ts; 799 uint16_t rn_last_ts; 800 uint32_t rn_last_unique_ts; 801 uint64_t rn_ts_prefix; 802 uint32_t rn_numbin5radars; 803 uint32_t rn_fastdivGCval; 804 int32_t rn_minrssithresh; 805 uint32_t rn_maxpulsedur; 806 uint8_t dfs_ext_chan_busy; 807 uint64_t ext_chan_busy_ts; 808 uint64_t dfs_bin5_chirp_ts; 809 uint8_t dfs_last_bin5_dur; 810 } qdf_packed; 811 812 /** 813 * struct dfs_bin5elem - BIN5 elements. 814 * @be_ts: Timestamp for the bin5 element. 815 * @be_rssi: Rssi for the bin5 element. 816 * @be_dur: Duration of bin5 element. 817 */ 818 struct dfs_bin5elem { 819 uint64_t be_ts; 820 uint32_t be_rssi; 821 uint32_t be_dur; 822 }; 823 824 /** 825 * struct dfs_bin5radars - BIN5 radars. 826 * @br_elems[]: List of bin5 elems that fall within the time window. 827 * @br_firstelem: Index of the first element. 828 * @br_lastelem: Index of the last element. 829 * @br_numelems: Number of elements in the delay line. 830 * @br_pulse: Original info about bin5 pulse. 831 */ 832 struct dfs_bin5radars { 833 struct dfs_bin5elem br_elems[DFS_MAX_B5_SIZE]; 834 uint32_t br_firstelem; 835 uint32_t br_lastelem; 836 uint32_t br_numelems; 837 struct dfs_bin5pulse br_pulse; 838 }; 839 840 /** 841 * struct dfs_stats - DFS stats. 842 * @num_radar_detects: Total num. of radar detects. 843 * @num_seg_two_radar_detects: Total num. of radar detected in secondary segment 844 * @total_phy_errors: Total PHY errors. 845 * @owl_phy_errors: OWL PHY errors. 846 * @pri_phy_errors: Primary channel phy errors. 847 * @ext_phy_errors: Extension channel phy errors. 848 * @dc_phy_errors: DC PHY errors. 849 * @early_ext_phy_errors: Extension channel early radar found error. 850 * @bwinfo_errors: Bogus bandwidth info received in descriptor. 851 * @datalen_discards: data length at least three bytes of payload. 852 * @rssi_discards: RSSI is not accurate. 853 * @last_reset_tstamp: Last reset timestamp. 854 */ 855 struct dfs_stats { 856 uint32_t num_radar_detects; 857 uint32_t num_seg_two_radar_detects; 858 uint32_t total_phy_errors; 859 uint32_t owl_phy_errors; 860 uint32_t pri_phy_errors; 861 uint32_t ext_phy_errors; 862 uint32_t dc_phy_errors; 863 uint32_t early_ext_phy_errors; 864 uint32_t bwinfo_errors; 865 uint32_t datalen_discards; 866 uint32_t rssi_discards; 867 uint64_t last_reset_tstamp; 868 }; 869 870 #define DFS_EVENT_LOG_SIZE 256 871 872 /** 873 * struct dfs_event_log - DFS event log. 874 * @ts: 64-bit full timestamp from interrupt time. 875 * @diff_ts: Diff timestamp. 876 * @rssi: Rssi of radar event. 877 * @dur: Duration of radar pulse. 878 * @is_chirp: Chirp flag. 879 * @seg_id: HT80_80/HT160 use. 880 * @sidx: Seg index. 881 * @freq_offset_khz: Freq offset in KHz 882 * @peak_mag: Peak mag. 883 * @total_gain: Total gain. 884 * @mb_gain: Mb gain. 885 * @relpwr_db: Relpower in db. 886 * @delta_diff: Delta diff. 887 * @delta_peak: Delta peak. 888 * @psidx_diff: Psidx diff. 889 */ 890 891 struct dfs_event_log { 892 uint64_t ts; 893 uint32_t diff_ts; 894 uint8_t rssi; 895 uint8_t dur; 896 int is_chirp; 897 uint8_t seg_id; 898 int sidx; 899 u_int freq_offset_khz; 900 int peak_mag; 901 int total_gain; 902 int mb_gain; 903 int relpwr_db; 904 uint8_t delta_diff; 905 int8_t delta_peak; 906 int16_t psidx_diff; 907 }; 908 909 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN 10 /*10 minutes*/ 910 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_S (WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN * 60) 911 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MS \ 912 ((WLAN_DFS_WEATHER_CHANNEL_WAIT_S) * 1000) /*in MS*/ 913 914 #define WLAN_DFS_WAIT_POLL_PERIOD 2 /* 2 seconds */ 915 #define WLAN_DFS_WAIT_POLL_PERIOD_MS \ 916 ((WLAN_DFS_WAIT_POLL_PERIOD) * 1000) /*in MS*/ 917 918 #define DFS_DEBUG_TIMEOUT_S 30 /* debug timeout is 30 seconds */ 919 #define DFS_DEBUG_TIMEOUT_MS (DFS_DEBUG_TIMEOUT_S * 1000) 920 921 #define RSSI_POSSIBLY_FALSE 50 922 #define SEARCH_FFT_REPORT_PEAK_MAG_THRSH 40 923 924 #define MIN_DFS_SUBCHAN_BW 20 /* Minimum bandwidth of each subchannel. */ 925 926 #define FREQ_OFFSET_BOUNDARY_FOR_80MHZ 40 927 928 #define FREQ_OFFSET_BOUNDARY_FOR_160MHZ 80 929 930 /** 931 * struct dfs_mode_switch_defer_params - Parameters storing DFS information 932 * before defer, as part of HW mode switch. 933 * 934 * @radar_params: Deferred radar parameters. 935 * @is_cac_completed: Boolean representing CAC completion event. 936 * @is_radar_detected: Boolean representing radar event. 937 */ 938 struct dfs_mode_switch_defer_params { 939 struct radar_found_info *radar_params; 940 bool is_cac_completed; 941 bool is_radar_detected; 942 }; 943 944 #ifdef QCA_SUPPORT_AGILE_DFS 945 #define DFS_PSOC_NO_IDX 0xFF 946 /** 947 * enum dfs_agile_sm_state - DFS AGILE SM states. 948 * @DFS_AGILE_S_INIT: Default state or the start state of the Agile SM. 949 * @DFS_AGILE_S_RUNNING: Agile Engine is being run. 950 * @DFS_AGILE_S_COMPLETE: The Agile Engine's minimum run is complete. 951 However, it is still running. Used only for RCAC 952 as RCAC needs to run continuously (uninterrupted) 953 until the channel change. 954 * @DFS_AGILE_S_MAX: Max (invalid) state. 955 */ 956 enum dfs_agile_sm_state { 957 DFS_AGILE_S_INIT, 958 DFS_AGILE_S_RUNNING, 959 DFS_AGILE_S_COMPLETE, 960 DFS_AGILE_S_MAX, 961 }; 962 963 /** 964 * struct dfs_rcac_params - DFS Rolling CAC channel parameters. 965 * @rcac_pri_freq: Rolling CAC channel's primary frequency. 966 * @rcac_ch_params: Rolling CAC channel parameters. 967 */ 968 struct dfs_rcac_params { 969 qdf_freq_t rcac_pri_freq; 970 struct ch_params rcac_ch_params; 971 }; 972 #endif 973 974 /** 975 * struct wlan_dfs - The main dfs structure. 976 * @dfs_debug_mask: Current debug bitmask. 977 * @dfs_curchan_radindex: Current channel radar index. 978 * @dfs_extchan_radindex: Extension channel radar index. 979 * @dfsdomain: Current DFS domain. 980 * @dfs_proc_phyerr: Flags for Phy Errs to process. 981 * @dfs_eventq: Q of free dfs event objects. 982 * @dfs_eventqlock: Lock for free dfs event list. 983 * @dfs_radarq: Q of radar events. 984 * @dfs_radarqlock: Lock for dfs q. 985 * @dfs_arq: Q of AR events. 986 * @dfs_arqlock: Lock for AR q. 987 * @dfs_ar_state: AR state. 988 * @dfs_radar[]: Per-Channel Radar detector state. 989 * @dfs_radarf[]: One filter for each radar pulse type. 990 * @dfs_rinfo: State vars for radar processing. 991 * @dfs_b5radars: Array of bin5 radar events. 992 * @dfs_ftindextable: Map of radar durs to filter types. 993 * @dfs_nol: Non occupancy list for radar. 994 * @dfs_nol_count: How many items? 995 * @dfs_defaultparams: Default phy params per radar state. 996 * @wlan_dfs_stats: DFS related stats. 997 * @pulses: Pulse history. 998 * @events: Events structure. 999 * @wlan_radar_tasksched: Radar task is scheduled. 1000 * @wlan_dfswait: Waiting on channel for radar detect. 1001 * @wlan_dfstest: Test timer in progress. 1002 * @dfs_caps: Object of wlan_dfs_caps structure. 1003 * @wlan_dfstest_ieeechan: IEEE chan num to return to after a dfs mute 1004 * test. 1005 * @wlan_dfs_cac_time: CAC period. 1006 * @wlan_dfstesttime: Time to stay off chan during dfs test. 1007 * @wlan_dfswaittimer: Dfs wait timer. 1008 * @wlan_dfstesttimer: Dfs mute test timer. 1009 * @wlan_dfs_debug_timer: Dfs debug timer. 1010 * @dfs_bangradar_type: Radar simulation type. 1011 * @is_radar_found_on_secondary_seg: Radar on second segment. 1012 * @is_radar_during_precac: Radar found during precac. 1013 * @dfs_precac_lock: Lock to protect precac lists. 1014 * @dfs_precac_secondary_freq_mhz: Second segment freq in MHZ for precac. 1015 * Applicable to only legacy chips. 1016 * @dfs_precac_primary_freq_mhz: PreCAC Primary freq in MHZ applicable only 1017 * to legacy chips. 1018 * @dfs_defer_precac_channel_change: Defer precac channel change. 1019 * @dfs_precac_inter_chan_freq: Intermediate non-DFS freq used while 1020 * doing precac. 1021 * @dfs_autoswitch_chan: Desired channel of dfs_channel structure 1022 * which will be prioritized for preCAC. 1023 * @dfs_autoswitch_des_mode: Desired PHY mode which has to be used 1024 * after precac. 1025 * @dfs_pre_cac_timeout_channel_change: Channel change due to precac timeout. 1026 * @wlan_dfs_task_timer: Dfs wait timer. 1027 * @dur_multiplier: Duration multiplier. 1028 * @wlan_dfs_isdfsregdomain: True when AP is in DFS domain 1029 * @wlan_dfs_false_rssi_thres: False RSSI Threshold. 1030 * @wlan_dfs_peak_mag: Peak mag. 1031 * @radar_log[]: Radar log. 1032 * @dfs_event_log_count: Event log count. 1033 * @dfs_event_log_on: Event log on. 1034 * @dfs_phyerr_count: Same as number of PHY radar interrupts. 1035 * @dfs_phyerr_reject_count: When TLV is supported, # of radar events 1036 * ignored after TLV is parsed. 1037 * @dfs_phyerr_queued_count: Number of radar events queued for matching 1038 * the filters. 1039 * @dfs_phyerr_freq_min: Phyerr min freq. 1040 * @dfs_phyerr_freq_max: Phyerr max freq. 1041 * @dfs_phyerr_w53_counter: Phyerr w53 counter. 1042 * @dfs_pri_multiplier: Allow pulse if they are within multiple of 1043 * PRI for the radar type. 1044 * @wlan_dfs_nol_timeout: NOL timeout. 1045 * @update_nol: Update NOL. 1046 * @dfs_seq_num: Sequence number. 1047 * @dfs_nol_event[]: NOL event. 1048 * @dfs_nol_timer: NOL list processing. 1049 * @dfs_nol_free_list: NOL free list. 1050 * @dfs_nol_elem_free_work: The work queue to free an NOL element. 1051 * @dfs_cac_timer: CAC timer. 1052 * @dfs_cac_valid_timer: Ignore CAC when this timer is running. 1053 * @dfs_cac_timeout_override: Overridden cac timeout. 1054 * @dfs_enable: DFS Enable. 1055 * @dfs_cac_timer_running: DFS CAC timer running. 1056 * @dfs_ignore_dfs: Ignore DFS. 1057 * @dfs_ignore_cac: Ignore CAC. 1058 * @dfs_cac_valid: DFS CAC valid. 1059 * @dfs_cac_valid_time: Time for which CAC will be valid and will 1060 * not be re-done. 1061 * @dfs_precac_timeout_override: Overridden precac timeout. 1062 * @dfs_num_precac_freqs: Number of PreCAC VHT80 frequencies. 1063 * @dfs_precac_list: PreCAC list (contains individual trees). 1064 * @dfs_precac_chwidth: PreCAC channel width enum. 1065 * @dfs_curchan: DFS current channel. 1066 * @dfs_prevchan: DFS previous channel. 1067 * @dfs_cac_started_chan: CAC started channel. 1068 * @dfs_pdev_obj: DFS pdev object. 1069 * @dfs_is_offload_enabled: Set if DFS offload enabled. 1070 * @dfs_is_radar_found_chan_freq_eq_center_freq: 1071 * Set if chan_freq parameter of the radar 1072 * found wmi event indicates channel center. 1073 * @dfs_agile_precac_freq_mhz: Freq in MHZ configured on Agile DFS engine. 1074 * @dfs_use_nol: Use the NOL when radar found(default: TRUE) 1075 * @dfs_nol_lock: Lock to protect nol list. 1076 * @tx_leakage_threshold: Tx leakage threshold for dfs. 1077 * @dfs_use_nol_subchannel_marking: Use subchannel marking logic to add only 1078 * radar affected subchannel instead of all 1079 * bonding channels. 1080 * @dfs_host_wait_timer: The timer that is started from host after 1081 * sending the average radar parameters. 1082 * Before this timeout host expects its dfs 1083 * status from fw. 1084 * @dfs_average_pri: Average pri value of the received radar 1085 * pulses. 1086 * @dfs_average_duration: Average duration of the received radar 1087 * pulses. 1088 * @dfs_average_sidx: Average sidx of the received radar pulses. 1089 * @dfs_is_host_wait_running: Indicates if host dfs status wait timer is 1090 * running. 1091 * @dfs_average_params_sent: Indicates if host has sent the average 1092 * radar parameters. 1093 * @dfs_no_res_from_fw: Indicates no response from fw. 1094 * @dfs_spoof_check_failed: Indicates if the spoof check has failed. 1095 * @dfs_spoof_test_done: Indicates if the sppof test is done. 1096 * @dfs_status_timeout_override: Used to change the timeout value of 1097 * dfs_host_wait_timer. 1098 * @dfs_is_stadfs_enabled: Is STADFS enabled. 1099 * @dfs_min_sidx: Minimum sidx of the received radar pulses. 1100 * @dfs_max_sidx: Maximum sidx of the received radar pulses. 1101 * @dfs_seg_id: Segment ID of the radar hit channel. 1102 * @dfs_is_chirp: Radar Chirp in pulse present or not. 1103 * @dfs_bw_reduced: DFS bandwidth reduced channel bit. 1104 * @dfs_freq_offset: Frequency offset where radar was found. 1105 * @dfs_cac_aborted: DFS cac is aborted. 1106 * @dfs_disable_radar_marking: To mark or unmark NOL chan as radar hit. 1107 * @dfs_data_struct_lock: DFS data structure lock. This is to protect 1108 * all the filtering data structures. For 1109 * example: dfs_bin5radars, dfs_filtertype, 1110 * etc. 1111 * @dfs_nol_ie_bandwidth: Minimum Bandwidth of subchannels that 1112 * are added to NOL. 1113 * @dfs_nol_ie_startfreq: The centre frequency of the starting 1114 * subchannel in the current channel list 1115 * to be sent in NOL IE with RCSA. 1116 * @dfs_nol_ie_bitmap: The bitmap of radar affected subchannels 1117 * in the current channel list 1118 * to be sent in NOL IE with RCSA. 1119 * @dfs_is_rcsa_ie_sent: To send or to not send RCSA IE. 1120 * @dfs_is_nol_ie_sent: To send or to not send NOL IE. 1121 * @dfs_legacy_precac_ucfg: User configuration for legacy preCAC in 1122 * partial offload chipsets. 1123 * @dfs_agile_precac_ucfg: User configuration for agile preCAC. 1124 * @dfs_agile_rcac_ucfg: User configuration for Rolling CAC. 1125 * @dfs_fw_adfs_support_non_160: Target Agile DFS support for non-160 BWs. 1126 * @dfs_fw_adfs_support_160: Target Agile DFS support for 160 BW. 1127 * @dfs_allow_hw_pulses: Allow/Block HW pulses. When synthetic 1128 * pulses are injected, the HW pulses should 1129 * be blocked and this variable should be 1130 * false so that HW pulses and synthetic 1131 * pulses do not get mixed up. 1132 * defer timer running. 1133 * @dfs_defer_params: DFS deferred event parameters (allocated 1134 * only for the duration of defer alone). 1135 * @dfs_agile_detector_id: Agile detector ID for the DFS object. 1136 * @dfs_agile_rcac_freq_ucfg: User programmed Rolling CAC frequency in 1137 * MHZ. 1138 * @dfs_rcac_param: Primary frequency and Channel params of 1139 * the selected RCAC channel. 1140 * @dfs_chan_postnol_freq: Frequency the AP switches to, post NOL. 1141 * @dfs_chan_postnol_mode: Phymode the AP switches to, post NOL. 1142 * @dfs_chan_postnol_cfreq2: Secondary center frequency the AP 1143 * switches to, post NOL. 1144 * @dfs_channel_state_array: Stores the channel states like CAC STARTED, 1145 * CAC REQUIRED, CAC COMPLETED, NOL, 1146 * PRECAC STARTED, PRECAC COMPLETED etc. of 1147 * all the DFS channels. 1148 * @dfs_precac_max_root_bw: Stores the max bandwidth (in MHz) to be 1149 * included in the precac forest as per the 1150 * regulatory current channel list. 1151 */ 1152 struct wlan_dfs { 1153 uint32_t dfs_debug_mask; 1154 int16_t dfs_curchan_radindex; 1155 int16_t dfs_extchan_radindex; 1156 uint32_t dfsdomain; 1157 uint32_t dfs_proc_phyerr; 1158 1159 STAILQ_HEAD(, dfs_event) dfs_eventq; 1160 qdf_spinlock_t dfs_eventqlock; 1161 1162 STAILQ_HEAD(, dfs_event) dfs_radarq; 1163 qdf_spinlock_t dfs_radarqlock; 1164 1165 STAILQ_HEAD(, dfs_event) dfs_arq; 1166 qdf_spinlock_t dfs_arqlock; 1167 1168 struct dfs_ar_state dfs_ar_state; 1169 struct dfs_state dfs_radar[DFS_NUM_RADAR_STATES]; 1170 struct dfs_filtertype *dfs_radarf[DFS_MAX_RADAR_TYPES]; 1171 struct dfs_info dfs_rinfo; 1172 struct dfs_bin5radars *dfs_b5radars; 1173 int8_t **dfs_ftindextable; 1174 struct dfs_nolelem *dfs_nol; 1175 int dfs_nol_count; 1176 struct wlan_dfs_phyerr_param dfs_defaultparams; 1177 struct dfs_stats wlan_dfs_stats; 1178 struct dfs_pulseline *pulses; 1179 struct dfs_event *events; 1180 1181 uint32_t wlan_radar_tasksched:1, 1182 wlan_dfswait:1, 1183 wlan_dfstest:1; 1184 struct wlan_dfs_caps dfs_caps; 1185 uint8_t wlan_dfstest_ieeechan; 1186 uint32_t wlan_dfs_cac_time; 1187 uint32_t wlan_dfstesttime; 1188 qdf_timer_t wlan_dfswaittimer; 1189 qdf_timer_t wlan_dfstesttimer; 1190 qdf_timer_t wlan_dfs_debug_timer; 1191 enum dfs_bangradar_types dfs_bangradar_type; 1192 bool is_radar_found_on_secondary_seg; 1193 bool is_radar_during_precac; 1194 qdf_spinlock_t dfs_precac_lock; 1195 bool dfs_precac_enable; 1196 #ifdef CONFIG_CHAN_FREQ_API 1197 uint16_t dfs_precac_secondary_freq_mhz; 1198 uint16_t dfs_precac_primary_freq_mhz; 1199 #endif 1200 uint8_t dfs_defer_precac_channel_change; 1201 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 1202 enum wlan_phymode dfs_autoswitch_des_mode; 1203 #endif 1204 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 1205 #ifdef CONFIG_CHAN_FREQ_API 1206 struct dfs_channel *dfs_autoswitch_chan; 1207 uint16_t dfs_precac_inter_chan_freq; 1208 #endif 1209 #endif 1210 uint8_t dfs_pre_cac_timeout_channel_change:1; 1211 qdf_timer_t wlan_dfs_task_timer; 1212 int dur_multiplier; 1213 uint16_t wlan_dfs_isdfsregdomain; 1214 int wlan_dfs_false_rssi_thres; 1215 int wlan_dfs_peak_mag; 1216 struct dfs_event_log radar_log[DFS_EVENT_LOG_SIZE]; 1217 int dfs_event_log_count; 1218 int dfs_event_log_on; 1219 int dfs_phyerr_count; 1220 int dfs_phyerr_reject_count; 1221 int dfs_phyerr_queued_count; 1222 int dfs_phyerr_freq_min; 1223 int dfs_phyerr_freq_max; 1224 int dfs_phyerr_w53_counter; 1225 int dfs_pri_multiplier; 1226 int wlan_dfs_nol_timeout; 1227 bool update_nol; 1228 uint32_t dfs_seq_num; 1229 int dfs_nol_event[DFS_CHAN_MAX]; 1230 qdf_timer_t dfs_nol_timer; 1231 1232 TAILQ_HEAD(, dfs_nolelem) dfs_nol_free_list; 1233 qdf_work_t dfs_nol_elem_free_work; 1234 1235 qdf_timer_t dfs_cac_timer; 1236 qdf_timer_t dfs_cac_valid_timer; 1237 int dfs_cac_timeout_override; 1238 uint8_t dfs_enable:1, 1239 dfs_cac_timer_running:1, 1240 dfs_ignore_dfs:1, 1241 dfs_ignore_cac:1, 1242 dfs_cac_valid:1; 1243 uint32_t dfs_cac_valid_time; 1244 int dfs_precac_timeout_override; 1245 uint8_t dfs_num_precac_freqs; 1246 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 1247 uint8_t dfs_disable_radar_marking; 1248 #endif 1249 TAILQ_HEAD(, dfs_precac_entry) dfs_precac_list; 1250 enum phy_ch_width dfs_precac_chwidth; 1251 1252 struct dfs_channel *dfs_curchan; 1253 struct dfs_channel *dfs_prevchan; 1254 struct dfs_channel dfs_cac_started_chan; 1255 struct wlan_objmgr_pdev *dfs_pdev_obj; 1256 struct dfs_soc_priv_obj *dfs_soc_obj; 1257 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1258 uint8_t dfs_psoc_idx; 1259 #endif 1260 #ifdef CONFIG_CHAN_FREQ_API 1261 uint16_t dfs_agile_precac_freq_mhz; 1262 #endif 1263 bool dfs_is_offload_enabled; 1264 bool dfs_is_radar_found_chan_freq_eq_center_freq; 1265 int dfs_use_nol; 1266 qdf_spinlock_t dfs_nol_lock; 1267 uint16_t tx_leakage_threshold; 1268 bool dfs_use_nol_subchannel_marking; 1269 uint8_t dfs_spoof_test_done:1; 1270 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 1271 qdf_timer_t dfs_host_wait_timer; 1272 uint32_t dfs_average_pri; 1273 uint32_t dfs_average_duration; 1274 uint32_t dfs_average_sidx; 1275 uint8_t dfs_is_host_wait_running:1, 1276 dfs_average_params_sent:1, 1277 dfs_no_res_from_fw:1, 1278 dfs_spoof_check_failed:1; 1279 struct dfs_channel dfs_radar_found_chan; 1280 int dfs_status_timeout_override; 1281 #endif 1282 bool dfs_is_stadfs_enabled; 1283 int32_t dfs_min_sidx; 1284 int32_t dfs_max_sidx; 1285 uint8_t dfs_seg_id; 1286 uint8_t dfs_is_chirp; 1287 bool dfs_bw_reduced; 1288 int32_t dfs_freq_offset; 1289 bool dfs_cac_aborted; 1290 qdf_spinlock_t dfs_data_struct_lock; 1291 #if defined(QCA_DFS_RCSA_SUPPORT) 1292 uint8_t dfs_nol_ie_bandwidth; 1293 uint16_t dfs_nol_ie_startfreq; 1294 uint8_t dfs_nol_ie_bitmap; 1295 bool dfs_is_rcsa_ie_sent; 1296 bool dfs_is_nol_ie_sent; 1297 #endif 1298 uint8_t dfs_legacy_precac_ucfg:1, 1299 dfs_agile_precac_ucfg:1, 1300 #if defined(QCA_SUPPORT_ADFS_RCAC) 1301 dfs_agile_rcac_ucfg:1, 1302 #endif 1303 dfs_fw_adfs_support_non_160:1, 1304 dfs_fw_adfs_support_160:1; 1305 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR) 1306 bool dfs_allow_hw_pulses; 1307 #endif 1308 struct dfs_mode_switch_defer_params dfs_defer_params; 1309 uint8_t dfs_agile_detector_id; 1310 #if defined(QCA_SUPPORT_ADFS_RCAC) 1311 uint16_t dfs_agile_rcac_freq_ucfg; 1312 struct dfs_rcac_params dfs_rcac_param; 1313 #endif 1314 uint16_t dfs_lowest_pri_limit; 1315 #if defined(QCA_SUPPORT_DFS_CHAN_POSTNOL) 1316 qdf_freq_t dfs_chan_postnol_freq; 1317 enum phy_ch_width dfs_chan_postnol_mode; 1318 qdf_freq_t dfs_chan_postnol_cfreq2; 1319 #endif 1320 #if defined(WLAN_DISP_CHAN_INFO) 1321 enum channel_dfs_state dfs_channel_state_array[NUM_DFS_CHANS]; 1322 #endif /* WLAN_DISP_CHAN_INFO */ 1323 #ifdef QCA_SUPPORT_AGILE_DFS 1324 uint16_t dfs_precac_max_root_bw; 1325 #endif 1326 }; 1327 1328 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1329 /** 1330 * struct wlan_dfs_priv - dfs private struct with agile capability info 1331 * @wlan_dfs: pointer to wlan_dfs object. 1332 * @agile_precac_active: agile precac active information for wlan_dfs_priv obj 1333 */ 1334 struct wlan_dfs_priv { 1335 struct wlan_dfs *dfs; 1336 bool agile_precac_active; 1337 }; 1338 #endif 1339 1340 /** 1341 * struct dfs_soc_priv_obj - dfs private data 1342 * @psoc: pointer to PSOC object information 1343 * @pdev: pointer to PDEV object information 1344 * @dfs_is_phyerr_filter_offload: For some chip like Rome indicates too many 1345 * phyerr packets in a short time, which causes 1346 * OS hang. If this feild is configured as true, 1347 * FW will do the pre-check, filter out some 1348 * kinds of invalid phyerrors and indicate 1349 * radar detection related information to host. 1350 * @dfs_priv: array of dfs private structs with agile capability info 1351 * @num_dfs_privs: array size of dfs private structs for given psoc. 1352 * @cur_dfs_index: index of the current dfs object using the Agile Engine. 1353 * It is used to index struct wlan_dfs_priv dfs_priv[] array. 1354 * @dfs_precac_timer: agile precac timer 1355 * @dfs_precac_timer_running: precac timer running flag 1356 * @ocac_status: Off channel CAC complete status 1357 * @dfs_nol_ctx: dfs NOL data for all radios. 1358 * @dfs_rcac_timer: Agile RCAC (Rolling CAC) timer. 1359 * @dfs_agile_sm_hdl: The handle for the state machine that drives Agile 1360 * Engine. 1361 * @dfs_agile_sm_cur_state: Current state of the Agile State Machine. 1362 * @dfs_rcac_sm_lock: DFS Rolling CAC state machine lock. 1363 */ 1364 struct dfs_soc_priv_obj { 1365 struct wlan_objmgr_psoc *psoc; 1366 struct wlan_objmgr_pdev *pdev; 1367 bool dfs_is_phyerr_filter_offload; 1368 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 1369 struct wlan_dfs_priv dfs_priv[WLAN_UMAC_MAX_PDEVS]; 1370 uint8_t num_dfs_privs; 1371 uint8_t cur_agile_dfs_index; 1372 qdf_timer_t dfs_precac_timer; 1373 uint8_t dfs_precac_timer_running; 1374 bool precac_state_started; 1375 bool ocac_status; 1376 #endif 1377 struct dfsreq_nolinfo *dfs_psoc_nolinfo; 1378 #ifdef QCA_SUPPORT_ADFS_RCAC 1379 qdf_timer_t dfs_rcac_timer; 1380 #endif 1381 #ifdef QCA_SUPPORT_AGILE_DFS 1382 struct wlan_sm *dfs_agile_sm_hdl; 1383 enum dfs_agile_sm_state dfs_agile_sm_cur_state; 1384 qdf_spinlock_t dfs_agile_sm_lock; 1385 #endif 1386 }; 1387 1388 /** 1389 * enum DFS debug - This should match the table from if_ath.c. 1390 * @WLAN_DEBUG_DFS: Minimal DFS debug. 1391 * @WLAN_DEBUG_DFS1: Normal DFS debug. 1392 * @WLAN_DEBUG_DFS2: Maximal DFS debug. 1393 * @WLAN_DEBUG_DFS3: Matched filterID display. 1394 * @WLAN_DEBUG_DFS_PHYERR: Phy error parsing. 1395 * @WLAN_DEBUG_DFS_NOL: NOL related entries. 1396 * @WLAN_DEBUG_DFS_PHYERR_SUM: PHY error summary. 1397 * @WLAN_DEBUG_DFS_PHYERR_PKT: PHY error payload. 1398 * @WLAN_DEBUG_DFS_BIN5: BIN5 checks. 1399 * @WLAN_DEBUG_DFS_BIN5_FFT: BIN5 FFT check. 1400 * @WLAN_DEBUG_DFS_BIN5_PULSE: BIN5 pulse check. 1401 * @WLAN_DEBUG_DFS_FALSE_DET: False detection debug related prints. 1402 * @WLAN_DEBUG_DFS_FALSE_DET2: Second level check to confirm poisitive 1403 * detection. 1404 * @WLAN_DEBUG_DFS_RANDOM_CHAN: Random channel selection. 1405 * @WLAN_DEBUG_DFS_AGILE: Agile PreCAC/RCAC 1406 */ 1407 enum { 1408 WLAN_DEBUG_DFS = 0x00000100, 1409 WLAN_DEBUG_DFS1 = 0x00000200, 1410 WLAN_DEBUG_DFS2 = 0x00000400, 1411 WLAN_DEBUG_DFS3 = 0x00000800, 1412 WLAN_DEBUG_DFS_PHYERR = 0x00001000, 1413 WLAN_DEBUG_DFS_NOL = 0x00002000, 1414 WLAN_DEBUG_DFS_PHYERR_SUM = 0x00004000, 1415 WLAN_DEBUG_DFS_PHYERR_PKT = 0x00008000, 1416 WLAN_DEBUG_DFS_BIN5 = 0x00010000, 1417 WLAN_DEBUG_DFS_BIN5_FFT = 0x00020000, 1418 WLAN_DEBUG_DFS_BIN5_PULSE = 0x00040000, 1419 WLAN_DEBUG_DFS_FALSE_DET = 0x00080000, 1420 WLAN_DEBUG_DFS_FALSE_DET2 = 0x00100000, 1421 WLAN_DEBUG_DFS_RANDOM_CHAN = 0x00200000, 1422 WLAN_DEBUG_DFS_AGILE = 0x00400000, 1423 WLAN_DEBUG_DFS_MAX = 0x80000000, 1424 WLAN_DEBUG_DFS_ALWAYS = WLAN_DEBUG_DFS_MAX 1425 }; 1426 1427 /** 1428 * enum host dfs spoof check status. 1429 * @HOST_DFS_CHECK_PASSED: Host indicates RADAR detected and the FW 1430 * confirms it to be spoof radar to host. 1431 * @HOST_DFS_CHECK_FAILED: Host doesn't indicate RADAR detected or spoof 1432 * radar parameters by 1433 * WMI_HOST_DFS_RADAR_FOUND_CMDID doesn't match. 1434 * @HOST_DFS_STATUS_CHECK_HW_RADAR: Host indicates RADAR detected and the 1435 * FW confirms it to be real HW radar to host. 1436 */ 1437 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 1438 enum { 1439 HOST_DFS_STATUS_CHECK_PASSED = 0, 1440 HOST_DFS_STATUS_CHECK_FAILED = 1, 1441 HOST_DFS_STATUS_CHECK_HW_RADAR = 2 1442 }; 1443 #endif 1444 1445 /** 1446 * struct dfs_phy_err - DFS phy error. 1447 * @fulltsf: 64-bit TSF as read from MAC. 1448 * @is_pri: Detected on primary channel. 1449 * @is_ext: Detected on extension channel. 1450 * @is_dc: Detected at DC. 1451 * @is_early: Early detect. 1452 * @do_check_chirp: Whether to check hw_chirp/sw_chirp. 1453 * @is_hw_chirp: Hardware-detected chirp. 1454 * @is_sw_chirp: Software detected chirp. 1455 * @rs_tstamp: 32 bit TSF from RX descriptor (event). 1456 * @freq: Centre frequency of event - KHz. 1457 * @freq_lo: Lower bounds of frequency - KHz. 1458 * @freq_hi: Upper bounds of frequency - KHz. 1459 * @rssi: Pulse RSSI. 1460 * @dur: Pulse duration, raw (not uS). 1461 * @seg_id: HT80_80/HT160 use. 1462 * @sidx: Seg index. 1463 * @freq_offset_khz: Freq offset in KHz. 1464 * @peak_mag: Peak mag. 1465 * @total_gain: Total gain. 1466 * @mb_gain: Mb gain. 1467 * @relpwr_db: Relpower in DB. 1468 * @pulse_delta_diff: Pulse delta diff. 1469 * @pulse_delta_peak: Pulse delta peak. 1470 * @pulse_psidx_diff: Pulse psidx diff. 1471 * 1472 * Chirp notes! 1473 * 1474 * Pre-Sowl chips don't do FFT reports, so chirp pulses simply show up 1475 * as long duration pulses. 1476 * 1477 * The bin5 checking code would simply look for a chirp pulse of the correct 1478 * duration (within MIN_BIN5_DUR and MAX_BIN5_DUR) and add it to the "chirp" 1479 * pattern. 1480 * 1481 * For Sowl and later, an FFT was done on longer duration frames. If those 1482 * frames looked like a chirp, their duration was adjusted to fall within 1483 * the chirp duration limits. If the pulse failed the chirp test (it had 1484 * no FFT data or the FFT didn't meet the chirping requirements) then the 1485 * pulse duration was adjusted to be greater than MAX_BIN5_DUR, so it 1486 * would always fail chirp detection. 1487 * 1488 * This is pretty horrible. 1489 * 1490 * The eventual goal for chirp handling is thus: 1491 * 1492 * 1)In case someone ever wants to do chirp detection with this code on 1493 * chips that don't support chirp detection, you can still do it based 1494 * on pulse duration. That's your problem to solve. 1495 * 1496 * 2)For chips that do hardware chirp detection or FFT, the "do_check_chirp" 1497 * bit should be set. 1498 * 1499 * 3)Then, either is_hw_chirp or is_sw_chirp is set, indicating that 1500 * the hardware or software post-processing of the chirp event found 1501 * that indeed it was a chirp. 1502 * 1503 * 4)Finally, the bin5 code should just check whether the chirp bits are 1504 * set and behave appropriately, falling back onto the duration checks 1505 * if someone wishes to use this on older hardware (or with disabled 1506 * FFTs, for whatever reason.) 1507 * 1508 * XXX TODO: 1509 * 1510 * 1)add duration in uS and raw duration, so the PHY error parsing 1511 * code is responsible for doing the duration calculation; 1512 * 2)add ts in raw and corrected, so the PHY error parsing 1513 * code is responsible for doing the offsetting, not the radar 1514 * event code. 1515 */ 1516 struct dfs_phy_err { 1517 uint64_t fulltsf; 1518 uint32_t is_pri:1, 1519 is_ext:1, 1520 is_dc:1, 1521 is_early:1, 1522 do_check_chirp:1, 1523 is_hw_chirp:1, 1524 is_sw_chirp:1; 1525 uint32_t rs_tstamp; 1526 uint32_t freq; 1527 uint32_t freq_lo; 1528 uint32_t freq_hi; 1529 uint8_t rssi; 1530 uint8_t dur; 1531 uint8_t seg_id; 1532 int sidx; 1533 u_int freq_offset_khz; 1534 int peak_mag; 1535 int total_gain; 1536 int mb_gain; 1537 int relpwr_db; 1538 uint8_t pulse_delta_diff; 1539 int8_t pulse_delta_peak; 1540 int16_t pulse_psidx_diff; 1541 }; 1542 1543 /** 1544 * struct rx_radar_status - Parsed radar status 1545 * @raw_tsf: Raw tsf 1546 * @tsf_offset: TSF offset. 1547 * @rssi: RSSI. 1548 * @pulse_duration: Pulse duration. 1549 * @is_chirp: Is chirp. 1550 * @delta_peak: Delta peak. 1551 * @delta_diff: Delta diff. 1552 * @sidx: Starting frequency. 1553 * @freq_offset: Frequency offset. 1554 * @agc_total_gain: AGC total gain. 1555 * @agc_mb_gain: AGC MB gain. 1556 */ 1557 struct rx_radar_status { 1558 uint32_t raw_tsf; 1559 uint32_t tsf_offset; 1560 int rssi; 1561 int pulse_duration; 1562 int is_chirp:1; 1563 int delta_peak; 1564 int delta_diff; 1565 int sidx; 1566 int freq_offset; /* in KHz */ 1567 int agc_total_gain; 1568 int agc_mb_gain; 1569 }; 1570 1571 /** 1572 * struct rx_search_fft_report - FFT report. 1573 * @total_gain_db: Total gain in Db. 1574 * @base_pwr_db: Base power in Db. 1575 * @fft_chn_idx: FFT channel index. 1576 * @peak_sidx: Peak sidx. 1577 * @relpwr_db: Real power in Db. 1578 * @avgpwr_db: Average power in Db. 1579 * @peak_mag: Peak Mag. 1580 * @num_str_bins_ib: Num dtr BINs IB 1581 * @seg_id: Segment ID 1582 */ 1583 struct rx_search_fft_report { 1584 uint32_t total_gain_db; 1585 uint32_t base_pwr_db; 1586 int fft_chn_idx; 1587 int peak_sidx; 1588 int relpwr_db; 1589 int avgpwr_db; 1590 int peak_mag; 1591 int num_str_bins_ib; 1592 int seg_id; 1593 }; 1594 1595 /** 1596 * dfs_process_radarevent() - process the radar event generated for a pulse. 1597 * @dfs: Pointer to wlan_dfs structure. 1598 * @chan: Current channel. 1599 * 1600 * There is currently no way to specify that a radar event has occurred on 1601 * a specific channel, so the current methodology is to mark both the pri 1602 * and ext channels as being unavailable. This should be fixed for 802.11ac 1603 * or we'll quickly run out of valid channels to use. 1604 * 1605 * If Radar found, this marks the channel (and the extension channel, if HT40) 1606 * as having seen a radar event. It marks CHAN_INTERFERENCE and will add it to 1607 * the local NOL implementation. This is only done for 'usenol=1', as the other 1608 * two modes don't do radar notification or CAC/CSA/NOL; it just notes there 1609 * was a radar. 1610 */ 1611 void dfs_process_radarevent(struct wlan_dfs *dfs, 1612 struct dfs_channel *chan); 1613 1614 /** 1615 * dfs_nol_addchan() - Add channel to NOL. 1616 * @dfs: Pointer to wlan_dfs structure. 1617 * @freq: frequency to add to NOL. 1618 * @dfs_nol_timeout: NOL timeout. 1619 */ 1620 void dfs_nol_addchan(struct wlan_dfs *dfs, 1621 uint16_t freq, 1622 uint32_t dfs_nol_timeout); 1623 1624 /** 1625 * dfs_get_nol() - Get NOL. 1626 * @dfs: Pointer to wlan_dfs structure. 1627 * @dfs_nol: Pointer to dfsreq_nolelem structure to save the channels from NOL. 1628 * @nchan: Number of channels. 1629 */ 1630 void dfs_get_nol(struct wlan_dfs *dfs, 1631 struct dfsreq_nolelem *dfs_nol, 1632 int *nchan); 1633 1634 /** 1635 * dfs_set_nol() - Set NOL. 1636 * @dfs: Pointer to wlan_dfs structure. 1637 * @dfs_nol: Pointer to dfsreq_nolelem structure. 1638 * @nchan: Number of channels. 1639 */ 1640 void dfs_set_nol(struct wlan_dfs *dfs, 1641 struct dfsreq_nolelem *dfs_nol, 1642 int nchan); 1643 1644 /** 1645 * dfs_nol_update() - NOL update 1646 * @dfs: Pointer to wlan_dfs structure. 1647 * 1648 * Notify the driver/umac that it should update the channel radar/NOL flags 1649 * based on the current NOL list. 1650 */ 1651 void dfs_nol_update(struct wlan_dfs *dfs); 1652 1653 /** 1654 * dfs_nol_timer_cleanup() - NOL timer cleanup. 1655 * @dfs: Pointer to wlan_dfs structure. 1656 * 1657 * Cancels the NOL timer and frees the NOL elements. 1658 */ 1659 void dfs_nol_timer_cleanup(struct wlan_dfs *dfs); 1660 1661 /** 1662 * dfs_nol_timer_detach() - Free NOL timer. 1663 * @dfs: Pointer to wlan_dfs structure. 1664 */ 1665 void dfs_nol_timer_detach(struct wlan_dfs *dfs); 1666 1667 /** 1668 * dfs_nol_workqueue_cleanup() - Flushes NOL workqueue. 1669 * @dfs: Pointer to wlan_dfs structure. 1670 * 1671 * Flushes the NOL workqueue. 1672 */ 1673 void dfs_nol_workqueue_cleanup(struct wlan_dfs *dfs); 1674 1675 /** 1676 * dfs_retain_bin5_burst_pattern() - Retain the BIN5 burst pattern. 1677 * @dfs: Pointer to wlan_dfs structure. 1678 * @diff_ts: Timestamp diff. 1679 * @old_dur: Old duration. 1680 */ 1681 uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs, 1682 uint32_t diff_ts, 1683 uint8_t old_dur); 1684 1685 /** 1686 * dfs_bin5_check_pulse() - BIN5 check pulse. 1687 * @dfs: Pointer to wlan_dfs structure. 1688 * @re: Pointer to dfs_event structure. 1689 * @br: Pointer to dfs_bin5radars structure. 1690 * 1691 * Reject the pulse if: 1692 * 1) It's outside the RSSI threshold; 1693 * 2) It's outside the pulse duration; 1694 * 3) It's been verified by HW/SW chirp checking 1695 * and neither of those found a chirp. 1696 */ 1697 int dfs_bin5_check_pulse(struct wlan_dfs *dfs, 1698 struct dfs_event *re, 1699 struct dfs_bin5radars *br); 1700 1701 /** 1702 * dfs_bin5_addpulse() - BIN5 add pulse. 1703 * @dfs: Pointer to wlan_dfs structure. 1704 * @br: Pointer to dfs_bin5radars structure. 1705 * @re: Pointer to dfs_event structure. 1706 * @thists: Timestamp. 1707 */ 1708 int dfs_bin5_addpulse(struct wlan_dfs *dfs, 1709 struct dfs_bin5radars *br, 1710 struct dfs_event *re, 1711 uint64_t thists); 1712 1713 /** 1714 * dfs_bin5_check() - BIN5 check. 1715 * @dfs: Pointer to wlan_dfs structure. 1716 * 1717 * If the dfs structure is NULL (which should be illegal if everyting is working 1718 * properly, then signify that a bin5 radar was found. 1719 */ 1720 int dfs_bin5_check(struct wlan_dfs *dfs); 1721 1722 /** 1723 * dfs_check_chirping() - Check chirping. 1724 * @dfs: Pointer to wlan_dfs structure. 1725 * @buf: Phyerr buffer 1726 * @datalen: Phyerr buf length 1727 * @is_ctl: detected on primary channel. 1728 * @is_ext: detected on extension channel. 1729 * @slope: Slope 1730 * @is_dc: DC found 1731 * 1732 * This examines the FFT data contained in the PHY error information to figure 1733 * out whether the pulse is moving across frequencies. 1734 */ 1735 int dfs_check_chirping(struct wlan_dfs *dfs, 1736 void *buf, 1737 uint16_t datalen, 1738 int is_ctl, 1739 int is_ext, 1740 int *slope, 1741 int *is_dc); 1742 1743 /** 1744 * dfs_get_random_bin5_dur() - Get random BIN5 duration. 1745 * @dfs: Pointer to wlan_dfs structure. 1746 * @tstamp: Timestamp. 1747 * 1748 * Chirping pulses may get cut off at DC and report lower durations. 1749 * This function will compute a suitable random duration for each pulse. 1750 * Duration must be between 50 and 100 us, but remember that in 1751 * wlan_process_phyerr() which calls this function, we are dealing with the 1752 * HW reported duration (unconverted). dfs_process_radarevent() will 1753 * actually convert the duration into the correct value. 1754 * This function doesn't take into account whether the hardware 1755 * is operating in 5GHz fast clock mode or not. 1756 * And this function doesn't take into account whether the hardware 1757 * is peregrine or not. 1758 */ 1759 int dfs_get_random_bin5_dur(struct wlan_dfs *dfs, 1760 uint64_t tstamp); 1761 1762 /** 1763 * dfs_print_delayline() - Prints delayline. 1764 * @dfs: Pointer to wlan_dfs structure. 1765 * @dl: Pointer to dfs_delayline structure. 1766 */ 1767 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1768 void dfs_print_delayline(struct wlan_dfs *dfs, 1769 struct dfs_delayline *dl); 1770 #else 1771 static inline 1772 void dfs_print_delayline(struct wlan_dfs *dfs, struct dfs_delayline *dl) 1773 { 1774 } 1775 #endif 1776 1777 /** 1778 * dfs_print_nol() - Print NOL elements. 1779 * @dfs: Pointer to wlan_dfs structure. 1780 */ 1781 void dfs_print_nol(struct wlan_dfs *dfs); 1782 1783 /** 1784 * dfs_print_filter() - Prints the filter. 1785 * @dfs: Pointer to wlan_dfs structure. 1786 * @rf: Pointer to dfs_filter structure. 1787 */ 1788 void dfs_print_filter(struct wlan_dfs *dfs, 1789 struct dfs_filter *rf); 1790 1791 /** 1792 * dfs_getchanstate() - Get chan state. 1793 * @dfs: Pointer to wlan_dfs structure. 1794 * @index: To save the index of dfs_radar[] 1795 * @ext_chan_flag: Extension channel flag; 1796 */ 1797 struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, 1798 uint8_t *index, 1799 int ext_ch_flag); 1800 1801 /** 1802 * dfs_round() - DFS found. 1803 * @val: Convert durations to TSF ticks. 1804 * 1805 * Return: TSF ticks. 1806 */ 1807 uint32_t dfs_round(int32_t val); 1808 1809 /** 1810 * dfs_reset_alldelaylines() - Reset alldelaylines. 1811 * @dfs: Pointer to wlan_dfs structure. 1812 */ 1813 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1814 void dfs_reset_alldelaylines(struct wlan_dfs *dfs); 1815 #else 1816 static inline void dfs_reset_alldelaylines(struct wlan_dfs *dfs) 1817 { 1818 } 1819 #endif 1820 1821 /** 1822 * dfs_reset_delayline() - Clear only a single delay line. 1823 * @dl: Pointer to dfs_delayline structure. 1824 */ 1825 void dfs_reset_delayline(struct dfs_delayline *dl); 1826 1827 /** 1828 * dfs_reset_filter_delaylines() - Reset filter delaylines. 1829 * @dft: Pointer to dfs_filtertype structure. 1830 */ 1831 void dfs_reset_filter_delaylines(struct dfs_filtertype *dft); 1832 1833 /** 1834 * dfs_reset_radarq() - Reset radar queue. 1835 * @dfs: Pointer to wlan_dfs structure. 1836 */ 1837 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1838 void dfs_reset_radarq(struct wlan_dfs *dfs); 1839 #else 1840 static inline void dfs_reset_radarq(struct wlan_dfs *dfs) 1841 { 1842 } 1843 #endif 1844 1845 /** 1846 * dfs_add_pulse() - Adds pulse to the queue. 1847 * @dfs: Pointer to wlan_dfs structure. 1848 * @rf: Pointer to dfs_filter structure. 1849 * @re: Pointer to dfs_event structure. 1850 * @deltaT: deltaT value. 1851 * @this_ts: Last time stamp. 1852 */ 1853 void dfs_add_pulse(struct wlan_dfs *dfs, 1854 struct dfs_filter *rf, 1855 struct dfs_event *re, 1856 uint32_t deltaT, 1857 uint64_t this_ts); 1858 1859 /** 1860 * dfs_bin_check() - BIN check 1861 * @dfs: Pointer to wlan_dfs structure. 1862 * @rf: Pointer to dfs_filter structure. 1863 * @deltaT: deltaT value. 1864 * @width: Width 1865 * @ext_chan_flag: Extension channel flag. 1866 */ 1867 int dfs_bin_check(struct wlan_dfs *dfs, 1868 struct dfs_filter *rf, 1869 uint32_t deltaT, 1870 uint32_t dur, 1871 int ext_chan_flag); 1872 1873 /** 1874 * dfs_bin_pri_check() - BIN PRI check 1875 * @dfs: Pointer to wlan_dfs structure. 1876 * @rf: Pointer to dfs_filter structure. 1877 * @dl: Pointer to dfs_delayline structure. 1878 * @score: Primary score. 1879 * @refpri: Current "filter" time for start of pulse in usecs. 1880 * @refdur: Duration value. 1881 * @ext_chan_flag: Extension channel flag. 1882 * @fundamentalpri: Highest PRI. 1883 */ 1884 int dfs_bin_pri_check(struct wlan_dfs *dfs, 1885 struct dfs_filter *rf, 1886 struct dfs_delayline *dl, 1887 uint32_t score, 1888 uint32_t refpri, 1889 uint32_t refdur, 1890 int ext_chan_flag, 1891 int fundamentalpri); 1892 1893 /** 1894 * dfs_staggered_check() - Detection implementation for staggered PRIs. 1895 * @dfs: Pointer to wlan_dfs structure. 1896 * @rf: Pointer to dfs_filter structure. 1897 * @deltaT: Delta of the Timestamp. 1898 * @width: Duration of radar pulse. 1899 * 1900 * Return: 1 on success and 0 on failure. 1901 */ 1902 int dfs_staggered_check(struct wlan_dfs *dfs, 1903 struct dfs_filter *rf, 1904 uint32_t deltaT, 1905 uint32_t width); 1906 1907 /** 1908 * dfs_get_pri_margin() - Get Primary margin. 1909 * @dfs: Pointer to wlan_dfs structure. 1910 * @is_extchan_detect: Extension channel detect. 1911 * @is_fixed_pattern: Fixed pattern. 1912 * 1913 * For the extension channel, if legacy traffic is present, we see a lot of 1914 * false alarms, so make the PRI margin narrower depending on the busy % for 1915 * the extension channel. 1916 * 1917 * Return: Returns pri_margin. 1918 */ 1919 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1920 int dfs_get_pri_margin(struct wlan_dfs *dfs, 1921 int is_extchan_detect, 1922 int is_fixed_pattern); 1923 #else 1924 static inline 1925 int dfs_get_pri_margin(struct wlan_dfs *dfs, 1926 int is_extchan_detect, 1927 int is_fixed_pattern) 1928 { 1929 return 0; 1930 } 1931 #endif 1932 1933 /** 1934 * dfs_get_filter_threshold() - Get filter threshold. 1935 * @dfs: Pointer to wlan_dfs structure. 1936 * @rf: Pointer to dfs_filter structure. 1937 * @is_extchan_detect: Extension channel detect. 1938 * 1939 * For the extension channel, if legacy traffic is present, we see a lot of 1940 * false alarms, so make the thresholds higher depending on the busy % for the 1941 * extension channel. 1942 * 1943 * Return: Returns threshold. 1944 */ 1945 int dfs_get_filter_threshold(struct wlan_dfs *dfs, 1946 struct dfs_filter *rf, 1947 int is_extchan_detect); 1948 1949 #if defined(MOBILE_DFS_SUPPORT) 1950 /** 1951 * dfs_process_ar_event() - Process the ar event. 1952 * @dfs: Pointer to wlan_dfs structure. 1953 * @chan: Current channel structure. 1954 */ 1955 static inline void dfs_process_ar_event(struct wlan_dfs *dfs, 1956 struct dfs_channel *chan) 1957 { 1958 } 1959 1960 /** 1961 * dfs_reset_ar() - resets the ar state. 1962 * @dfs: pointer to wlan_dfs structure. 1963 */ 1964 static inline void dfs_reset_ar(struct wlan_dfs *dfs) 1965 { 1966 } 1967 1968 /** 1969 * dfs_reset_arq() - resets the ar queue. 1970 * @dfs: pointer to wlan_dfs structure. 1971 */ 1972 static inline void dfs_reset_arq(struct wlan_dfs *dfs) 1973 { 1974 } 1975 1976 #else 1977 void dfs_process_ar_event(struct wlan_dfs *dfs, 1978 struct dfs_channel *chan); 1979 1980 void dfs_reset_ar(struct wlan_dfs *dfs); 1981 void dfs_reset_arq(struct wlan_dfs *dfs); 1982 #endif 1983 1984 /** 1985 * dfs_is_radar_enabled() - check if radar detection is enabled. 1986 * @dfs: Pointer to wlan_dfs structure. 1987 * @ignore_dfs: if 1 then radar detection is disabled.. 1988 */ 1989 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 1990 void dfs_is_radar_enabled(struct wlan_dfs *dfs, 1991 int *ignore_dfs); 1992 #else 1993 static inline void dfs_is_radar_enabled(struct wlan_dfs *dfs, 1994 int *ignore_dfs) 1995 { 1996 } 1997 #endif 1998 1999 /** 2000 * dfs_process_phyerr_bb_tlv() - Parses the PHY error and populates the 2001 * dfs_phy_err struct. 2002 * @dfs: Pointer to wlan_dfs structure. 2003 * @buf: Phyerr buffer 2004 * @datalen: Phyerr buf len 2005 * @rssi: RSSI 2006 * @ext_rssi: Extension RSSI. 2007 * @rs_tstamp: Time stamp. 2008 * @fulltsf: TSF64. 2009 * @e: Pointer to dfs_phy_err structure. 2010 * 2011 * Return: Returns 1. 2012 */ 2013 int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs, 2014 void *buf, 2015 uint16_t datalen, 2016 uint8_t rssi, 2017 uint8_t ext_rssi, 2018 uint32_t rs_tstamp, 2019 uint64_t fulltsf, 2020 struct dfs_phy_err *e); 2021 2022 /** 2023 * dfs_reset() - DFS reset 2024 * @dfs: Pointer to wlan_dfs structure. 2025 */ 2026 void dfs_reset(struct wlan_dfs *dfs); 2027 2028 /** 2029 * dfs_radar_enable() - Enables the radar. 2030 * @dfs: Pointer to wlan_dfs structure. 2031 * @no_cac: If no_cac is 0, it cancels the CAC. 2032 */ 2033 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2034 void dfs_radar_enable(struct wlan_dfs *dfs, 2035 int no_cac, uint32_t opmode); 2036 #else 2037 static inline void dfs_radar_enable(struct wlan_dfs *dfs, 2038 int no_cac, uint32_t opmode) 2039 { 2040 } 2041 #endif 2042 2043 /** 2044 * dfs_process_phyerr() - Process phyerr. 2045 * @dfs: Pointer to wlan_dfs structure. 2046 * @buf: Phyerr buffer. 2047 * @datalen: phyerr buffer length. 2048 * @r_rssi: RSSI. 2049 * @r_ext_rssi: Extension channel RSSI. 2050 * @r_rs_tstamp: Timestamp. 2051 * @r_fulltsf: TSF64. 2052 */ 2053 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2054 void dfs_process_phyerr(struct wlan_dfs *dfs, 2055 void *buf, 2056 uint16_t datalen, 2057 uint8_t r_rssi, 2058 uint8_t r_ext_rssi, 2059 uint32_t r_rs_tstamp, 2060 uint64_t r_fulltsf); 2061 #else 2062 static inline void dfs_process_phyerr(struct wlan_dfs *dfs, 2063 void *buf, 2064 uint16_t datalen, 2065 uint8_t r_rssi, 2066 uint8_t r_ext_rssi, 2067 uint32_t r_rs_tstamp, 2068 uint64_t r_fulltsf) 2069 { 2070 } 2071 #endif 2072 2073 #ifdef QCA_SUPPORT_DFS_CHAN_POSTNOL 2074 /** 2075 * dfs_switch_to_postnol_chan_if_nol_expired() - Find if NOL is expired 2076 * in the postNOL channel configured. If true, trigger channel change. 2077 * @dfs: Pointer to DFS of wlan_dfs structure. 2078 * 2079 * Return: True, if channel change is triggered, else false. 2080 */ 2081 bool dfs_switch_to_postnol_chan_if_nol_expired(struct wlan_dfs *dfs); 2082 #else 2083 static inline bool 2084 dfs_switch_to_postnol_chan_if_nol_expired(struct wlan_dfs *dfs) 2085 { 2086 return false; 2087 } 2088 #endif 2089 2090 #ifdef MOBILE_DFS_SUPPORT 2091 /** 2092 * dfs_process_phyerr_filter_offload() - Process radar event. 2093 * @dfs: Pointer to wlan_dfs structure. 2094 * @wlan_radar_event: Pointer to radar_event_info structure. 2095 * 2096 * Return: None 2097 */ 2098 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2099 void dfs_process_phyerr_filter_offload(struct wlan_dfs *dfs, 2100 struct radar_event_info *wlan_radar_event); 2101 #else 2102 static inline void dfs_process_phyerr_filter_offload( 2103 struct wlan_dfs *dfs, 2104 struct radar_event_info *wlan_radar_event) 2105 { 2106 } 2107 #endif 2108 #endif 2109 2110 /** 2111 * dfs_get_radars() - Based on the chipset, calls init radar table functions. 2112 * @dfs: Pointer to wlan_dfs structure. 2113 */ 2114 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2115 void dfs_get_radars(struct wlan_dfs *dfs); 2116 #else 2117 static inline void dfs_get_radars(struct wlan_dfs *dfs) 2118 { 2119 } 2120 #endif 2121 2122 /** 2123 * dfs_attach() - Wrapper function to allocate memory for wlan_dfs members. 2124 * @dfs: Pointer to wlan_dfs structure. 2125 */ 2126 int dfs_attach(struct wlan_dfs *dfs); 2127 2128 2129 /** 2130 * dfs_create_object() - Creates DFS object. 2131 * @dfs: Pointer to wlan_dfs structure. 2132 */ 2133 int dfs_create_object(struct wlan_dfs **dfs); 2134 2135 /** 2136 * dfs_destroy_object() - Destroys the DFS object. 2137 * @dfs: Pointer to wlan_dfs structure. 2138 */ 2139 void dfs_destroy_object(struct wlan_dfs *dfs); 2140 2141 /** 2142 * dfs_detach() - Wrapper function to free dfs variables. 2143 * @dfs: Pointer to wlan_dfs structure. 2144 */ 2145 void dfs_detach(struct wlan_dfs *dfs); 2146 2147 #ifdef QCA_SUPPORT_DFS_CAC 2148 /** 2149 * dfs_stacac_stop() - Clear the STA CAC timer. 2150 * @dfs: Pointer to wlan_dfs structure. 2151 */ 2152 void dfs_stacac_stop(struct wlan_dfs *dfs); 2153 2154 /** 2155 * dfs_is_cac_required() - Check if DFS CAC is required for the current channel. 2156 * @dfs: Pointer to wlan_dfs structure. 2157 * @cur_chan: Pointer to current channel of dfs_channel structure. 2158 * @prev_chan: Pointer to previous channel of dfs_channel structure. 2159 * @continue_current_cac: If AP can start CAC then this variable indicates 2160 * whether to continue with the current CAC or restart the CAC. This variable 2161 * is valid only if this function returns true. 2162 * @is_vap_restart: Flag to indicate if vap is restarted/started. 2163 * True: VAP restart. False: VAP start 2164 * 2165 * Return: true if AP requires CAC or can continue current CAC, else false. 2166 */ 2167 bool dfs_is_cac_required(struct wlan_dfs *dfs, 2168 struct dfs_channel *cur_chan, 2169 struct dfs_channel *prev_chan, 2170 bool *continue_current_cac, 2171 bool is_vap_restart); 2172 2173 /** 2174 * dfs_cac_stop() - Clear the AP CAC timer. 2175 * @dfs: Pointer to wlan_dfs structure. 2176 */ 2177 2178 void dfs_cac_stop(struct wlan_dfs *dfs); 2179 2180 /** 2181 * dfs_cancel_cac_timer() - Cancels the CAC timer. 2182 * @dfs: Pointer to wlan_dfs structure. 2183 */ 2184 void dfs_cancel_cac_timer(struct wlan_dfs *dfs); 2185 2186 /** 2187 * dfs_start_cac_timer() - Starts the CAC timer. 2188 * @dfs: Pointer to wlan_dfs structure. 2189 */ 2190 void dfs_start_cac_timer(struct wlan_dfs *dfs); 2191 2192 /** 2193 * dfs_cac_valid_reset_for_freq() - Cancels the dfs_cac_valid_timer timer. 2194 * @dfs: Pointer to wlan_dfs structure. 2195 * @prevchan_chan: Prevchan frequency 2196 * @prevchan_flags: Prevchan flags. 2197 */ 2198 #ifdef CONFIG_CHAN_FREQ_API 2199 void dfs_cac_valid_reset_for_freq(struct wlan_dfs *dfs, 2200 uint16_t prevchan_freq, 2201 uint32_t prevchan_flags); 2202 #endif 2203 2204 /** 2205 * dfs_get_override_cac_timeout() - Get override CAC timeout value. 2206 * @dfs: Pointer to DFS object. 2207 * @cac_timeout: Pointer to save the CAC timeout value. 2208 */ 2209 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, 2210 int *cac_timeout); 2211 2212 /** 2213 * dfs_override_cac_timeout() - Override the default CAC timeout. 2214 * @dfs: Pointer to DFS object. 2215 * @cac_timeout: CAC timeout value. 2216 */ 2217 int dfs_override_cac_timeout(struct wlan_dfs *dfs, 2218 int cac_timeout); 2219 2220 /** 2221 * dfs_is_ap_cac_timer_running() - Returns the dfs cac timer. 2222 * @dfs: Pointer to wlan_dfs structure. 2223 */ 2224 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs); 2225 2226 /** 2227 * dfs_cac_timer_attach() - Initialize cac timers. 2228 * @dfs: Pointer to wlan_dfs structure. 2229 */ 2230 void dfs_cac_timer_attach(struct wlan_dfs *dfs); 2231 2232 /** 2233 * dfs_cac_timer_reset() - Cancel dfs cac timers. 2234 * @dfs: Pointer to wlan_dfs structure. 2235 */ 2236 void dfs_cac_timer_reset(struct wlan_dfs *dfs); 2237 2238 /** 2239 * dfs_cac_timer_detach() - Free dfs cac timers. 2240 * @dfs: Pointer to wlan_dfs structure. 2241 */ 2242 void dfs_cac_timer_detach(struct wlan_dfs *dfs); 2243 2244 /** 2245 * dfs_deliver_cac_state_events() - Deliver the DFS CAC events namely 2246 * WLAN_EV_CAC_STARTED on cac started channel(current channel) and 2247 * WLAN_EV_CAC_RESET on previous dfs channel. 2248 * 2249 * @dfs: Pointer to wlan_dfs structure. 2250 */ 2251 #if defined(WLAN_DISP_CHAN_INFO) 2252 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs); 2253 #else 2254 static inline 2255 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs) 2256 { 2257 } 2258 #endif 2259 #else 2260 static inline 2261 void dfs_stacac_stop(struct wlan_dfs *dfs) 2262 { 2263 } 2264 2265 static inline 2266 bool dfs_is_cac_required(struct wlan_dfs *dfs, 2267 struct dfs_channel *cur_chan, 2268 struct dfs_channel *prev_chan, 2269 bool *continue_current_cac, 2270 bool is_vap_restart) 2271 { 2272 return false; 2273 } 2274 2275 static inline 2276 void dfs_cac_stop(struct wlan_dfs *dfs) 2277 { 2278 } 2279 2280 static inline 2281 void dfs_cancel_cac_timer(struct wlan_dfs *dfs) 2282 { 2283 } 2284 2285 static inline 2286 void dfs_start_cac_timer(struct wlan_dfs *dfs) 2287 { 2288 } 2289 2290 #ifdef CONFIG_CHAN_FREQ_API 2291 static inline 2292 void dfs_cac_valid_reset_for_freq(struct wlan_dfs *dfs, 2293 uint16_t prevchan_freq, 2294 uint32_t prevchan_flags) 2295 { 2296 } 2297 #endif 2298 2299 static inline 2300 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, 2301 int *cac_timeout) 2302 { 2303 return 0; 2304 } 2305 2306 static inline 2307 int dfs_override_cac_timeout(struct wlan_dfs *dfs, 2308 int cac_timeout) 2309 { 2310 return 0; 2311 } 2312 2313 static inline 2314 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs) 2315 { 2316 return 0; 2317 } 2318 2319 static inline 2320 void dfs_cac_timer_attach(struct wlan_dfs *dfs) 2321 { 2322 } 2323 2324 static inline 2325 void dfs_cac_timer_reset(struct wlan_dfs *dfs) 2326 { 2327 } 2328 2329 static inline 2330 void dfs_cac_timer_detach(struct wlan_dfs *dfs) 2331 { 2332 } 2333 2334 static inline 2335 void dfs_deliver_cac_state_events(struct wlan_dfs *dfs) 2336 { 2337 } 2338 #endif 2339 /** 2340 * dfs_set_update_nol_flag() - Sets update_nol flag. 2341 * @dfs: Pointer to wlan_dfs structure. 2342 * @val: update_nol flag. 2343 */ 2344 void dfs_set_update_nol_flag(struct wlan_dfs *dfs, 2345 bool val); 2346 2347 /** 2348 * dfs_get_update_nol_flag() - Returns update_nol flag. 2349 * @dfs: Pointer to wlan_dfs structure. 2350 */ 2351 bool dfs_get_update_nol_flag(struct wlan_dfs *dfs); 2352 2353 /** 2354 * dfs_get_use_nol() - Get usenol. 2355 * @dfs: Pointer to wlan_dfs structure. 2356 */ 2357 int dfs_get_use_nol(struct wlan_dfs *dfs); 2358 2359 /** 2360 * dfs_get_nol_timeout() - Get NOL timeout. 2361 * @dfs: Pointer to wlan_dfs structure. 2362 */ 2363 int dfs_get_nol_timeout(struct wlan_dfs *dfs); 2364 2365 /** 2366 * dfs_control()- Used to process ioctls related to DFS. 2367 * @dfs: Pointer to wlan_dfs structure. 2368 * @id: Command type. 2369 * @indata: Input buffer. 2370 * @insize: size of the input buffer. 2371 * @outdata: A buffer for the results. 2372 * @outsize: Size of the output buffer. 2373 */ 2374 int dfs_control(struct wlan_dfs *dfs, 2375 u_int id, 2376 void *indata, 2377 uint32_t insize, 2378 void *outdata, 2379 uint32_t *outsize); 2380 2381 /** 2382 * dfs_getnol() - Wrapper function for dfs_get_nol() 2383 * @dfs: Pointer to wlan_dfs structure. 2384 * @dfs_nolinfo: Pointer to dfsreq_nolinfo structure. 2385 */ 2386 void dfs_getnol(struct wlan_dfs *dfs, 2387 void *dfs_nolinfo); 2388 2389 /** 2390 * dfs_clear_nolhistory() - unmarks WLAN_CHAN_CLR_HISTORY_RADAR flag for 2391 * all the channels in dfs_ch_channels. 2392 * @dfs: Pointer to wlan_dfs structure. 2393 */ 2394 #if !defined(MOBILE_DFS_SUPPORT) 2395 void dfs_clear_nolhistory(struct wlan_dfs *dfs); 2396 #else 2397 static inline void 2398 dfs_clear_nolhistory(struct wlan_dfs *dfs) 2399 { 2400 } 2401 #endif 2402 2403 /** 2404 * ol_if_dfs_configure() - Initialize the RADAR table for offload chipsets. 2405 * @dfs: Pointer to wlan_dfs structure. 2406 * 2407 * This is called during a channel change or regulatory domain 2408 * reset; in order to fetch the new configuration information and 2409 * program the DFS pattern matching module. 2410 * 2411 * Eventually this should be split into "fetch config" (which can 2412 * happen at regdomain selection time) and "configure DFS" (which 2413 * can happen at channel config time) so as to minimise overheads 2414 * when doing channel changes. However, this'll do for now. 2415 */ 2416 void ol_if_dfs_configure(struct wlan_dfs *dfs); 2417 2418 /** 2419 * dfs_init_radar_filters() - Init Radar filters. 2420 * @dfs: Pointer to wlan_dfs structure. 2421 * @radar_info: Pointer to wlan_dfs_radar_tab_info structure. 2422 */ 2423 int dfs_init_radar_filters(struct wlan_dfs *dfs, 2424 struct wlan_dfs_radar_tab_info *radar_info); 2425 2426 /** 2427 * dfs_print_filters() - Print the filters. 2428 * @dfs: Pointer to wlan_dfs structure. 2429 */ 2430 void dfs_print_filters(struct wlan_dfs *dfs); 2431 2432 /** 2433 * dfs_clear_stats() - Clear stats. 2434 * @dfs: Pointer to wlan_dfs structure. 2435 */ 2436 void dfs_clear_stats(struct wlan_dfs *dfs); 2437 2438 /** 2439 * dfs_radar_disable() - Disables the radar. 2440 * @dfs: Pointer to wlan_dfs structure. 2441 */ 2442 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2443 int dfs_radar_disable(struct wlan_dfs *dfs); 2444 #else 2445 static inline int dfs_radar_disable(struct wlan_dfs *dfs) 2446 { 2447 return 0; 2448 } 2449 #endif 2450 2451 /** 2452 * dfs_get_debug_info() - Get debug info. 2453 * @dfs: Pointer to wlan_dfs structure. 2454 * @data: void pointer to the data to save dfs_proc_phyerr. 2455 */ 2456 int dfs_get_debug_info(struct wlan_dfs *dfs, 2457 void *data); 2458 2459 2460 /** 2461 * dfs_nol_timer_init() - Initialize NOL timers. 2462 * @dfs: Pointer to wlan_dfs structure. 2463 */ 2464 void dfs_nol_timer_init(struct wlan_dfs *dfs); 2465 2466 /** 2467 * dfs_nol_attach() - Initialize NOL variables. 2468 * @dfs: Pointer to wlan_dfs structure. 2469 */ 2470 void dfs_nol_attach(struct wlan_dfs *dfs); 2471 2472 /** 2473 * dfs_nol_detach() - Detach NOL variables. 2474 * @dfs: Pointer to wlan_dfs structure. 2475 */ 2476 void dfs_nol_detach(struct wlan_dfs *dfs); 2477 2478 /** 2479 * dfs_print_nolhistory() - Print NOL history. 2480 * @dfs: Pointer to wlan_dfs structure. 2481 */ 2482 void dfs_print_nolhistory(struct wlan_dfs *dfs); 2483 2484 /** 2485 * dfs_find_precac_secondary_vht80_chan() - Get a VHT80 channel with the 2486 * precac primary center frequency. 2487 * @dfs: Pointer to wlan_dfs structure. 2488 * @chan: Pointer to dfs channel structure. 2489 */ 2490 void dfs_find_precac_secondary_vht80_chan(struct wlan_dfs *dfs, 2491 struct dfs_channel *chan); 2492 2493 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 2494 /** 2495 * dfs_precac_csa() - Automatically switch the channel to the DFS channel 2496 * on which PreCAC was completed without finding a RADAR. 2497 * Use CSA with TBTT_COUNT to switch the channel. 2498 * @dfs: Pointer to dfs handler. 2499 * 2500 * Return: Void 2501 */ 2502 void dfs_precac_csa(struct wlan_dfs *dfs); 2503 #endif 2504 2505 /** 2506 * dfs_phyerr_param_copy() - Function to copy src buf to dest buf. 2507 * @dst: dest buf. 2508 * @src: src buf. 2509 */ 2510 void dfs_phyerr_param_copy(struct wlan_dfs_phyerr_param *dst, 2511 struct wlan_dfs_phyerr_param *src); 2512 2513 /** 2514 * dfs_get_thresholds() - Get the threshold value. 2515 * @dfs: Pointer to wlan_dfs structure. 2516 * @param: Pointer to wlan_dfs_phyerr_param structure. 2517 */ 2518 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2519 int dfs_get_thresholds(struct wlan_dfs *dfs, 2520 struct wlan_dfs_phyerr_param *param); 2521 #else 2522 static inline int dfs_get_thresholds(struct wlan_dfs *dfs, 2523 struct wlan_dfs_phyerr_param *param) 2524 { 2525 return 0; 2526 } 2527 #endif 2528 2529 /** 2530 * dfs_set_thresholds() - Sets the threshold value. 2531 * @dfs: Pointer to wlan_dfs structure. 2532 * @threshtype: DFS ioctl param type. 2533 * @value: Threshold value. 2534 */ 2535 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2536 int dfs_set_thresholds(struct wlan_dfs *dfs, 2537 const uint32_t threshtype, 2538 const uint32_t value); 2539 #else 2540 static inline int dfs_set_thresholds(struct wlan_dfs *dfs, 2541 const uint32_t threshtype, 2542 const uint32_t value) 2543 { 2544 return 0; 2545 } 2546 #endif 2547 2548 /** 2549 * dfs_check_intersect_excl() - Check whether curfreq falls within lower_freq 2550 * and upper_freq, exclusively. 2551 * @low_freq : lower bound frequency value. 2552 * @high_freq: upper bound frequency value. 2553 * @chan_freq: Current frequency value to be checked. 2554 * 2555 * Return: returns true if overlap found, else returns false. 2556 */ 2557 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2558 bool dfs_check_intersect_excl(int low_freq, int high_freq, int chan_freq); 2559 #else 2560 static inline bool dfs_check_intersect_excl(int low_freq, int high_freq, 2561 int chan_freq) 2562 { 2563 return false; 2564 } 2565 #endif 2566 2567 /** 2568 * dfs_check_etsi_overlap() - Check whether given frequency centre/channel 2569 * width entry overlap with frequency spread in any way. 2570 * @center_freq : current channel centre frequency. 2571 * @chan_width : current channel width. 2572 * @en302_502_freq_low : overlap frequency lower bound. 2573 * @en302_502_freq_high : overlap frequency upper bound. 2574 * 2575 * Return: returns 1 if overlap found, else returns 0. 2576 */ 2577 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2578 int dfs_check_etsi_overlap(int center_freq, int chan_width, 2579 int en302_502_freq_low, int en302_502_freq_high); 2580 #else 2581 static inline int dfs_check_etsi_overlap(int center_freq, int chan_width, 2582 int en302_502_freq_low, 2583 int en302_502_freq_high) 2584 { 2585 return 0; 2586 } 2587 #endif 2588 2589 /** 2590 * dfs_is_en302_502_applicable() - Check whether current channel frequecy spread 2591 * overlaps with EN 302 502 radar type 2592 * frequency range. 2593 *@dfs: Pointer to wlan_dfs structure. 2594 * 2595 * Return: returns true if overlap found, else returns false. 2596 */ 2597 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) 2598 bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs); 2599 #else 2600 static inline bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs) 2601 { 2602 return false; 2603 } 2604 #endif 2605 2606 #ifdef CONFIG_CHAN_FREQ_API 2607 /** 2608 * dfs_set_current_channel_for_freq() - Set DFS current channel. 2609 * @dfs: Pointer to wlan_dfs structure. 2610 * @dfs_chan_freq: Frequency in Mhz. 2611 * @dfs_chan_flags: Channel flags. 2612 * @dfs_chan_flagext: Extended channel flags. 2613 * @dfs_chan_ieee: IEEE channel number. 2614 * @dfs_chan_vhtop_freq_seg1: Channel Center frequency1. 2615 * @dfs_chan_vhtop_freq_seg2: Channel Center frequency2. 2616 * @dfs_chan_mhz_freq_seg1: Channel center frequency of primary segment in MHZ. 2617 * @dfs_chan_mhz_freq_seg2: Channel center frequency of secondary segment in MHZ 2618 * applicable only for 80+80MHZ mode of operation. 2619 * @dfs_chan_op_puncture_bitmap: Static channel puncturing of current channel. 2620 * @is_channel_updated: boolean to represent channel update. 2621 */ 2622 void dfs_set_current_channel_for_freq(struct wlan_dfs *dfs, 2623 uint16_t dfs_chan_freq, 2624 uint64_t dfs_chan_flags, 2625 uint16_t dfs_chan_flagext, 2626 uint8_t dfs_chan_ieee, 2627 uint8_t dfs_chan_vhtop_freq_seg1, 2628 uint8_t dfs_chan_vhtop_freq_seg2, 2629 uint16_t dfs_chan_mhz_freq_seg1, 2630 uint16_t dfs_chan_mhz_freq_seg2, 2631 uint16_t dfs_chan_op_puncture_bitmap, 2632 bool *is_channel_updated); 2633 #endif 2634 /** 2635 * dfs_get_nol_chfreq_and_chwidth() - Get channel freq and width from NOL list. 2636 * @dfs_nol: Pointer to NOL channel entry. 2637 * @nol_chfreq: Pointer to save channel frequency. 2638 * @nol_chwidth: Pointer to save channel width. 2639 * @index: Index to dfs_nol list. 2640 */ 2641 void dfs_get_nol_chfreq_and_chwidth(struct dfsreq_nolelem *dfs_nol, 2642 uint32_t *nol_chfreq, 2643 uint32_t *nol_chwidth, 2644 int index); 2645 2646 /** 2647 * dfs_process_phyerr_owl() - Process an Owl-style phy error. 2648 * @dfs: Pointer to wlan_dfs structure. 2649 * @buf: Phyerr buffer 2650 * @datalen: Phyerr buf len 2651 * @rssi: RSSI 2652 * @ext_rssi: Extension RSSI. 2653 * @rs_tstamp: Time stamp. 2654 * @fulltsf: TSF64. 2655 * @e: Pointer to dfs_phy_err structure. 2656 * 2657 * Return: Returns 1. 2658 */ 2659 int dfs_process_phyerr_owl(struct wlan_dfs *dfs, 2660 void *buf, 2661 uint16_t datalen, 2662 uint8_t rssi, 2663 uint8_t ext_rssi, 2664 uint32_t rs_tstamp, 2665 uint64_t fulltsf, 2666 struct dfs_phy_err *e); 2667 2668 /** 2669 * dfs_process_phyerr_sowl() -Process a Sowl/Howl style phy error. 2670 * @dfs: Pointer to wlan_dfs structure. 2671 * @buf: Phyerr buffer 2672 * @datalen: Phyerr buf len 2673 * @rssi: RSSI 2674 * @ext_rssi: Extension RSSI. 2675 * @rs_tstamp: Time stamp. 2676 * @fulltsf: TSF64. 2677 * @e: Pointer to dfs_phy_err structure. 2678 * 2679 * Return: Returns 1. 2680 */ 2681 int dfs_process_phyerr_sowl(struct wlan_dfs *dfs, 2682 void *buf, 2683 uint16_t datalen, 2684 uint8_t rssi, 2685 uint8_t ext_rssi, 2686 uint32_t rs_tstamp, 2687 uint64_t fulltsf, 2688 struct dfs_phy_err *e); 2689 2690 /** 2691 * dfs_process_phyerr_merlin() - Process a Merlin/Osprey style phy error. 2692 * dfs_phy_err struct. 2693 * @dfs: Pointer to wlan_dfs structure. 2694 * @buf: Phyerr buffer 2695 * @datalen: Phyerr buf len 2696 * @rssi: RSSI 2697 * @ext_rssi: Extension RSSI. 2698 * @rs_tstamp: Time stamp. 2699 * @fulltsf: TSF64. 2700 * @e: Pointer to dfs_phy_err structure. 2701 * 2702 * Return: Returns 1. 2703 */ 2704 int dfs_process_phyerr_merlin(struct wlan_dfs *dfs, 2705 void *buf, 2706 uint16_t datalen, 2707 uint8_t rssi, 2708 uint8_t ext_rssi, 2709 uint32_t rs_tstamp, 2710 uint64_t fulltsf, 2711 struct dfs_phy_err *e); 2712 2713 /* 2714 * __dfs_process_radarevent() - Continuation of process a radar event function. 2715 * @dfs: Pointer to wlan_dfs structure. 2716 * @ft: Pointer to dfs_filtertype structure. 2717 * @re: Pointer to dfs_event structure. 2718 * @this_ts: Timestamp. 2719 * 2720 * There is currently no way to specify that a radar event has occurred on 2721 * a specific channel, so the current methodology is to mark both the pri 2722 * and ext channels as being unavailable. This should be fixed for 802.11ac 2723 * or we'll quickly run out of valid channels to use. 2724 * 2725 * Return: If a radar event is found, return 1. Otherwise, return 0. 2726 */ 2727 void __dfs_process_radarevent(struct wlan_dfs *dfs, 2728 struct dfs_filtertype *ft, 2729 struct dfs_event *re, 2730 uint64_t this_ts, 2731 int *found, 2732 int *false_radar_found); 2733 2734 /** 2735 * dfs_radar_found_action() - Radar found action 2736 * @dfs: Pointer to wlan_dfs structure. 2737 * @bangradar: true if radar is due to bangradar command. 2738 * @seg_id: Segment id. 2739 */ 2740 void dfs_radar_found_action(struct wlan_dfs *dfs, 2741 bool bangradar, 2742 uint8_t seg_id); 2743 2744 /** 2745 * bin5_rules_check_internal() - This is a extension of dfs_bin5_check(). 2746 * @dfs: Pointer to wlan_dfs structure. 2747 * @br: Pointer to dfs_bin5radars structure. 2748 * @bursts: Bursts. 2749 * @numevents: Number of events. 2750 * @prev: prev index. 2751 * @i: Index. 2752 * @this: index to br_elems[] 2753 */ 2754 void bin5_rules_check_internal(struct wlan_dfs *dfs, 2755 struct dfs_bin5radars *br, 2756 uint32_t *bursts, 2757 uint32_t *numevents, 2758 uint32_t prev, 2759 uint32_t i, 2760 uint32_t this, 2761 int *index); 2762 2763 /** 2764 * dfs_main_task_testtimer_init() - Initialize dfs task testtimer. 2765 * @dfs: Pointer to wlan_dfs structure. 2766 */ 2767 void dfs_main_task_testtimer_init(struct wlan_dfs *dfs); 2768 2769 /** 2770 * dfs_stop() - Clear dfs timers. 2771 * @dfs: Pointer to wlan_dfs structure. 2772 */ 2773 void dfs_stop(struct wlan_dfs *dfs); 2774 2775 /** 2776 * dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 2777 * @dfs: Pointer to wlan_dfs structure. 2778 * @flags: New channel flags 2779 * @flagext: New Extended flags 2780 */ 2781 void dfs_update_cur_chan_flags(struct wlan_dfs *dfs, 2782 uint64_t flags, 2783 uint16_t flagext); 2784 2785 /** 2786 * wlan_psoc_get_dfs_txops() - Get dfs_tx_ops pointer 2787 * @psoc: Pointer to psoc structure. 2788 * 2789 * Return: Pointer to dfs_tx_ops. 2790 */ 2791 struct wlan_lmac_if_dfs_tx_ops * 2792 wlan_psoc_get_dfs_txops(struct wlan_objmgr_psoc *psoc); 2793 2794 /** 2795 * dfs_nol_free_list() - Free NOL elements. 2796 * @dfs: Pointer to wlan_dfs structure. 2797 */ 2798 void dfs_nol_free_list(struct wlan_dfs *dfs); 2799 2800 /** 2801 * dfs_second_segment_radar_disable() - Disables the second segment radar. 2802 * @dfs: Pointer to wlan_dfs structure. 2803 * 2804 * This is called when AP detects the radar, to (potentially) disable 2805 * the radar code. 2806 * 2807 * Return: returns 0. 2808 */ 2809 int dfs_second_segment_radar_disable(struct wlan_dfs *dfs); 2810 2811 /** 2812 * dfs_fetch_nol_ie_info() - Fill NOL information to be sent with RCSA. 2813 * @dfs - Pointer to wlan_dfs structure. 2814 * @nol_ie_bandwidth - Minimum subchannel bandwidth. 2815 * @nol_ie_startfreq - Radar affected channel list's first subchannel's 2816 * - centre frequency. 2817 * @nol_ie_bitmap - NOL bitmap denoting affected subchannels. 2818 */ 2819 #if defined(QCA_DFS_RCSA_SUPPORT) 2820 void dfs_fetch_nol_ie_info(struct wlan_dfs *dfs, uint8_t *nol_ie_bandwidth, 2821 uint16_t *nol_ie_startfreq, uint8_t *nol_ie_bitmap); 2822 #else 2823 static inline 2824 void dfs_fetch_nol_ie_info(struct wlan_dfs *dfs, uint8_t *nol_ie_bandwidth, 2825 uint16_t *nol_ie_startfreq, uint8_t *nol_ie_bitmap) 2826 { 2827 *nol_ie_bandwidth = 0; 2828 *nol_ie_startfreq = 0; 2829 *nol_ie_bitmap = 0; 2830 } 2831 #endif 2832 2833 /** 2834 * dfs_set_rcsa_flags() - Set flags that are required for sending RCSA and 2835 * NOL IE. 2836 * @dfs: Pointer to wlan_dfs structure. 2837 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 2838 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 2839 */ 2840 #if defined(QCA_DFS_RCSA_SUPPORT) 2841 void dfs_set_rcsa_flags(struct wlan_dfs *dfs, bool is_rcsa_ie_sent, 2842 bool is_nol_ie_sent); 2843 #else 2844 static inline 2845 void dfs_set_rcsa_flags(struct wlan_dfs *dfs, bool is_rcsa_ie_sent, 2846 bool is_nol_ie_sent) 2847 { 2848 } 2849 #endif 2850 2851 /** 2852 * dfs_get_rcsa_flags() - Get flags that are required for sending RCSA and 2853 * NOL IE. 2854 * @dfs: Pointer to wlan_dfs structure. 2855 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 2856 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 2857 */ 2858 #if defined(QCA_DFS_RCSA_SUPPORT) 2859 void dfs_get_rcsa_flags(struct wlan_dfs *dfs, bool *is_rcsa_ie_sent, 2860 bool *is_nol_ie_sent); 2861 #else 2862 static inline 2863 void dfs_get_rcsa_flags(struct wlan_dfs *dfs, bool *is_rcsa_ie_sent, 2864 bool *is_nol_ie_sent) 2865 { 2866 *is_rcsa_ie_sent = false; 2867 *is_nol_ie_sent = false; 2868 } 2869 #endif 2870 2871 /** 2872 * dfs_process_nol_ie_bitmap() - Update NOL with external radar information. 2873 * @dfs - Pointer to wlan_dfs structure. 2874 * @nol_ie_bandwidth - Minimum subchannel bandwidth. 2875 * @nol_ie_starfreq - Radar affected channel list's first subchannel's 2876 * - centre frequency. 2877 * @nol_ie_bitmap - Bitmap denoting radar affected subchannels. 2878 * 2879 * Return: True if NOL IE should be propagated, else false. 2880 */ 2881 #if defined(QCA_DFS_RCSA_SUPPORT) 2882 bool dfs_process_nol_ie_bitmap(struct wlan_dfs *dfs, uint8_t nol_ie_bandwidth, 2883 uint16_t nol_ie_startfreq, 2884 uint8_t nol_ie_bitmap); 2885 #else 2886 static inline 2887 bool dfs_process_nol_ie_bitmap(struct wlan_dfs *dfs, uint8_t nol_ie_bandwidth, 2888 uint16_t nol_ie_startfreq, 2889 uint8_t nol_ie_bitmap) 2890 { 2891 return false; 2892 } 2893 #endif 2894 2895 /** 2896 * dfs_task_testtimer_reset() - stop dfs test timer. 2897 * @dfs: Pointer to wlan_dfs structure. 2898 */ 2899 void dfs_task_testtimer_reset(struct wlan_dfs *dfs); 2900 2901 /** 2902 * dfs_is_freq_in_nol() - check if given channel in nol list 2903 * @dfs: Pointer to wlan_dfs structure 2904 * @freq: channel frequency 2905 * 2906 * check if given channel in nol list. 2907 * 2908 * Return: true if channel in nol, false else 2909 */ 2910 bool dfs_is_freq_in_nol(struct wlan_dfs *dfs, uint32_t freq); 2911 2912 /** 2913 * dfs_task_testtimer_detach() - Free dfs test timer. 2914 * @dfs: Pointer to wlan_dfs structure. 2915 */ 2916 void dfs_task_testtimer_detach(struct wlan_dfs *dfs); 2917 2918 /** 2919 * dfs_timer_detach() - Free dfs timers. 2920 * @dfs: Pointer to wlan_dfs structure. 2921 */ 2922 void dfs_timer_detach(struct wlan_dfs *dfs); 2923 2924 /** 2925 * dfs_is_disable_radar_marking_set() - Check if radar marking is set on 2926 * NOL chan. 2927 * @dfs: Pointer to wlan_dfs structure. 2928 */ 2929 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 2930 int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs, 2931 bool *disable_radar_marking); 2932 #else 2933 static inline int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs, 2934 bool *disable_radar_marking) 2935 { 2936 return QDF_STATUS_SUCCESS; 2937 } 2938 #endif 2939 /** 2940 * dfs_get_disable_radar_marking() - Get the value of disable radar marking. 2941 * @dfs: Pointer to wlan_dfs structure. 2942 */ 2943 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 2944 bool dfs_get_disable_radar_marking(struct wlan_dfs *dfs); 2945 #else 2946 static inline bool dfs_get_disable_radar_marking(struct wlan_dfs *dfs) 2947 { 2948 return false; 2949 } 2950 #endif 2951 2952 /** 2953 * dfs_reset_agile_config() - Reset the ADFS config variables. 2954 * @dfs: Pointer to dfs_soc_priv_obj. 2955 */ 2956 #ifdef QCA_SUPPORT_AGILE_DFS 2957 void dfs_reset_agile_config(struct dfs_soc_priv_obj *dfs_soc); 2958 #endif 2959 2960 /** 2961 * dfs_reinit_timers() - Reinit timers in DFS. 2962 * @dfs: Pointer to wlan_dfs. 2963 */ 2964 int dfs_reinit_timers(struct wlan_dfs *dfs); 2965 2966 /** 2967 * dfs_reset_dfs_prevchan() - Reset DFS previous channel structure. 2968 * @dfs: Pointer to wlan_dfs object. 2969 * 2970 * Return: None. 2971 */ 2972 void dfs_reset_dfs_prevchan(struct wlan_dfs *dfs); 2973 2974 /** 2975 * dfs_init_tmp_psoc_nol() - Init temporary psoc NOL structure. 2976 * @dfs: Pointer to wlan_dfs object. 2977 * @num_radios: Num of radios in the PSOC. 2978 * 2979 * Return: void. 2980 */ 2981 void dfs_init_tmp_psoc_nol(struct wlan_dfs *dfs, uint8_t num_radios); 2982 2983 /** 2984 * dfs_deinit_tmp_psoc_nol() - De-init temporary psoc NOL structure. 2985 * @dfs: Pointer to wlan_dfs object. 2986 * 2987 * Return: void. 2988 */ 2989 void dfs_deinit_tmp_psoc_nol(struct wlan_dfs *dfs); 2990 2991 /** 2992 * dfs_save_dfs_nol_in_psoc() - Save NOL data of given pdev. 2993 * @dfs: Pointer to wlan_dfs object. 2994 * @pdev_id: The pdev ID which will have the NOL data. 2995 * 2996 * Based on the frequency of the NOL channel, copy it to the target pdev_id 2997 * structure in psoc. 2998 * 2999 * Return: void. 3000 */ 3001 void dfs_save_dfs_nol_in_psoc(struct wlan_dfs *dfs, uint8_t pdev_id); 3002 3003 /** 3004 * dfs_reinit_nol_from_psoc_copy() - Reinit saved NOL data to corresponding 3005 * DFS object. 3006 * @dfs: Pointer to wlan_dfs object. 3007 * @pdev_id: pdev_id of the given dfs object. 3008 * @low_5ghz_freq: The low 5GHz frequency value of the target pdev id. 3009 * @high_5ghz_freq: The high 5GHz frequency value of the target pdev id. 3010 * 3011 * Return: void. 3012 */ 3013 void dfs_reinit_nol_from_psoc_copy(struct wlan_dfs *dfs, 3014 uint8_t pdev_id, 3015 uint16_t low_5ghz_freq, 3016 uint16_t high_5ghz_freq); 3017 3018 /** 3019 * dfs_is_hw_mode_switch_in_progress() - Check if HW mode switch in progress. 3020 * @dfs: Pointer to wlan_dfs object. 3021 * 3022 * Return: True if mode switch is in progress, else false. 3023 */ 3024 #ifdef QCA_HW_MODE_SWITCH 3025 bool dfs_is_hw_mode_switch_in_progress(struct wlan_dfs *dfs); 3026 #else 3027 static inline 3028 bool dfs_is_hw_mode_switch_in_progress(struct wlan_dfs *dfs) 3029 { 3030 return false; 3031 } 3032 #endif 3033 3034 /** 3035 * dfs_start_mode_switch_defer_timer() - start mode switch defer timer. 3036 * @dfs: Pointer to wlan_dfs object. 3037 * 3038 * Return: void. 3039 */ 3040 void dfs_start_mode_switch_defer_timer(struct wlan_dfs *dfs); 3041 3042 /** 3043 * dfs_complete_deferred_tasks() - Process mode switch completion event and 3044 * handle deffered tasks. 3045 * @dfs: Pointer to wlan_dfs object. 3046 * 3047 * Return: void. 3048 */ 3049 void dfs_complete_deferred_tasks(struct wlan_dfs *dfs); 3050 3051 /** 3052 * dfs_process_cac_completion() - Process DFS CAC completion event. 3053 * @dfs: Pointer to wlan_dfs object. 3054 * 3055 * Return: void. 3056 */ 3057 void dfs_process_cac_completion(struct wlan_dfs *dfs); 3058 3059 #ifdef WLAN_DFS_TRUE_160MHZ_SUPPORT 3060 /** 3061 * dfs_is_true_160mhz_supported() - Find if true 160MHz is supported. 3062 * @dfs: Pointer to wlan_dfs object. 3063 * 3064 * Return: True if true 160MHz is supported, else false. 3065 */ 3066 bool dfs_is_true_160mhz_supported(struct wlan_dfs *dfs); 3067 3068 /** 3069 * dfs_is_restricted_80p80mhz_supported() - Find if restricted 80p80mhz is 3070 * supported. 3071 * @dfs: Pointer to wlan_dfs object. 3072 * 3073 * Return: True if restricted 160MHz is supported, else false. 3074 */ 3075 bool dfs_is_restricted_80p80mhz_supported(struct wlan_dfs *dfs); 3076 #else 3077 static inline bool dfs_is_true_160mhz_supported(struct wlan_dfs *dfs) 3078 { 3079 return false; 3080 } 3081 3082 static inline bool dfs_is_restricted_80p80mhz_supported(struct wlan_dfs *dfs) 3083 { 3084 return false; 3085 } 3086 #endif /* WLAN_DFS_TRUE_160MHZ_SUPPORT */ 3087 3088 /** 3089 * dfs_get_agile_detector_id() - Find the Agile detector ID for given DFS. 3090 * @dfs: Pointer to wlan_dfs object. 3091 * 3092 * Return: Agile detector value (uint8_t). 3093 */ 3094 #ifdef QCA_SUPPORT_AGILE_DFS 3095 uint8_t dfs_get_agile_detector_id(struct wlan_dfs *dfs); 3096 #else 3097 static inline uint8_t dfs_get_agile_detector_id(struct wlan_dfs *dfs) 3098 { 3099 return INVALID_DETECTOR_ID; 3100 } 3101 #endif 3102 3103 /** 3104 * dfs_is_new_chan_subset_of_old_chan() - Find if new channel is subset of 3105 * old channel. 3106 * @dfs: Pointer to wlan_dfs structure. 3107 * @new_chan: Pointer to new channel of dfs_channel structure. 3108 * @old_chan: Pointer to old channel of dfs_channel structure. 3109 * 3110 * Return: True if new channel is subset of old channel, else false. 3111 */ 3112 bool dfs_is_new_chan_subset_of_old_chan(struct wlan_dfs *dfs, 3113 struct dfs_channel *new_chan, 3114 struct dfs_channel *old_chan); 3115 3116 /** 3117 * dfs_find_dfs_sub_channels_for_freq() - Given a dfs channel, find its 3118 * HT20 subset channels. 3119 * @dfs: Pointer to wlan_dfs structure. 3120 * @chan: Pointer to dfs_channel structure. 3121 * @subchan_arr: Pointer to subchannels array. 3122 * 3123 * Return: Number of sub channels. 3124 */ 3125 uint8_t dfs_find_dfs_sub_channels_for_freq(struct wlan_dfs *dfs, 3126 struct dfs_channel *chan, 3127 uint16_t *subchan_arr); 3128 3129 /** 3130 * dfs_clear_cac_started_chan() - Clear dfs cac started channel. 3131 * @dfs: Pointer to wlan_dfs structure. 3132 */ 3133 void dfs_clear_cac_started_chan(struct wlan_dfs *dfs); 3134 3135 #ifdef QCA_DFS_BANGRADAR 3136 /** 3137 * dfs_bangradar() - Handles all type of Bangradar. 3138 * @dfs: Pointer to wlan_dfs structure. 3139 * @indata: reference to input data 3140 * @insize: input data size 3141 * 3142 */ 3143 int dfs_bang_radar(struct wlan_dfs *dfs, void *indata, uint32_t insize); 3144 #else 3145 static inline int 3146 dfs_bang_radar(struct wlan_dfs *dfs, void *indata, uint32_t insize) 3147 { 3148 return 0; 3149 } 3150 #endif 3151 3152 #if defined(QCA_SUPPORT_DFS_CHAN_POSTNOL) 3153 void dfs_postnol_attach(struct wlan_dfs *dfs); 3154 #else 3155 static inline void dfs_postnol_attach(struct wlan_dfs *dfs) 3156 { 3157 } 3158 #endif 3159 3160 #ifdef CONFIG_HOST_FIND_CHAN 3161 /** 3162 * wlan_is_chan_radar() - Checks if a given dfs channel is in NOL or not. 3163 * @dfs: Pointer to wlan_dfs structure. 3164 * @chan: Pointer to the dfs channel structure. 3165 * 3166 * Return: True if the channel has detected radar, else false. 3167 */ 3168 bool wlan_is_chan_radar(struct wlan_dfs *dfs, struct dfs_channel *chan); 3169 3170 /** 3171 * wlan_is_chan_history_radar() - Checks if a given dfs channel is in NOL 3172 * history or not. 3173 * @dfs: Pointer to wlan_dfs structure. 3174 * @chan: Pointer to the dfs channel structure. 3175 * 3176 * Return: True if the channel is marked as radar history, else false. 3177 */ 3178 bool wlan_is_chan_history_radar(struct wlan_dfs *dfs, struct dfs_channel *chan); 3179 #else 3180 static inline bool 3181 wlan_is_chan_radar(struct wlan_dfs *dfs, struct dfs_channel *chan) 3182 { 3183 return false; 3184 } 3185 3186 static inline bool 3187 wlan_is_chan_history_radar(struct wlan_dfs *dfs, struct dfs_channel *chan) 3188 { 3189 return false; 3190 } 3191 #endif /* CONFIG_HOST_FIND_CHAN */ 3192 3193 #if defined(QCA_SUPPORT_ADFS_RCAC) && \ 3194 defined(WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT) && \ 3195 defined(QCA_SUPPORT_AGILE_DFS) 3196 /** 3197 * dfs_restart_rcac_on_nol_expiry() - If the chosen desired channel is 3198 * radar infected during RCAC, trigger RCAC on desired channel after 3199 * NOL expiry. 3200 * @dfs: Pointer to wlan_dfs structure. 3201 * 3202 * Return: True if rcac is started, false otherwise 3203 */ 3204 bool dfs_restart_rcac_on_nol_expiry(struct wlan_dfs *dfs); 3205 #else 3206 static inline bool 3207 dfs_restart_rcac_on_nol_expiry(struct wlan_dfs *dfs) 3208 { 3209 return false; 3210 } 3211 #endif 3212 #endif /* _DFS_H_ */ 3213