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