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(&(_dfs)->dfs_radarqlock) 154 #define WLAN_DFSQ_UNLOCK(_dfs) qdf_spin_unlock(&(_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(&(_dfs)->dfs_arqlock) 161 #define WLAN_ARQ_UNLOCK(_dfs) qdf_spin_unlock(&(_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(&(_dfs)->dfs_eventqlock) 166 #define WLAN_DFSEVENTQ_UNLOCK(_dfs) qdf_spin_unlock( \ 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 /** 266 * Software use: channel interference used for as AR as well as RADAR 267 * interference detection. 268 */ 269 #define CHANNEL_INTERFERENCE 0x01 270 271 #define CHANNEL_2GHZ 0x00080 /* 2 GHz spectrum channel. */ 272 #define CHANNEL_OFDM 0x00040 /* OFDM channel */ 273 #define CHANNEL_TURBO 0x00010 /* Turbo Channel */ 274 #define CHANNEL_108G (CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO) 275 276 /* qdf_packed - denotes structure is packed. */ 277 #define qdf_packed __qdf_packed 278 279 #define SEG_ID_PRIMARY 0 280 #define SEG_ID_SECONDARY 1 281 282 /* MIN and MAX width for different regions */ 283 #define REG0_MIN_WIDTH 33 284 #define REG0_MAX_WIDTH 38 285 #define REG1_MIN_WIDTH 39 286 #define REG1_MAX_WIDTH 44 287 #define REG2_MIN_WIDTH 53 288 #define REG2_MAX_WIDTH 58 289 #define REG3_MIN_WIDTH 126 290 #define REG3_MAX_WIDTH 140 291 #define REG4_MIN_WIDTH 141 292 #define REG4_MAX_WIDTH 160 293 #define REG5_MIN_WIDTH 189 294 #define REG5_MAX_WIDTH 210 295 #define REG6_MIN_WIDTH 360 296 #define REG6_MAX_WIDTH 380 297 #define REG7_MIN_WIDTH 257 298 #define REG7_MAX_WIDTH 270 299 #define REG8_MIN_WIDTH 295 300 #define REG8_MAX_WIDTH 302 301 302 #define OVER_SAMPLING_FREQ 44000 303 #define SAMPLING_FREQ 40000 304 #define HUNDRED 100 305 #define NUM_BINS 128 306 #define THOUSAND 1000 307 308 /* Check if the dfs current channel is 5.8GHz */ 309 #define DFS_CURCHAN_IS_58GHz(freq) \ 310 ((((freq) >= 5745) && ((freq) <= 5865)) ? true : false) 311 312 /* ETSI11_WORLD regdmn pair id */ 313 #define ETSI11_WORLD_REGDMN_PAIR_ID 0x26 314 315 /* Array offset to ETSI legacy pulse */ 316 #define ETSI_LEGACY_PULSE_ARR_OFFSET 2 317 318 #define DFS_NOL_ADD_CHAN_LOCKED(dfs, freq, timeout) \ 319 do { \ 320 WLAN_DFSNOL_LOCK(dfs); \ 321 dfs_nol_addchan(dfs, freq, timeout); \ 322 WLAN_DFSNOL_UNLOCK(dfs); \ 323 } while (0) 324 325 #define DFS_NOL_DELETE_CHAN_LOCKED(dfs, freq, chwidth) \ 326 do { \ 327 WLAN_DFSNOL_LOCK(dfs); \ 328 dfs_nol_delete(dfs, freq, chwidth); \ 329 WLAN_DFSNOL_UNLOCK(dfs); \ 330 } while (0) 331 332 #define DFS_GET_NOL_LOCKED(dfs, dfs_nol, nchan) \ 333 do { \ 334 WLAN_DFSNOL_LOCK(dfs); \ 335 dfs_get_nol(dfs, dfs_nol, nchan); \ 336 WLAN_DFSNOL_UNLOCK(dfs); \ 337 } while (0) 338 339 #define DFS_PRINT_NOL_LOCKED(dfs) \ 340 do { \ 341 WLAN_DFSNOL_LOCK(dfs); \ 342 dfs_print_nol(dfs); \ 343 WLAN_DFSNOL_UNLOCK(dfs); \ 344 } while (0) 345 346 #define DFS_NOL_FREE_LIST_LOCKED(dfs) \ 347 do { \ 348 WLAN_DFSNOL_LOCK(dfs); \ 349 dfs_nol_free_list(dfs); \ 350 WLAN_DFSNOL_UNLOCK(dfs); \ 351 } while (0) 352 353 /** 354 * struct dfs_pulseparams - DFS pulse param structure. 355 * @p_time: Time for start of pulse in usecs. 356 * @p_dur: Duration of pulse in usecs. 357 * @p_rssi: RSSI of pulse. 358 * @p_seg_id: Segment id. 359 * @p_sidx: Sidx value. 360 * @p_delta_peak: Delta peak value. 361 * @p_seq_num: Sequence number. 362 */ 363 struct dfs_pulseparams { 364 uint64_t p_time; 365 uint8_t p_dur; 366 uint8_t p_rssi; 367 uint8_t p_seg_id; 368 int16_t p_sidx; 369 int8_t p_delta_peak; 370 uint32_t p_seq_num; 371 } qdf_packed; 372 373 /** 374 * struct dfs_pulseline - Pulseline structure. 375 * @pl_elems[]: array of pulses in delay line. 376 * @pl_firstelem: Index of the first element. 377 * @pl_lastelem: Index of the last element. 378 * @pl_numelems: Number of elements in the delay line. 379 */ 380 struct dfs_pulseline { 381 struct dfs_pulseparams pl_elems[DFS_MAX_PULSE_BUFFER_SIZE]; 382 uint32_t pl_firstelem; 383 uint32_t pl_lastelem; 384 uint32_t pl_numelems; 385 } qdf_packed; 386 387 #define DFS_EVENT_CHECKCHIRP 0x01 /* Whether to check the chirp flag */ 388 #define DFS_EVENT_HW_CHIRP 0x02 /* hardware chirp */ 389 #define DFS_EVENT_SW_CHIRP 0x04 /* software chirp */ 390 391 /* Use this only if the event has CHECKCHIRP set. */ 392 #define DFS_EVENT_ISCHIRP(e) \ 393 ((e)->re_flags & (DFS_EVENT_HW_CHIRP | DFS_EVENT_SW_CHIRP)) 394 395 /** 396 * Check if the given event is to be rejected as not possibly 397 * a chirp. This means: 398 * (a) it's a hardware or software checked chirp, and 399 * (b) the HW/SW chirp bits are both 0. 400 */ 401 #define DFS_EVENT_NOTCHIRP(e) \ 402 (((e)->re_flags & (DFS_EVENT_CHECKCHIRP)) && (!DFS_EVENT_ISCHIRP((e)))) 403 404 /** 405 * struct dfs_event - DFS event structure. 406 * @re_full_ts: 64-bit full timestamp from interrupt time. 407 * @re_ts: Original 15 bit recv timestamp. 408 * @re_rssi: Rssi of radar event. 409 * @re_dur: Duration of radar pulse. 410 * @re_chanindex: Channel of event. 411 * @re_flags: Event flags. 412 * @re_freq: Centre frequency of event, KHz. 413 * @re_freq_lo: Lower bounds of frequency, KHz. 414 * @re_freq_hi: Upper bounds of frequency, KHz. 415 * @re_seg_id: HT80_80/HT160 use. 416 * @re_sidx: Seg index. 417 * @re_freq_offset_khz: Freq offset in KHz 418 * @re_peak_mag: Peak mag. 419 * @re_total_gain: Total gain. 420 * @re_mb_gain: Mb gain. 421 * @re_relpwr_db: Relpower in db. 422 * @re_delta_diff: Delta diff. 423 * @re_delta_peak: Delta peak. 424 * @re_list: List of radar events. 425 */ 426 struct dfs_event { 427 uint64_t re_full_ts; 428 uint32_t re_ts; 429 uint8_t re_rssi; 430 uint8_t re_dur; 431 uint8_t re_chanindex; 432 uint8_t re_flags; 433 uint32_t re_freq; 434 uint32_t re_freq_lo; 435 uint32_t re_freq_hi; 436 uint8_t re_seg_id; 437 int re_sidx; 438 u_int re_freq_offset_khz; 439 int re_peak_mag; 440 int re_total_gain; 441 int re_mb_gain; 442 int re_relpwr_db; 443 uint8_t re_delta_diff; 444 int8_t re_delta_peak; 445 446 STAILQ_ENTRY(dfs_event) re_list; 447 } qdf_packed; 448 449 #define DFS_AR_MAX_ACK_RADAR_DUR 511 450 #define DFS_AR_MAX_NUM_PEAKS 3 451 #define DFS_AR_ARQ_SIZE 2048 /* 8K AR events for buffer size */ 452 #define DFS_AR_ARQ_SEQSIZE 2049 /* Sequence counter wrap for AR */ 453 454 #define DFS_RADARQ_SIZE 512 /* 1K radar events for buffer size */ 455 #define DFS_RADARQ_SEQSIZE 513 /* Sequence counter wrap for radar */ 456 /* Number of radar channels we keep state for */ 457 #define DFS_NUM_RADAR_STATES 64 458 /* Max number radar filters for each type */ 459 #define DFS_MAX_NUM_RADAR_FILTERS 10 460 /* Number of different radar types */ 461 #define DFS_MAX_RADAR_TYPES 32 462 463 /* RADAR filter pattern type 1*/ 464 #define WLAN_DFS_RF_PATTERN_TYPE_1 1 465 466 /** 467 * struct dfs_ar_state - DFS AR state structure. 468 * @ar_prevwidth: Previous width. 469 * @ar_phyerrcount[]: Phy error count. 470 * @ar_acksum: Acksum. 471 * @ar_packetthreshold: Thresh to determine traffic load. 472 * @ar_parthreshold: Thresh to determine peak. 473 * @ar_radarrssi: Rssi threshold for AR event. 474 * @ar_prevtimestamp: Prev time stamp. 475 * @ar_peaklist[]: Peak list. 476 */ 477 struct dfs_ar_state { 478 uint32_t ar_prevwidth; 479 uint32_t ar_phyerrcount[DFS_AR_MAX_ACK_RADAR_DUR]; 480 uint32_t ar_acksum; 481 uint32_t ar_packetthreshold; 482 uint32_t ar_parthreshold; 483 uint32_t ar_radarrssi; 484 uint16_t ar_prevtimestamp; 485 uint16_t ar_peaklist[DFS_AR_MAX_NUM_PEAKS]; 486 }; 487 488 /** 489 * struct dfs_delayelem - Delay Element. 490 * @de_time: Current "filter" time for start of pulse in usecs. 491 * @de_dur: Duration of pulse in usecs. 492 * @de_rssi: Rssi of pulse in dB. 493 * @de_ts: Time stamp for this delay element. 494 * @de_seg_id: Segment id for HT80_80/HT160 use. 495 * @de_sidx: Sidx value. 496 * @de_delta_peak: Delta peak. 497 * @de_seq_num: Sequence number. 498 */ 499 struct dfs_delayelem { 500 uint32_t de_time; 501 uint8_t de_dur; 502 uint8_t de_rssi; 503 uint64_t de_ts; 504 uint8_t de_seg_id; 505 int16_t de_sidx; 506 int8_t de_delta_peak; 507 uint32_t de_seq_num; 508 } qdf_packed; 509 510 /** 511 * struct dfs_delayline - DFS Delay Line. 512 * @dl_elems[]: Array of pulses in delay line. 513 * @dl_last_ts: Last timestamp the delay line was used (in usecs). 514 * @dl_firstelem: Index of the first element. 515 * @dl_lastelem: Index of the last element. 516 * @dl_numelems: Number of elements in the delay line. 517 * The following is to handle fractional PRI pulses that can cause false 518 * detection. 519 * @dl_seq_num_start: Sequence number of first pulse that was part of 520 * threshold match. 521 * @dl_seq_num_stop: Sequence number of last pulse that was part of threshold 522 * match. 523 * The following is required because the first pulse may or may not be in the 524 * delay line but we will find it iin the pulse line using dl_seq_num_second's 525 * diff_ts value. 526 * @dl_seq_num_second: Sequence number of second pulse that was part of 527 * threshold match. 528 * @dl_search_pri: We need final search PRI to identify possible fractional 529 * PRI issue. 530 * @dl_min_sidx: Minimum sidx value of pulses used to match thershold. 531 * Used for sidx spread check. 532 * @dl_max_sidx: Maximum sidx value of pulses used to match thershold. 533 * Used for sidx spread check. 534 * @dl_delta_peak_match_count: Number of pulse in the delay line that had valid 535 * delta peak value. 536 */ 537 struct dfs_delayline { 538 struct dfs_delayelem dl_elems[DFS_MAX_DL_SIZE]; 539 uint64_t dl_last_ts; 540 uint32_t dl_firstelem; 541 uint32_t dl_lastelem; 542 uint32_t dl_numelems; 543 uint32_t dl_seq_num_start; 544 uint32_t dl_seq_num_stop; 545 uint32_t dl_seq_num_second; 546 uint32_t dl_search_pri; 547 int16_t dl_min_sidx; 548 int8_t dl_max_sidx; 549 uint8_t dl_delta_peak_match_count; 550 } qdf_packed; 551 552 /** 553 * struct dfs_filter - Dfs filter. 554 * @rf_dl: Delay line of pulses for this filter. 555 * @rf_numpulses: Number of pulses in the filter. 556 * @rf_minpri: Min pri to be considered for this filter. 557 * @rf_maxpri: Max pri to be considered for this filter. 558 * @rf_threshold: Match filter output threshold for radar detect. 559 * @rf_filterlen: Length (in usecs) of the filter. 560 * @rf_patterntype: Fixed or variable pattern type. 561 * @rf_fixed_pri_radar_pulse: indicates if it is a fixed pri pulse. 562 * @rf_mindur: Min duration for this radar filter. 563 * @rf_maxdur: Max duration for this radar filter. 564 * @rf_ignore_pri_window: Ignore pri window. 565 * @rf_pulseid: Unique ID corresponding to the original filter ID. 566 * To reduce false detection, look at frequency spread. For now we will use 567 * sidx spread. But for HT160 frequency spread will be a better measure. 568 * @rf_sidx_spread: Maximum SIDX value spread in a matched sequence 569 * excluding FCC Bin 5. 570 * @rf_check_delta_peak: Minimum allowed delta_peak value for a pulse to be 571 * considetred for this filter's match. 572 */ 573 struct dfs_filter { 574 struct dfs_delayline rf_dl; 575 uint32_t rf_numpulses; 576 uint32_t rf_minpri; 577 uint32_t rf_maxpri; 578 uint32_t rf_threshold; 579 uint32_t rf_filterlen; 580 uint32_t rf_patterntype; 581 uint32_t rf_fixed_pri_radar_pulse; 582 uint32_t rf_mindur; 583 uint32_t rf_maxdur; 584 uint32_t rf_ignore_pri_window; 585 uint32_t rf_pulseid; 586 uint16_t rf_sidx_spread; 587 int8_t rf_check_delta_peak; 588 } qdf_packed; 589 590 /** 591 * struct dfs_filtertype - DFS Filter type. 592 * @ft_filterdur[]: Filter array. 593 * @ft_filterdur: Duration of pulse which specifies filter type. 594 * @ft_numfilters: Num filters of this type. 595 * @ft_last_ts: Last timestamp this filtertype was used (in usecs). 596 * @ft_mindur: Min pulse duration to be considered for this filter type. 597 * @ft_maxdur: Max pulse duration to be considered for this filter type. 598 * @ft_rssithresh: Min rssi to be considered for this filter type. 599 * @ft_numpulses: Num pulses in each filter of this type. 600 * @ft_patterntype: Fixed or variable pattern type. 601 * @ft_minpri: Min pri to be considered for this type. 602 * @ft_rssimargin: Rssi threshold margin. In Turbo Mode HW reports rssi 3dB 603 * lower than in non TURBO mode. This will offset that diff. 604 */ 605 struct dfs_filtertype { 606 struct dfs_filter ft_filters[DFS_MAX_NUM_RADAR_FILTERS]; 607 uint32_t ft_filterdur; 608 uint32_t ft_numfilters; 609 uint64_t ft_last_ts; 610 uint32_t ft_mindur; 611 uint32_t ft_maxdur; 612 uint32_t ft_rssithresh; 613 uint32_t ft_numpulses; 614 uint32_t ft_patterntype; 615 uint32_t ft_minpri; 616 uint32_t ft_rssimargin; 617 }; 618 619 /** 620 * struct dfs_channel - Channel structure for dfs component. 621 * @dfs_ch_freq: Frequency in Mhz. 622 * @dfs_ch_flags: Channel flags. 623 * @dfs_ch_flagext: Extended channel flags. 624 * @dfs_ch_ieee: IEEE channel number. 625 * @dfs_ch_vhtop_ch_freq_seg1: Channel Center frequency. 626 * @dfs_ch_vhtop_ch_freq_seg2: Channel Center frequency applicable for 80+80MHz 627 * mode of operation. 628 */ 629 struct dfs_channel { 630 uint16_t dfs_ch_freq; 631 uint64_t dfs_ch_flags; 632 uint16_t dfs_ch_flagext; 633 uint8_t dfs_ch_ieee; 634 uint8_t dfs_ch_vhtop_ch_freq_seg1; 635 uint8_t dfs_ch_vhtop_ch_freq_seg2; 636 }; 637 638 /** 639 * struct dfs_state - DFS state. 640 * @rs_chan: Channel info. 641 * @rs_chanindex: Channel index in radar structure. 642 * @rs_numradarevents: Number of radar events. 643 * @rs_param: Phy param. 644 */ 645 struct dfs_state { 646 struct dfs_channel rs_chan; 647 uint8_t rs_chanindex; 648 uint32_t rs_numradarevents; 649 struct wlan_dfs_phyerr_param rs_param; 650 }; 651 652 #define DFS_NOL_TIMEOUT_S (30*60) /* 30 minutes in seconds */ 653 #define DFS_NOL_TIMEOUT_MS (DFS_NOL_TIMEOUT_S * 1000) 654 #define DFS_NOL_TIMEOUT_US (DFS_NOL_TIMEOUT_MS * 1000) 655 656 /** 657 * struct dfs_nolelem - DFS NOL element. 658 * @nol_dfs Back pointer to dfs object. 659 * @nol_freq: Centre frequency. 660 * @nol_chwidth: Event width (MHz). 661 * @nol_start_ticks: NOL start time in OS ticks. 662 * @nol_timeout_ms: NOL timeout value in msec. 663 * @nol_timer: Per element NOL timer. 664 * @nol_next: Next element pointer. 665 */ 666 struct dfs_nolelem { 667 TAILQ_ENTRY(dfs_nolelem) nolelem_list; 668 struct wlan_dfs *nol_dfs; 669 uint32_t nol_freq; 670 uint32_t nol_chwidth; 671 unsigned long nol_start_ticks; 672 uint32_t nol_timeout_ms; 673 os_timer_t nol_timer; 674 struct dfs_nolelem *nol_next; 675 } qdf_packed; 676 677 678 /** 679 * struct dfs_info - DFS Info. 680 * @rn_ftindex: Number of different types of radars. 681 * @rn_lastfull_ts: Last 64 bit timstamp from recv interrupt. 682 * @rn_last_ts: last 15 bit ts from recv descriptor. 683 * @rn_last_unique_ts: last unique 32 bit ts from recv descriptor. 684 * @rn_ts_prefix: Prefix to prepend to 15 bit recv ts. 685 * @rn_numbin5radars: Number of bin5 radar pulses to search for. 686 * @rn_fastdivGCval: Value of fast diversity gc limit from init file. 687 * @rn_minrssithresh: Min rssi for all radar types. 688 * @rn_maxpulsedur: Max pulse width in TSF ticks. 689 * @dfs_ext_chan_busy: Ext chan busy. 690 * @ext_chan_busy_ts: Ext chan busy time. 691 * @dfs_bin5_chirp_ts: Ext bin5 chrip time. 692 * @dfs_last_bin5_dur: Last bin5 during. 693 */ 694 struct dfs_info { 695 uint32_t rn_ftindex; 696 uint64_t rn_lastfull_ts; 697 uint16_t rn_last_ts; 698 uint32_t rn_last_unique_ts; 699 uint64_t rn_ts_prefix; 700 uint32_t rn_numbin5radars; 701 uint32_t rn_fastdivGCval; 702 int32_t rn_minrssithresh; 703 uint32_t rn_maxpulsedur; 704 uint8_t dfs_ext_chan_busy; 705 uint64_t ext_chan_busy_ts; 706 uint64_t dfs_bin5_chirp_ts; 707 uint8_t dfs_last_bin5_dur; 708 } qdf_packed; 709 710 /** 711 * struct dfs_bin5elem - BIN5 elements. 712 * @be_ts: Timestamp for the bin5 element. 713 * @be_rssi: Rssi for the bin5 element. 714 * @be_dur: Duration of bin5 element. 715 */ 716 struct dfs_bin5elem { 717 uint64_t be_ts; 718 uint32_t be_rssi; 719 uint32_t be_dur; 720 }; 721 722 /** 723 * struct dfs_bin5radars - BIN5 radars. 724 * @br_elems[]: List of bin5 elems that fall within the time window. 725 * @br_firstelem: Index of the first element. 726 * @br_lastelem: Index of the last element. 727 * @br_numelems: Number of elements in the delay line. 728 * @br_pulse: Original info about bin5 pulse. 729 */ 730 struct dfs_bin5radars { 731 struct dfs_bin5elem br_elems[DFS_MAX_B5_SIZE]; 732 uint32_t br_firstelem; 733 uint32_t br_lastelem; 734 uint32_t br_numelems; 735 struct dfs_bin5pulse br_pulse; 736 }; 737 738 /** 739 * struct dfs_stats - DFS stats. 740 * @num_radar_detects: Total num. of radar detects. 741 * @num_seg_two_radar_detects: Total num. of radar detected in secondary segment 742 * @total_phy_errors: Total PHY errors. 743 * @owl_phy_errors: OWL PHY errors. 744 * @pri_phy_errors: Primary channel phy errors. 745 * @ext_phy_errors: Extension channel phy errors. 746 * @dc_phy_errors: DC PHY errors. 747 * @early_ext_phy_errors: Extension channel early radar found error. 748 * @bwinfo_errors: Bogus bandwidth info received in descriptor. 749 * @datalen_discards: data length at least three bytes of payload. 750 * @rssi_discards: RSSI is not accurate. 751 * @last_reset_tstamp: Last reset timestamp. 752 */ 753 struct dfs_stats { 754 uint32_t num_radar_detects; 755 uint32_t num_seg_two_radar_detects; 756 uint32_t total_phy_errors; 757 uint32_t owl_phy_errors; 758 uint32_t pri_phy_errors; 759 uint32_t ext_phy_errors; 760 uint32_t dc_phy_errors; 761 uint32_t early_ext_phy_errors; 762 uint32_t bwinfo_errors; 763 uint32_t datalen_discards; 764 uint32_t rssi_discards; 765 uint64_t last_reset_tstamp; 766 }; 767 768 #define DFS_EVENT_LOG_SIZE 256 769 770 /** 771 * struct dfs_event_log - DFS event log. 772 * @ts: 64-bit full timestamp from interrupt time. 773 * @diff_ts: Diff timestamp. 774 * @rssi: Rssi of radar event. 775 * @dur: Duration of radar pulse. 776 * @is_chirp: Chirp flag. 777 * @seg_id: HT80_80/HT160 use. 778 * @sidx: Seg index. 779 * @freq_offset_khz: Freq offset in KHz 780 * @peak_mag: Peak mag. 781 * @total_gain: Total gain. 782 * @mb_gain: Mb gain. 783 * @relpwr_db: Relpower in db. 784 * @delta_diff: Delta diff. 785 * @delta_peak: Delta peak. 786 */ 787 788 struct dfs_event_log { 789 uint64_t ts; 790 uint32_t diff_ts; 791 uint8_t rssi; 792 uint8_t dur; 793 int is_chirp; 794 uint8_t seg_id; 795 int sidx; 796 u_int freq_offset_khz; 797 int peak_mag; 798 int total_gain; 799 int mb_gain; 800 int relpwr_db; 801 uint8_t delta_diff; 802 int8_t delta_peak; 803 }; 804 805 #define WLAN_DFS_RESET_TIME_S 7 806 #define WLAN_DFS_WAIT (60 + WLAN_DFS_RESET_TIME_S) /* 60 seconds */ 807 #define WLAN_DFS_WAIT_MS ((WLAN_DFS_WAIT) * 1000) /*in MS*/ 808 809 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN 10 /*10 minutes*/ 810 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_S (WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN * 60) 811 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MS \ 812 ((WLAN_DFS_WEATHER_CHANNEL_WAIT_S) * 1000) /*in MS*/ 813 814 #define WLAN_DFS_WAIT_POLL_PERIOD 2 /* 2 seconds */ 815 #define WLAN_DFS_WAIT_POLL_PERIOD_MS \ 816 ((WLAN_DFS_WAIT_POLL_PERIOD) * 1000) /*in MS*/ 817 818 #define DFS_DEBUG_TIMEOUT_S 30 /* debug timeout is 30 seconds */ 819 #define DFS_DEBUG_TIMEOUT_MS (DFS_DEBUG_TIMEOUT_S * 1000) 820 821 #define RSSI_POSSIBLY_FALSE 50 822 #define SEARCH_FFT_REPORT_PEAK_MAG_THRSH 40 823 824 /** 825 * struct wlan_dfs - The main dfs structure. 826 * @dfs_debug_mask: Current debug bitmask. 827 * @dfs_curchan_radindex: Current channel radar index. 828 * @dfs_extchan_radindex: Extension channel radar index. 829 * @dfsdomain: Current DFS domain. 830 * @dfs_proc_phyerr: Flags for Phy Errs to process. 831 * @dfs_eventq: Q of free dfs event objects. 832 * @dfs_eventqlock: Lock for free dfs event list. 833 * @dfs_radarq: Q of radar events. 834 * @dfs_radarqlock: Lock for dfs q. 835 * @dfs_arq: Q of AR events. 836 * @dfs_arqlock: Lock for AR q. 837 * @dfs_ar_state: AR state. 838 * @dfs_radar[]: Per-Channel Radar detector state. 839 * @dfs_radarf[]: One filter for each radar pulse type. 840 * @dfs_rinfo: State vars for radar processing. 841 * @dfs_b5radars: Array of bin5 radar events. 842 * @dfs_ftindextable: Map of radar durs to filter types. 843 * @dfs_nol: Non occupancy list for radar. 844 * @dfs_nol_count: How many items? 845 * @dfs_defaultparams: Default phy params per radar state. 846 * @wlan_dfs_stats: DFS related stats. 847 * @pulses: Pulse history. 848 * @events: Events structure. 849 * @wlan_radar_tasksched: Radar task is scheduled. 850 * @wlan_dfswait: Waiting on channel for radar detect. 851 * @wlan_dfstest: Test timer in progress. 852 * @dfs_caps: Object of wlan_dfs_caps structure. 853 * @wlan_dfstest_ieeechan: IEEE chan num to return to after a dfs mute 854 * test. 855 * @wlan_dfs_cac_time: CAC period. 856 * @wlan_dfstesttime: Time to stay off chan during dfs test. 857 * @wlan_dfswaittimer: Dfs wait timer. 858 * @wlan_dfstesttimer: Dfs mute test timer. 859 * @wlan_dfs_debug_timer: Dfs debug timer. 860 * @dfs_second_segment_bangradar: Bangaradar on second segment of 861 * VHT80_80/160. 862 * @is_radar_found_on_secondary_seg: Radar on second segment. 863 * @is_radar_during_precac: Radar found during precac. 864 * @dfs_precac_lock: Lock to protect precac lists. 865 * @dfs_precac_enable: Enable the precac. 866 * @dfs_precac_secondary_freq: Second segment freq for precac. 867 * @dfs_precac_primary_freq: Primary freq. 868 * @dfs_precac_timer_running: Precac timer running. 869 * @dfs_defer_precac_channel_change: Defer precac channel change. 870 * @dfs_pre_cac_timeout_channel_change: Channel change due to precac timeout. 871 * @wlan_dfs_task_timer: Dfs wait timer. 872 * @dur_multiplier: Duration multiplier. 873 * @wlan_dfs_isdfsregdomain: True when AP is in DFS domain 874 * @wlan_dfs_false_rssi_thres: False RSSI Threshold. 875 * @wlan_dfs_peak_mag: Peak mag. 876 * @radar_log[]: Radar log. 877 * @dfs_event_log_count: Event log count. 878 * @dfs_event_log_on: Event log on. 879 * @dfs_phyerr_count: Same as number of PHY radar interrupts. 880 * @dfs_phyerr_reject_count: When TLV is supported, # of radar events 881 * ignored after TLV is parsed. 882 * @dfs_phyerr_queued_count: Number of radar events queued for matching 883 * the filters. 884 * @dfs_phyerr_freq_min: Phyerr min freq. 885 * @dfs_phyerr_freq_max: Phyerr max freq. 886 * @dfs_phyerr_w53_counter: Phyerr w53 counter. 887 * @dfs_pri_multiplier: Allow pulse if they are within multiple of 888 * PRI for the radar type. 889 * @wlan_dfs_nol_timeout: NOL timeout. 890 * @update_nol: Update NOL. 891 * @dfs_seq_num: Sequence number. 892 * @dfs_nol_event[]: NOL event. 893 * @dfs_nol_timer: NOL list processing. 894 * @dfs_nol_free_list: NOL free list. 895 * @dfs_nol_elem_free_work: The work queue to free an NOL element. 896 * @dfs_cac_timer: CAC timer. 897 * @dfs_cac_valid_timer: Ignore CAC when this timer is running. 898 * @dfs_cac_timeout_override: Overridden cac timeout. 899 * @dfs_enable: DFS Enable. 900 * @dfs_cac_timer_running: DFS CAC timer running. 901 * @dfs_ignore_dfs: Ignore DFS. 902 * @dfs_ignore_cac: Ignore CAC. 903 * @dfs_cac_valid: DFS CAC valid. 904 * @dfs_cac_valid_time: Time for which CAC will be valid and will 905 * not be re-done. 906 * @dfs_precac_timer: PRECAC timer. 907 * @dfs_precac_timeout_override: Overridden precac timeout. 908 * @dfs_num_precac_freqs: Number of PreCAC VHT80 frequencies. 909 * @dfs_precac_required_list: PreCAC required list. 910 * @dfs_precac_done_list: PreCAC done list. 911 * @dfs_precac_nol_list: PreCAC NOL List. 912 * @dfs_is_offload_enabled: Set if DFS offload enabled. 913 * @dfs_use_nol: Use the NOL when radar found(default: TRUE) 914 * @dfs_nol_lock: Lock to protect nol list. 915 * @tx_leakage_threshold: Tx leakage threshold for dfs. 916 * @dfs_use_nol_subchannel_marking: Use subchannel marking logic to add only 917 * radar affected subchannel instead of all 918 * bonding channels. 919 */ 920 struct wlan_dfs { 921 uint32_t dfs_debug_mask; 922 int16_t dfs_curchan_radindex; 923 int16_t dfs_extchan_radindex; 924 uint32_t dfsdomain; 925 uint32_t dfs_proc_phyerr; 926 927 STAILQ_HEAD(, dfs_event) dfs_eventq; 928 qdf_spinlock_t dfs_eventqlock; 929 930 STAILQ_HEAD(, dfs_event) dfs_radarq; 931 qdf_spinlock_t dfs_radarqlock; 932 933 STAILQ_HEAD(, dfs_event) dfs_arq; 934 qdf_spinlock_t dfs_arqlock; 935 936 struct dfs_ar_state dfs_ar_state; 937 struct dfs_state dfs_radar[DFS_NUM_RADAR_STATES]; 938 struct dfs_filtertype *dfs_radarf[DFS_MAX_RADAR_TYPES]; 939 struct dfs_info dfs_rinfo; 940 struct dfs_bin5radars *dfs_b5radars; 941 int8_t **dfs_ftindextable; 942 struct dfs_nolelem *dfs_nol; 943 int dfs_nol_count; 944 struct wlan_dfs_phyerr_param dfs_defaultparams; 945 struct dfs_stats wlan_dfs_stats; 946 struct dfs_pulseline *pulses; 947 struct dfs_event *events; 948 949 uint32_t wlan_radar_tasksched:1, 950 wlan_dfswait:1, 951 wlan_dfstest:1; 952 struct wlan_dfs_caps dfs_caps; 953 uint8_t wlan_dfstest_ieeechan; 954 uint32_t wlan_dfs_cac_time; 955 uint32_t wlan_dfstesttime; 956 os_timer_t wlan_dfswaittimer; 957 os_timer_t wlan_dfstesttimer; 958 os_timer_t wlan_dfs_debug_timer; 959 uint8_t dfs_bangradar; 960 bool dfs_second_segment_bangradar; 961 bool is_radar_found_on_secondary_seg; 962 bool is_radar_during_precac; 963 qdf_spinlock_t dfs_precac_lock; 964 bool dfs_precac_enable; 965 uint8_t dfs_precac_secondary_freq; 966 uint8_t dfs_precac_primary_freq; 967 uint8_t dfs_precac_timer_running; 968 uint8_t dfs_defer_precac_channel_change; 969 uint8_t dfs_pre_cac_timeout_channel_change:1; 970 os_timer_t wlan_dfs_task_timer; 971 int dur_multiplier; 972 uint16_t wlan_dfs_isdfsregdomain; 973 int wlan_dfs_false_rssi_thres; 974 int wlan_dfs_peak_mag; 975 struct dfs_event_log radar_log[DFS_EVENT_LOG_SIZE]; 976 int dfs_event_log_count; 977 int dfs_event_log_on; 978 int dfs_phyerr_count; 979 int dfs_phyerr_reject_count; 980 int dfs_phyerr_queued_count; 981 int dfs_phyerr_freq_min; 982 int dfs_phyerr_freq_max; 983 int dfs_phyerr_w53_counter; 984 int dfs_pri_multiplier; 985 int wlan_dfs_nol_timeout; 986 bool update_nol; 987 uint32_t dfs_seq_num; 988 int dfs_nol_event[DFS_CHAN_MAX]; 989 os_timer_t dfs_nol_timer; 990 991 TAILQ_HEAD(, dfs_nolelem) dfs_nol_free_list; 992 qdf_work_t dfs_nol_elem_free_work; 993 994 os_timer_t dfs_cac_timer; 995 os_timer_t dfs_cac_valid_timer; 996 int dfs_cac_timeout_override; 997 uint8_t dfs_enable:1, 998 dfs_cac_timer_running:1, 999 dfs_ignore_dfs:1, 1000 dfs_ignore_cac:1, 1001 dfs_cac_valid:1; 1002 uint32_t dfs_cac_valid_time; 1003 os_timer_t dfs_precac_timer; 1004 int dfs_precac_timeout_override; 1005 uint8_t dfs_num_precac_freqs; 1006 1007 TAILQ_HEAD(, dfs_precac_entry) dfs_precac_required_list; 1008 TAILQ_HEAD(, dfs_precac_entry) dfs_precac_done_list; 1009 TAILQ_HEAD(, dfs_precac_entry) dfs_precac_nol_list; 1010 1011 struct dfs_channel *dfs_curchan; 1012 struct wlan_objmgr_pdev *dfs_pdev_obj; 1013 bool dfs_is_offload_enabled; 1014 int dfs_use_nol; 1015 qdf_spinlock_t dfs_nol_lock; 1016 uint16_t tx_leakage_threshold; 1017 bool dfs_use_nol_subchannel_marking; 1018 }; 1019 1020 /** 1021 * struct dfs_soc_priv_obj - dfs private data 1022 * @psoc: pointer to PSOC object information 1023 * @pdev: pointer to PDEV object information 1024 * @dfs_is_phyerr_filter_offload: For some chip like Rome indicates too many 1025 * phyerr packets in a short time, which causes 1026 * OS hang. If this feild is configured as true, 1027 * FW will do the pre-check, filter out some 1028 * kinds of invalid phyerrors and indicate 1029 * radar detection related information to host. 1030 */ 1031 struct dfs_soc_priv_obj { 1032 struct wlan_objmgr_psoc *psoc; 1033 struct wlan_objmgr_pdev *pdev; 1034 bool dfs_is_phyerr_filter_offload; 1035 }; 1036 1037 /** 1038 * enum DFS debug - This should match the table from if_ath.c. 1039 * @WLAN_DEBUG_DFS: Minimal DFS debug. 1040 * @WLAN_DEBUG_DFS1: Normal DFS debug. 1041 * @WLAN_DEBUG_DFS2: Maximal DFS debug. 1042 * @WLAN_DEBUG_DFS3: Matched filterID display. 1043 * @WLAN_DEBUG_DFS_PHYERR: Phy error parsing. 1044 * @WLAN_DEBUG_DFS_NOL: NOL related entries. 1045 * @WLAN_DEBUG_DFS_PHYERR_SUM: PHY error summary. 1046 * @WLAN_DEBUG_DFS_PHYERR_PKT: PHY error payload. 1047 * @WLAN_DEBUG_DFS_BIN5: BIN5 checks. 1048 * @WLAN_DEBUG_DFS_BIN5_FFT: BIN5 FFT check. 1049 * @WLAN_DEBUG_DFS_BIN5_PULSE: BIN5 pulse check. 1050 * @WLAN_DEBUG_DFS_FALSE_DET: False detection debug related prints. 1051 * @WLAN_DEBUG_DFS_FALSE_DET2: Second level check to confirm poisitive 1052 * detection. 1053 * @WLAN_DEBUG_DFS_RANDOM_CHAN: Random channel selection. 1054 */ 1055 enum { 1056 WLAN_DEBUG_DFS = 0x00000100, 1057 WLAN_DEBUG_DFS1 = 0x00000200, 1058 WLAN_DEBUG_DFS2 = 0x00000400, 1059 WLAN_DEBUG_DFS3 = 0x00000800, 1060 WLAN_DEBUG_DFS_PHYERR = 0x00001000, 1061 WLAN_DEBUG_DFS_NOL = 0x00002000, 1062 WLAN_DEBUG_DFS_PHYERR_SUM = 0x00004000, 1063 WLAN_DEBUG_DFS_PHYERR_PKT = 0x00008000, 1064 WLAN_DEBUG_DFS_BIN5 = 0x00010000, 1065 WLAN_DEBUG_DFS_BIN5_FFT = 0x00020000, 1066 WLAN_DEBUG_DFS_BIN5_PULSE = 0x00040000, 1067 WLAN_DEBUG_DFS_FALSE_DET = 0x00080000, 1068 WLAN_DEBUG_DFS_FALSE_DET2 = 0x00100000, 1069 WLAN_DEBUG_DFS_RANDOM_CHAN = 0x00200000, 1070 WLAN_DEBUG_DFS_MAX = 0x80000000, 1071 WLAN_DEBUG_DFS_ALWAYS = WLAN_DEBUG_DFS_MAX 1072 }; 1073 1074 /** 1075 * struct dfs_phy_err - DFS phy error. 1076 * @fulltsf: 64-bit TSF as read from MAC. 1077 * @is_pri: Detected on primary channel. 1078 * @is_ext: Detected on extension channel. 1079 * @is_dc: Detected at DC. 1080 * @is_early: Early detect. 1081 * @do_check_chirp: Whether to check hw_chirp/sw_chirp. 1082 * @is_hw_chirp: Hardware-detected chirp. 1083 * @is_sw_chirp: Software detected chirp. 1084 * @rs_tstamp: 32 bit TSF from RX descriptor (event). 1085 * @freq: Centre frequency of event - KHz. 1086 * @freq_lo: Lower bounds of frequency - KHz. 1087 * @freq_hi: Upper bounds of frequency - KHz. 1088 * @rssi: Pulse RSSI. 1089 * @dur: Pulse duration, raw (not uS). 1090 * @seg_id: HT80_80/HT160 use. 1091 * @sidx: Seg index. 1092 * @freq_offset_khz: Freq offset in KHz. 1093 * @peak_mag: Peak mag. 1094 * @total_gain: Total gain. 1095 * @mb_gain: Mb gain. 1096 * @relpwr_db: Relpower in DB. 1097 * @pulse_delta_diff: Pulse delta diff. 1098 * @pulse_delta_peak: Pulse delta peak. 1099 * 1100 * Chirp notes! 1101 * 1102 * Pre-Sowl chips don't do FFT reports, so chirp pulses simply show up 1103 * as long duration pulses. 1104 * 1105 * The bin5 checking code would simply look for a chirp pulse of the correct 1106 * duration (within MIN_BIN5_DUR and MAX_BIN5_DUR) and add it to the "chirp" 1107 * pattern. 1108 * 1109 * For Sowl and later, an FFT was done on longer duration frames. If those 1110 * frames looked like a chirp, their duration was adjusted to fall within 1111 * the chirp duration limits. If the pulse failed the chirp test (it had 1112 * no FFT data or the FFT didn't meet the chirping requirements) then the 1113 * pulse duration was adjusted to be greater than MAX_BIN5_DUR, so it 1114 * would always fail chirp detection. 1115 * 1116 * This is pretty horrible. 1117 * 1118 * The eventual goal for chirp handling is thus: 1119 * 1120 * 1)In case someone ever wants to do chirp detection with this code on 1121 * chips that don't support chirp detection, you can still do it based 1122 * on pulse duration. That's your problem to solve. 1123 * 1124 * 2)For chips that do hardware chirp detection or FFT, the "do_check_chirp" 1125 * bit should be set. 1126 * 1127 * 3)Then, either is_hw_chirp or is_sw_chirp is set, indicating that 1128 * the hardware or software post-processing of the chirp event found 1129 * that indeed it was a chirp. 1130 * 1131 * 4)Finally, the bin5 code should just check whether the chirp bits are 1132 * set and behave appropriately, falling back onto the duration checks 1133 * if someone wishes to use this on older hardware (or with disabled 1134 * FFTs, for whatever reason.) 1135 * 1136 * XXX TODO: 1137 * 1138 * 1)add duration in uS and raw duration, so the PHY error parsing 1139 * code is responsible for doing the duration calculation; 1140 * 2)add ts in raw and corrected, so the PHY error parsing 1141 * code is responsible for doing the offsetting, not the radar 1142 * event code. 1143 */ 1144 struct dfs_phy_err { 1145 uint64_t fulltsf; 1146 uint32_t is_pri:1, 1147 is_ext:1, 1148 is_dc:1, 1149 is_early:1, 1150 do_check_chirp:1, 1151 is_hw_chirp:1, 1152 is_sw_chirp:1; 1153 uint32_t rs_tstamp; 1154 uint32_t freq; 1155 uint32_t freq_lo; 1156 uint32_t freq_hi; 1157 uint8_t rssi; 1158 uint8_t dur; 1159 uint8_t seg_id; 1160 int sidx; 1161 u_int freq_offset_khz; 1162 int peak_mag; 1163 int total_gain; 1164 int mb_gain; 1165 int relpwr_db; 1166 uint8_t pulse_delta_diff; 1167 int8_t pulse_delta_peak; 1168 }; 1169 1170 /** 1171 * struct rx_radar_status - Parsed radar status 1172 * @raw_tsf: Raw tsf 1173 * @tsf_offset: TSF offset. 1174 * @rssi: RSSI. 1175 * @pulse_duration: Pulse duration. 1176 * @is_chirp: Is chirp. 1177 * @delta_peak: Delta peak. 1178 * @delta_diff: Delta diff. 1179 * @sidx: Starting frequency. 1180 * @freq_offset: Frequency offset. 1181 * @agc_total_gain: AGC total gain. 1182 * @agc_mb_gain: AGC MB gain. 1183 */ 1184 struct rx_radar_status { 1185 uint32_t raw_tsf; 1186 uint32_t tsf_offset; 1187 int rssi; 1188 int pulse_duration; 1189 int is_chirp:1; 1190 int delta_peak; 1191 int delta_diff; 1192 int sidx; 1193 int freq_offset; /* in KHz */ 1194 int agc_total_gain; 1195 int agc_mb_gain; 1196 }; 1197 1198 /** 1199 * struct rx_search_fft_report - FFT report. 1200 * @total_gain_db: Total gain in Db. 1201 * @base_pwr_db: Base power in Db. 1202 * @fft_chn_idx: FFT channel index. 1203 * @peak_sidx: Peak sidx. 1204 * @relpwr_db: Real power in Db. 1205 * @avgpwr_db: Average power in Db. 1206 * @peak_mag: Peak Mag. 1207 * @num_str_bins_ib: Num dtr BINs IB 1208 * @seg_id: Segment ID 1209 */ 1210 struct rx_search_fft_report { 1211 uint32_t total_gain_db; 1212 uint32_t base_pwr_db; 1213 int fft_chn_idx; 1214 int peak_sidx; 1215 int relpwr_db; 1216 int avgpwr_db; 1217 int peak_mag; 1218 int num_str_bins_ib; 1219 int seg_id; 1220 }; 1221 1222 /** 1223 * dfs_process_radarevent() - process the radar event generated for a pulse. 1224 * @dfs: Pointer to wlan_dfs structure. 1225 * @chan: Current channel. 1226 * 1227 * There is currently no way to specify that a radar event has occurred on 1228 * a specific channel, so the current methodology is to mark both the pri 1229 * and ext channels as being unavailable. This should be fixed for 802.11ac 1230 * or we'll quickly run out of valid channels to use. 1231 * 1232 * If Radar found, this marks the channel (and the extension channel, if HT40) 1233 * as having seen a radar event. It marks CHAN_INTERFERENCE and will add it to 1234 * the local NOL implementation. This is only done for 'usenol=1', as the other 1235 * two modes don't do radar notification or CAC/CSA/NOL; it just notes there 1236 * was a radar. 1237 */ 1238 void dfs_process_radarevent(struct wlan_dfs *dfs, 1239 struct dfs_channel *chan); 1240 1241 /** 1242 * dfs_nol_addchan() - Add channel to NOL. 1243 * @dfs: Pointer to wlan_dfs structure. 1244 * @freq: frequency to add to NOL. 1245 * @dfs_nol_timeout: NOL timeout. 1246 */ 1247 void dfs_nol_addchan(struct wlan_dfs *dfs, 1248 uint16_t freq, 1249 uint32_t dfs_nol_timeout); 1250 1251 /** 1252 * dfs_get_nol() - Get NOL. 1253 * @dfs: Pointer to wlan_dfs structure. 1254 * @dfs_nol: Pointer to dfsreq_nolelem structure to save the channels from NOL. 1255 * @nchan: Number of channels. 1256 */ 1257 void dfs_get_nol(struct wlan_dfs *dfs, 1258 struct dfsreq_nolelem *dfs_nol, 1259 int *nchan); 1260 1261 /** 1262 * dfs_set_nol() - Set NOL. 1263 * @dfs: Pointer to wlan_dfs structure. 1264 * @dfs_nol: Pointer to dfsreq_nolelem structure. 1265 * @nchan: Number of channels. 1266 */ 1267 void dfs_set_nol(struct wlan_dfs *dfs, 1268 struct dfsreq_nolelem *dfs_nol, 1269 int nchan); 1270 1271 /** 1272 * dfs_nol_update() - NOL update 1273 * @dfs: Pointer to wlan_dfs structure. 1274 * 1275 * Notify the driver/umac that it should update the channel radar/NOL flags 1276 * based on the current NOL list. 1277 */ 1278 void dfs_nol_update(struct wlan_dfs *dfs); 1279 1280 /** 1281 * dfs_nol_timer_cleanup() - NOL timer cleanup. 1282 * @dfs: Pointer to wlan_dfs structure. 1283 * 1284 * Cancels the NOL timer and frees the NOL elements. 1285 */ 1286 void dfs_nol_timer_cleanup(struct wlan_dfs *dfs); 1287 1288 /** 1289 * dfs_nol_workqueue_cleanup() - Flushes NOL workqueue. 1290 * @dfs: Pointer to wlan_dfs structure. 1291 * 1292 * Flushes the NOL workqueue. 1293 */ 1294 void dfs_nol_workqueue_cleanup(struct wlan_dfs *dfs); 1295 1296 /** 1297 * dfs_retain_bin5_burst_pattern() - Retain the BIN5 burst pattern. 1298 * @dfs: Pointer to wlan_dfs structure. 1299 * @diff_ts: Timestamp diff. 1300 * @old_dur: Old duration. 1301 */ 1302 uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs, 1303 uint32_t diff_ts, 1304 uint8_t old_dur); 1305 1306 /** 1307 * dfs_bin5_check_pulse() - BIN5 check pulse. 1308 * @dfs: Pointer to wlan_dfs structure. 1309 * @re: Pointer to dfs_event structure. 1310 * @br: Pointer to dfs_bin5radars structure. 1311 * 1312 * Reject the pulse if: 1313 * 1) It's outside the RSSI threshold; 1314 * 2) It's outside the pulse duration; 1315 * 3) It's been verified by HW/SW chirp checking 1316 * and neither of those found a chirp. 1317 */ 1318 int dfs_bin5_check_pulse(struct wlan_dfs *dfs, 1319 struct dfs_event *re, 1320 struct dfs_bin5radars *br); 1321 1322 /** 1323 * dfs_bin5_addpulse() - BIN5 add pulse. 1324 * @dfs: Pointer to wlan_dfs structure. 1325 * @br: Pointer to dfs_bin5radars structure. 1326 * @re: Pointer to dfs_event structure. 1327 * @thists: Timestamp. 1328 */ 1329 int dfs_bin5_addpulse(struct wlan_dfs *dfs, 1330 struct dfs_bin5radars *br, 1331 struct dfs_event *re, 1332 uint64_t thists); 1333 1334 /** 1335 * dfs_bin5_check() - BIN5 check. 1336 * @dfs: Pointer to wlan_dfs structure. 1337 * 1338 * If the dfs structure is NULL (which should be illegal if everyting is working 1339 * properly, then signify that a bin5 radar was found. 1340 */ 1341 int dfs_bin5_check(struct wlan_dfs *dfs); 1342 1343 /** 1344 * dfs_check_chirping() - Check chirping. 1345 * @dfs: Pointer to wlan_dfs structure. 1346 * @buf: Phyerr buffer 1347 * @datalen: Phyerr buf length 1348 * @is_ctl: detected on primary channel. 1349 * @is_ext: detected on extension channel. 1350 * @slope: Slope 1351 * @is_dc: DC found 1352 * 1353 * This examines the FFT data contained in the PHY error information to figure 1354 * out whether the pulse is moving across frequencies. 1355 */ 1356 int dfs_check_chirping(struct wlan_dfs *dfs, 1357 void *buf, 1358 uint16_t datalen, 1359 int is_ctl, 1360 int is_ext, 1361 int *slope, 1362 int *is_dc); 1363 1364 /** 1365 * dfs_get_random_bin5_dur() - Get random BIN5 duration. 1366 * @dfs: Pointer to wlan_dfs structure. 1367 * @tstamp: Timestamp. 1368 * 1369 * Chirping pulses may get cut off at DC and report lower durations. 1370 * This function will compute a suitable random duration for each pulse. 1371 * Duration must be between 50 and 100 us, but remember that in 1372 * wlan_process_phyerr() which calls this function, we are dealing with the 1373 * HW reported duration (unconverted). dfs_process_radarevent() will 1374 * actually convert the duration into the correct value. 1375 * This function doesn't take into account whether the hardware 1376 * is operating in 5GHz fast clock mode or not. 1377 * And this function doesn't take into account whether the hardware 1378 * is peregrine or not. 1379 */ 1380 int dfs_get_random_bin5_dur(struct wlan_dfs *dfs, 1381 uint64_t tstamp); 1382 1383 /** 1384 * dfs_print_delayline() - Prints delayline. 1385 * @dfs: Pointer to wlan_dfs structure. 1386 * @dl: Pointer to dfs_delayline structure. 1387 */ 1388 void dfs_print_delayline(struct wlan_dfs *dfs, 1389 struct dfs_delayline *dl); 1390 1391 /** 1392 * dfs_print_nol() - Print NOL elements. 1393 * @dfs: Pointer to wlan_dfs structure. 1394 */ 1395 void dfs_print_nol(struct wlan_dfs *dfs); 1396 1397 /** 1398 * dfs_print_filter() - Prints the filter. 1399 * @dfs: Pointer to wlan_dfs structure. 1400 * @rf: Pointer to dfs_filter structure. 1401 */ 1402 void dfs_print_filter(struct wlan_dfs *dfs, 1403 struct dfs_filter *rf); 1404 1405 /** 1406 * dfs_getchanstate() - Get chan state. 1407 * @dfs: Pointer to wlan_dfs structure. 1408 * @index: To save the index of dfs_radar[] 1409 * @ext_chan_flag: Extension channel flag; 1410 */ 1411 struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, 1412 uint8_t *index, 1413 int ext_ch_flag); 1414 1415 /** 1416 * dfs_round() - DFS found. 1417 * @val: Convert durations to TSF ticks. 1418 * 1419 * Return: TSF ticks. 1420 */ 1421 uint32_t dfs_round(int32_t val); 1422 1423 /** 1424 * dfs_reset_alldelaylines() - Reset alldelaylines. 1425 * @dfs: Pointer to wlan_dfs structure. 1426 */ 1427 void dfs_reset_alldelaylines(struct wlan_dfs *dfs); 1428 1429 /** 1430 * dfs_reset_delayline() - Clear only a single delay line. 1431 * @dl: Pointer to dfs_delayline structure. 1432 */ 1433 void dfs_reset_delayline(struct dfs_delayline *dl); 1434 1435 /** 1436 * dfs_reset_filter_delaylines() - Reset filter delaylines. 1437 * @dft: Pointer to dfs_filtertype structure. 1438 */ 1439 void dfs_reset_filter_delaylines(struct dfs_filtertype *dft); 1440 1441 /** 1442 * dfs_reset_radarq() - Reset radar queue. 1443 * @dfs: Pointer to wlan_dfs structure. 1444 */ 1445 void dfs_reset_radarq(struct wlan_dfs *dfs); 1446 1447 /** 1448 * dfs_add_pulse() - Adds pulse to the queue. 1449 * @dfs: Pointer to wlan_dfs structure. 1450 * @rf: Pointer to dfs_filter structure. 1451 * @re: Pointer to dfs_event structure. 1452 * @deltaT: deltaT value. 1453 * @this_ts: Last time stamp. 1454 */ 1455 void dfs_add_pulse(struct wlan_dfs *dfs, 1456 struct dfs_filter *rf, 1457 struct dfs_event *re, 1458 uint32_t deltaT, 1459 uint64_t this_ts); 1460 1461 /** 1462 * dfs_bin_check() - BIN check 1463 * @dfs: Pointer to wlan_dfs structure. 1464 * @rf: Pointer to dfs_filter structure. 1465 * @deltaT: deltaT value. 1466 * @width: Width 1467 * @ext_chan_flag: Extension channel flag. 1468 */ 1469 int dfs_bin_check(struct wlan_dfs *dfs, 1470 struct dfs_filter *rf, 1471 uint32_t deltaT, 1472 uint32_t dur, 1473 int ext_chan_flag); 1474 1475 /** 1476 * dfs_bin_pri_check() - BIN PRI check 1477 * @dfs: Pointer to wlan_dfs structure. 1478 * @rf: Pointer to dfs_filter structure. 1479 * @dl: Pointer to dfs_delayline structure. 1480 * @score: Primary score. 1481 * @refpri: Current "filter" time for start of pulse in usecs. 1482 * @refdur: Duration value. 1483 * @ext_chan_flag: Extension channel flag. 1484 * @fundamentalpri: Highest PRI. 1485 */ 1486 int dfs_bin_pri_check(struct wlan_dfs *dfs, 1487 struct dfs_filter *rf, 1488 struct dfs_delayline *dl, 1489 uint32_t score, 1490 uint32_t refpri, 1491 uint32_t refdur, 1492 int ext_chan_flag, 1493 int fundamentalpri); 1494 1495 /** 1496 * dfs_staggered_check() - Detection implementation for staggered PRIs. 1497 * @dfs: Pointer to wlan_dfs structure. 1498 * @rf: Pointer to dfs_filter structure. 1499 * @deltaT: Delta of the Timestamp. 1500 * @width: Duration of radar pulse. 1501 * 1502 * Return: 1 on success and 0 on failure. 1503 */ 1504 int dfs_staggered_check(struct wlan_dfs *dfs, 1505 struct dfs_filter *rf, 1506 uint32_t deltaT, 1507 uint32_t width); 1508 1509 /** 1510 * dfs_get_pri_margin() - Get Primary margin. 1511 * @dfs: Pointer to wlan_dfs structure. 1512 * @is_extchan_detect: Extension channel detect. 1513 * @is_fixed_pattern: Fixed pattern. 1514 * 1515 * For the extension channel, if legacy traffic is present, we see a lot of 1516 * false alarms, so make the PRI margin narrower depending on the busy % for 1517 * the extension channel. 1518 * 1519 * Return: Returns pri_margin. 1520 */ 1521 int dfs_get_pri_margin(struct wlan_dfs *dfs, 1522 int is_extchan_detect, 1523 int is_fixed_pattern); 1524 1525 /** 1526 * dfs_get_filter_threshold() - Get filter threshold. 1527 * @dfs: Pointer to wlan_dfs structure. 1528 * @rf: Pointer to dfs_filter structure. 1529 * @is_extchan_detect: Extension channel detect. 1530 * 1531 * For the extension channel, if legacy traffic is present, we see a lot of 1532 * false alarms, so make the thresholds higher depending on the busy % for the 1533 * extension channel. 1534 * 1535 * Return: Returns threshold. 1536 */ 1537 int dfs_get_filter_threshold(struct wlan_dfs *dfs, 1538 struct dfs_filter *rf, 1539 int is_extchan_detect); 1540 1541 /** 1542 * dfs_process_ar_event() - Process the ar event. 1543 * @dfs: Pointer to wlan_dfs structure. 1544 * @chan: Current channel structure. 1545 */ 1546 void dfs_process_ar_event(struct wlan_dfs *dfs, 1547 struct dfs_channel *chan); 1548 1549 /** 1550 * dfs_reset_ar() - resets the ar state. 1551 * @dfs: pointer to wlan_dfs structure. 1552 */ 1553 void dfs_reset_ar(struct wlan_dfs *dfs); 1554 1555 /** 1556 * dfs_reset_arq() - resets the ar queue. 1557 * @dfs: pointer to wlan_dfs structure. 1558 */ 1559 void dfs_reset_arq(struct wlan_dfs *dfs); 1560 1561 /** 1562 * dfs_process_phyerr_bb_tlv() - Parses the PHY error and populates the 1563 * dfs_phy_err struct. 1564 * @dfs: Pointer to wlan_dfs structure. 1565 * @buf: Phyerr buffer 1566 * @datalen: Phyerr buf len 1567 * @rssi: RSSI 1568 * @ext_rssi: Extension RSSI. 1569 * @rs_tstamp: Time stamp. 1570 * @fulltsf: TSF64. 1571 * @e: Pointer to dfs_phy_err structure. 1572 * 1573 * Return: Returns 1. 1574 */ 1575 int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs, 1576 void *buf, 1577 uint16_t datalen, 1578 uint8_t rssi, 1579 uint8_t ext_rssi, 1580 uint32_t rs_tstamp, 1581 uint64_t fulltsf, 1582 struct dfs_phy_err *e); 1583 1584 /** 1585 * dfs_reset() - DFS reset 1586 * @dfs: Pointer to wlan_dfs structure. 1587 */ 1588 void dfs_reset(struct wlan_dfs *dfs); 1589 1590 /** 1591 * dfs_radar_enable() - Enables the radar. 1592 * @dfs: Pointer to wlan_dfs structure. 1593 * @no_cac: If no_cac is 0, it cancels the CAC. 1594 */ 1595 void dfs_radar_enable(struct wlan_dfs *dfs, 1596 int no_cac, uint32_t opmode); 1597 1598 /** 1599 * dfs_process_phyerr() - Process phyerr. 1600 * @dfs: Pointer to wlan_dfs structure. 1601 * @buf: Phyerr buffer. 1602 * @datalen: phyerr buffer length. 1603 * @r_rssi: RSSI. 1604 * @r_ext_rssi: Extension channel RSSI. 1605 * @r_rs_tstamp: Timestamp. 1606 * @r_fulltsf: TSF64. 1607 */ 1608 void dfs_process_phyerr(struct wlan_dfs *dfs, 1609 void *buf, 1610 uint16_t datalen, 1611 uint8_t r_rssi, 1612 uint8_t r_ext_rssi, 1613 uint32_t r_rs_tstamp, 1614 uint64_t r_fulltsf); 1615 1616 #ifdef QCA_MCL_DFS_SUPPORT 1617 /** 1618 * dfs_process_phyerr_filter_offload() - Process radar event. 1619 * @dfs: Pointer to wlan_dfs structure. 1620 * @wlan_radar_event: Pointer to radar_event_info structure. 1621 * 1622 * Return: None 1623 */ 1624 void dfs_process_phyerr_filter_offload(struct wlan_dfs *dfs, 1625 struct radar_event_info *wlan_radar_event); 1626 #endif 1627 1628 /** 1629 * dfs_is_precac_timer_running() - Check whether precac timer is running. 1630 * @dfs: Pointer to wlan_dfs structure. 1631 */ 1632 bool dfs_is_precac_timer_running(struct wlan_dfs *dfs); 1633 1634 /** 1635 * dfs_get_radars() - Based on the chipset, calls init radar table functions. 1636 * @dfs: Pointer to wlan_dfs structure. 1637 */ 1638 void dfs_get_radars(struct wlan_dfs *dfs); 1639 1640 /** 1641 * dfs_attach() - Wrapper function to allocate memory for wlan_dfs members. 1642 * @dfs: Pointer to wlan_dfs structure. 1643 */ 1644 int dfs_attach(struct wlan_dfs *dfs); 1645 1646 /** 1647 * dfs_main_attach() - Allocates memory for wlan_dfs members. 1648 * @dfs: Pointer to wlan_dfs structure. 1649 */ 1650 int dfs_main_attach(struct wlan_dfs *dfs); 1651 1652 /** 1653 * dfs_create_object() - Creates DFS object. 1654 * @dfs: Pointer to wlan_dfs structure. 1655 */ 1656 int dfs_create_object(struct wlan_dfs **dfs); 1657 1658 /** 1659 * dfs_destroy_object() - Destroys the DFS object. 1660 * @dfs: Pointer to wlan_dfs structure. 1661 */ 1662 void dfs_destroy_object(struct wlan_dfs *dfs); 1663 1664 /** 1665 * dfs_detach() - Wrapper function to free dfs variables. 1666 * @dfs: Pointer to wlan_dfs structure. 1667 */ 1668 void dfs_detach(struct wlan_dfs *dfs); 1669 1670 /** 1671 * dfs_main_detach() - Free dfs variables. 1672 * @dfs: Pointer to wlan_dfs structure. 1673 */ 1674 void dfs_main_detach(struct wlan_dfs *dfs); 1675 1676 /** 1677 * dfs_cac_valid_reset() - Cancels the dfs_cac_valid_timer timer. 1678 * @dfs: Pointer to wlan_dfs structure. 1679 * @prevchan_ieee: Prevchan number. 1680 * @prevchan_flags: Prevchan flags. 1681 */ 1682 void dfs_cac_valid_reset(struct wlan_dfs *dfs, 1683 uint8_t prevchan_ieee, 1684 uint32_t prevchan_flags); 1685 1686 /** 1687 * dfs_cac_stop() - Clear the AP CAC timer. 1688 * @dfs: Pointer to wlan_dfs structure. 1689 */ 1690 void dfs_cac_stop(struct wlan_dfs *dfs); 1691 1692 /** 1693 * dfs_cancel_cac_timer() - Cancels the CAC timer. 1694 * @dfs: Pointer to wlan_dfs structure. 1695 */ 1696 void dfs_cancel_cac_timer(struct wlan_dfs *dfs); 1697 1698 /** 1699 * dfs_start_cac_timer() - Starts the CAC timer. 1700 * @dfs: Pointer to wlan_dfs structure. 1701 */ 1702 void dfs_start_cac_timer(struct wlan_dfs *dfs); 1703 1704 /** 1705 * dfs_set_update_nol_flag() - Sets update_nol flag. 1706 * @dfs: Pointer to wlan_dfs structure. 1707 * @val: update_nol flag. 1708 */ 1709 void dfs_set_update_nol_flag(struct wlan_dfs *dfs, 1710 bool val); 1711 1712 /** 1713 * dfs_get_update_nol_flag() - Returns update_nol flag. 1714 * @dfs: Pointer to wlan_dfs structure. 1715 */ 1716 bool dfs_get_update_nol_flag(struct wlan_dfs *dfs); 1717 1718 /** 1719 * dfs_get_use_nol() - Get usenol. 1720 * @dfs: Pointer to wlan_dfs structure. 1721 */ 1722 int dfs_get_use_nol(struct wlan_dfs *dfs); 1723 1724 /** 1725 * dfs_get_nol_timeout() - Get NOL timeout. 1726 * @dfs: Pointer to wlan_dfs structure. 1727 */ 1728 int dfs_get_nol_timeout(struct wlan_dfs *dfs); 1729 1730 /** 1731 * dfs_is_ap_cac_timer_running() - Returns the dfs cac timer. 1732 * @dfs: Pointer to wlan_dfs structure. 1733 */ 1734 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs); 1735 1736 /** 1737 * dfs_control()- Used to process ioctls related to DFS. 1738 * @dfs: Pointer to wlan_dfs structure. 1739 * @id: Command type. 1740 * @indata: Input buffer. 1741 * @insize: size of the input buffer. 1742 * @outdata: A buffer for the results. 1743 * @outsize: Size of the output buffer. 1744 */ 1745 int dfs_control(struct wlan_dfs *dfs, 1746 u_int id, 1747 void *indata, 1748 uint32_t insize, 1749 void *outdata, 1750 uint32_t *outsize); 1751 1752 /** 1753 * dfs_getnol() - Wrapper function for dfs_get_nol() 1754 * @dfs: Pointer to wlan_dfs structure. 1755 * @dfs_nolinfo: Pointer to dfsreq_nolinfo structure. 1756 */ 1757 void dfs_getnol(struct wlan_dfs *dfs, 1758 void *dfs_nolinfo); 1759 1760 /** 1761 * dfs_get_override_cac_timeout() - Get override CAC timeout value. 1762 * @dfs: Pointer to DFS object. 1763 * @cac_timeout: Pointer to save the CAC timeout value. 1764 */ 1765 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, 1766 int *cac_timeout); 1767 1768 /** 1769 * dfs_override_cac_timeout() - Override the default CAC timeout. 1770 * @dfs: Pointer to DFS object. 1771 * @cac_timeout: CAC timeout value. 1772 */ 1773 int dfs_override_cac_timeout(struct wlan_dfs *dfs, 1774 int cac_timeout); 1775 1776 /** 1777 * dfs_clear_nolhistory() - unmarks WLAN_CHAN_CLR_HISTORY_RADAR flag for 1778 * all the channels in dfs_ch_channels. 1779 * @dfs: Pointer to wlan_dfs structure. 1780 */ 1781 void dfs_clear_nolhistory(struct wlan_dfs *dfs); 1782 1783 /** 1784 * ol_if_dfs_configure() - Initialize the RADAR table for offload chipsets. 1785 * @dfs: Pointer to wlan_dfs structure. 1786 * 1787 * This is called during a channel change or regulatory domain 1788 * reset; in order to fetch the new configuration information and 1789 * program the DFS pattern matching module. 1790 * 1791 * Eventually this should be split into "fetch config" (which can 1792 * happen at regdomain selection time) and "configure DFS" (which 1793 * can happen at channel config time) so as to minimise overheads 1794 * when doing channel changes. However, this'll do for now. 1795 */ 1796 void ol_if_dfs_configure(struct wlan_dfs *dfs); 1797 1798 /** 1799 * dfs_init_radar_filters() - Init Radar filters. 1800 * @dfs: Pointer to wlan_dfs structure. 1801 * @radar_info: Pointer to wlan_dfs_radar_tab_info structure. 1802 */ 1803 int dfs_init_radar_filters(struct wlan_dfs *dfs, 1804 struct wlan_dfs_radar_tab_info *radar_info); 1805 1806 /** 1807 * dfs_get_radars_for_ar5212() - Initialize radar table for AR5212 chipsets. 1808 * @dfs: Pointer to wlan_dfs structure. 1809 */ 1810 void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs); 1811 1812 /** 1813 * dfs_get_radars_for_ar5416() - Initialize radar table for AR5416 chipsets. 1814 * @dfs: Pointer to wlan_dfs structure. 1815 */ 1816 void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs); 1817 1818 /** 1819 * dfs_get_radars_for_ar9300() - Initialize radar table for AR9300 chipsets. 1820 * @dfs: Pointer to wlan_dfs structure. 1821 */ 1822 void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs); 1823 1824 /** 1825 * dfs_print_filters() - Print the filters. 1826 * @dfs: Pointer to wlan_dfs structure. 1827 */ 1828 void dfs_print_filters(struct wlan_dfs *dfs); 1829 1830 /** 1831 * dfs_clear_stats() - Clear stats. 1832 * @dfs: Pointer to wlan_dfs structure. 1833 */ 1834 void dfs_clear_stats(struct wlan_dfs *dfs); 1835 1836 /** 1837 * dfs_radar_disable() - Disables the radar. 1838 * @dfs: Pointer to wlan_dfs structure. 1839 */ 1840 int dfs_radar_disable(struct wlan_dfs *dfs); 1841 1842 /** 1843 * dfs_mark_precac_dfs() - Mark the precac channel as radar. 1844 * @dfs: Pointer to wlan_dfs structure. 1845 */ 1846 void dfs_mark_precac_dfs(struct wlan_dfs *dfs, 1847 uint8_t is_radar_found_on_secondary_seg); 1848 1849 /** 1850 * dfs_get_debug_info() - Get debug info. 1851 * @dfs: Pointer to wlan_dfs structure. 1852 * @data: void pointer to the data to save dfs_proc_phyerr. 1853 */ 1854 int dfs_get_debug_info(struct wlan_dfs *dfs, 1855 void *data); 1856 1857 /** 1858 * dfs_cac_timer_init() - Initialize cac timers. 1859 * @dfs: Pointer to wlan_dfs structure. 1860 */ 1861 void dfs_cac_timer_init(struct wlan_dfs *dfs); 1862 1863 /** 1864 * dfs_cac_attach() - Initialize dfs cac variables. 1865 * @dfs: Pointer to wlan_dfs structure. 1866 */ 1867 void dfs_cac_attach(struct wlan_dfs *dfs); 1868 1869 /** 1870 * dfs_cac_timer_reset() - Cancel dfs cac timers. 1871 * @dfs: Pointer to wlan_dfs structure. 1872 */ 1873 void dfs_cac_timer_reset(struct wlan_dfs *dfs); 1874 1875 /** 1876 * dfs_nol_timer_init() - Initialize NOL timers. 1877 * @dfs: Pointer to wlan_dfs structure. 1878 */ 1879 void dfs_nol_timer_init(struct wlan_dfs *dfs); 1880 1881 /** 1882 * dfs_nol_attach() - Initialize NOL variables. 1883 * @dfs: Pointer to wlan_dfs structure. 1884 */ 1885 void dfs_nol_attach(struct wlan_dfs *dfs); 1886 1887 /** 1888 * dfs_nol_detach() - Detach NOL variables. 1889 * @dfs: Pointer to wlan_dfs structure. 1890 */ 1891 void dfs_nol_detach(struct wlan_dfs *dfs); 1892 1893 /** 1894 * dfs_print_nolhistory() - Print NOL history. 1895 * @dfs: Pointer to wlan_dfs structure. 1896 */ 1897 void dfs_print_nolhistory(struct wlan_dfs *dfs); 1898 1899 /** 1900 * dfs_stacac_stop() - Clear the STA CAC timer. 1901 * @dfs: Pointer to wlan_dfs structure. 1902 */ 1903 void dfs_stacac_stop(struct wlan_dfs *dfs); 1904 1905 /** 1906 * dfs_find_precac_secondary_vht80_chan() - Get a VHT80 channel with the 1907 * precac primary center frequency. 1908 * @dfs: Pointer to wlan_dfs structure. 1909 * @chan: Pointer to dfs channel structure. 1910 */ 1911 void dfs_find_precac_secondary_vht80_chan(struct wlan_dfs *dfs, 1912 struct dfs_channel *chan); 1913 1914 /** 1915 * dfs_phyerr_param_copy() - Function to copy src buf to dest buf. 1916 * @dst: dest buf. 1917 * @src: src buf. 1918 */ 1919 void dfs_phyerr_param_copy(struct wlan_dfs_phyerr_param *dst, 1920 struct wlan_dfs_phyerr_param *src); 1921 1922 /** 1923 * dfs_get_thresholds() - Get the threshold value. 1924 * @dfs: Pointer to wlan_dfs structure. 1925 * @param: Pointer to wlan_dfs_phyerr_param structure. 1926 */ 1927 int dfs_get_thresholds(struct wlan_dfs *dfs, 1928 struct wlan_dfs_phyerr_param *param); 1929 1930 /** 1931 * dfs_set_thresholds() - Sets the threshold value. 1932 * @dfs: Pointer to wlan_dfs structure. 1933 * @threshtype: DFS ioctl param type. 1934 * @value: Threshold value. 1935 */ 1936 int dfs_set_thresholds(struct wlan_dfs *dfs, 1937 const uint32_t threshtype, 1938 const uint32_t value); 1939 1940 /** 1941 * dfs_set_current_channel() - Set DFS current channel. 1942 * @dfs: Pointer to wlan_dfs structure. 1943 * @dfs_ch_freq: Frequency in Mhz. 1944 * @dfs_ch_flags: Channel flags. 1945 * @dfs_ch_flagext: Extended channel flags. 1946 * @dfs_ch_ieee: IEEE channel number. 1947 * @dfs_ch_vhtop_ch_freq_seg1: Channel Center frequency1. 1948 * @dfs_ch_vhtop_ch_freq_seg2: Channel Center frequency2. 1949 */ 1950 void dfs_set_current_channel(struct wlan_dfs *dfs, 1951 uint16_t dfs_ch_freq, 1952 uint64_t dfs_ch_flags, 1953 uint16_t dfs_ch_flagext, 1954 uint8_t dfs_ch_ieee, 1955 uint8_t dfs_ch_vhtop_ch_freq_seg1, 1956 uint8_t dfs_ch_vhtop_ch_freq_seg2); 1957 1958 /** 1959 * dfs_second_segment_radar_disable() - Disables the second segment radar. 1960 * @dfs: Pointer to wlan_dfs structure. 1961 * 1962 * This is called when AP detects the radar, to (potentially) disable 1963 * the radar code. 1964 * 1965 * Return: returns 0. 1966 */ 1967 int dfs_second_segment_radar_disable(struct wlan_dfs *dfs); 1968 1969 /** 1970 * dfs_get_nol_chfreq_and_chwidth() - Get channel freq and width from NOL list. 1971 * @dfs_nol: Pointer to NOL channel entry. 1972 * @nol_chfreq: Pointer to save channel frequency. 1973 * @nol_chwidth: Pointer to save channel width. 1974 * @index: Index to dfs_nol list. 1975 */ 1976 void dfs_get_nol_chfreq_and_chwidth(struct dfsreq_nolelem *dfs_nol, 1977 uint32_t *nol_chfreq, 1978 uint32_t *nol_chwidth, 1979 int index); 1980 1981 /** 1982 * dfs_process_phyerr_owl() - Process an Owl-style phy error. 1983 * @dfs: Pointer to wlan_dfs structure. 1984 * @buf: Phyerr buffer 1985 * @datalen: Phyerr buf len 1986 * @rssi: RSSI 1987 * @ext_rssi: Extension RSSI. 1988 * @rs_tstamp: Time stamp. 1989 * @fulltsf: TSF64. 1990 * @e: Pointer to dfs_phy_err structure. 1991 * 1992 * Return: Returns 1. 1993 */ 1994 int dfs_process_phyerr_owl(struct wlan_dfs *dfs, 1995 void *buf, 1996 uint16_t datalen, 1997 uint8_t rssi, 1998 uint8_t ext_rssi, 1999 uint32_t rs_tstamp, 2000 uint64_t fulltsf, 2001 struct dfs_phy_err *e); 2002 2003 /** 2004 * dfs_process_phyerr_sowl() -Process a Sowl/Howl style phy error. 2005 * @dfs: Pointer to wlan_dfs structure. 2006 * @buf: Phyerr buffer 2007 * @datalen: Phyerr buf len 2008 * @rssi: RSSI 2009 * @ext_rssi: Extension RSSI. 2010 * @rs_tstamp: Time stamp. 2011 * @fulltsf: TSF64. 2012 * @e: Pointer to dfs_phy_err structure. 2013 * 2014 * Return: Returns 1. 2015 */ 2016 int dfs_process_phyerr_sowl(struct wlan_dfs *dfs, 2017 void *buf, 2018 uint16_t datalen, 2019 uint8_t rssi, 2020 uint8_t ext_rssi, 2021 uint32_t rs_tstamp, 2022 uint64_t fulltsf, 2023 struct dfs_phy_err *e); 2024 2025 /** 2026 * dfs_process_phyerr_merlin() - Process a Merlin/Osprey style phy error. 2027 * dfs_phy_err struct. 2028 * @dfs: Pointer to wlan_dfs structure. 2029 * @buf: Phyerr buffer 2030 * @datalen: Phyerr buf len 2031 * @rssi: RSSI 2032 * @ext_rssi: Extension RSSI. 2033 * @rs_tstamp: Time stamp. 2034 * @fulltsf: TSF64. 2035 * @e: Pointer to dfs_phy_err structure. 2036 * 2037 * Return: Returns 1. 2038 */ 2039 int dfs_process_phyerr_merlin(struct wlan_dfs *dfs, 2040 void *buf, 2041 uint16_t datalen, 2042 uint8_t rssi, 2043 uint8_t ext_rssi, 2044 uint32_t rs_tstamp, 2045 uint64_t fulltsf, 2046 struct dfs_phy_err *e); 2047 2048 /* 2049 * __dfs_process_radarevent() - Continuation of process a radar event function. 2050 * @dfs: Pointer to wlan_dfs structure. 2051 * @ft: Pointer to dfs_filtertype structure. 2052 * @re: Pointer to dfs_event structure. 2053 * @this_ts: Timestamp. 2054 * 2055 * There is currently no way to specify that a radar event has occurred on 2056 * a specific channel, so the current methodology is to mark both the pri 2057 * and ext channels as being unavailable. This should be fixed for 802.11ac 2058 * or we'll quickly run out of valid channels to use. 2059 * 2060 * Return: If a radar event is found, return 1. Otherwise, return 0. 2061 */ 2062 void __dfs_process_radarevent(struct wlan_dfs *dfs, 2063 struct dfs_filtertype *ft, 2064 struct dfs_event *re, 2065 uint64_t this_ts, 2066 int *found, 2067 int *false_radar_found); 2068 2069 /** 2070 * bin5_rules_check_internal() - This is a extension of dfs_bin5_check(). 2071 * @dfs: Pointer to wlan_dfs structure. 2072 * @br: Pointer to dfs_bin5radars structure. 2073 * @bursts: Bursts. 2074 * @numevents: Number of events. 2075 * @prev: prev index. 2076 * @i: Index. 2077 * @this: index to br_elems[] 2078 */ 2079 void bin5_rules_check_internal(struct wlan_dfs *dfs, 2080 struct dfs_bin5radars *br, 2081 uint32_t *bursts, 2082 uint32_t *numevents, 2083 uint32_t prev, 2084 uint32_t i, 2085 uint32_t this, 2086 int *index); 2087 2088 /** 2089 * dfs_main_task_timer_init() - Initialize dfs task timer. 2090 * @dfs: Pointer to wlan_dfs structure. 2091 */ 2092 void dfs_main_task_timer_init(struct wlan_dfs *dfs); 2093 2094 /** 2095 * dfs_main_task_testtimer_init() - Initialize dfs task testtimer. 2096 * @dfs: Pointer to wlan_dfs structure. 2097 */ 2098 void dfs_main_task_testtimer_init(struct wlan_dfs *dfs); 2099 2100 /** 2101 * dfs_main_timer_reset() - Stop dfs timers. 2102 * @dfs: Pointer to wlan_dfs structure. 2103 */ 2104 void dfs_main_timer_reset(struct wlan_dfs *dfs); 2105 2106 /** 2107 * dfs_stop() - Clear dfs timers. 2108 * @dfs: Pointer to wlan_dfs structure. 2109 */ 2110 void dfs_stop(struct wlan_dfs *dfs); 2111 2112 /** 2113 * dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 2114 * @dfs: Pointer to wlan_dfs structure. 2115 * @flags: New channel flags 2116 * @flagext: New Extended flags 2117 */ 2118 void dfs_update_cur_chan_flags(struct wlan_dfs *dfs, 2119 uint64_t flags, 2120 uint16_t flagext); 2121 2122 /** 2123 * dfs_send_csa_to_current_chan() - Send CSA to current channel 2124 * @dfs: Pointer to wlan_dfs structure. 2125 * 2126 * For the test mode(usenol = 0), don't do a CSA; but setup the test timer so 2127 * we get a CSA _back_ to the current operating channel. 2128 */ 2129 void dfs_send_csa_to_current_chan(struct wlan_dfs *dfs); 2130 2131 /** 2132 * dfs_radarevent_basic_sanity() - Check basic sanity of the radar event 2133 * @dfs: Pointer to wlan_dfs structure. 2134 * @chan: Current channel. 2135 * 2136 * Return: If a radar event found on NON-DFS channel return 0. Otherwise, 2137 * return 1. 2138 */ 2139 int dfs_radarevent_basic_sanity(struct wlan_dfs *dfs, 2140 struct dfs_channel *chan); 2141 2142 /** 2143 * wlan_psoc_get_dfs_txops() - Get dfs_tx_ops pointer 2144 * @psoc: Pointer to psoc structure. 2145 * 2146 * Return: Pointer to dfs_tx_ops. 2147 */ 2148 struct wlan_lmac_if_dfs_tx_ops * 2149 wlan_psoc_get_dfs_txops(struct wlan_objmgr_psoc *psoc); 2150 2151 /** 2152 * dfs_nol_free_list() - Free NOL elements. 2153 * @dfs: Pointer to wlan_dfs structure. 2154 */ 2155 void dfs_nol_free_list(struct wlan_dfs *dfs); 2156 2157 /** 2158 * dfs_set_phyerr_filter_offload - config phyerr filter offload. 2159 * @dfs: Pointer to wlan_dfs structure. 2160 * 2161 * Return: None 2162 */ 2163 void dfs_set_phyerr_filter_offload(struct wlan_dfs *dfs); 2164 #endif /* _DFS_H_ */ 2165