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