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