1 /* 2 * Copyright (c) 2011, 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 * Copyright (c) 2010, Atheros Communications Inc. 5 * All Rights Reserved. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /** 23 * DOC: This file has dfs IOCTL Defines. 24 */ 25 26 #ifndef _DFS_IOCTL_H_ 27 #define _DFS_IOCTL_H_ 28 29 #define DFS_MUTE_TIME 1 30 #define DFS_SET_THRESH 2 31 #define DFS_GET_THRESH 3 32 #define DFS_GET_USENOL 4 33 #define DFS_SET_USENOL 5 34 #define DFS_RADARDETECTS 6 35 #define DFS_BANGRADAR 7 36 #define DFS_SHOW_NOL 8 37 #define DFS_DISABLE_DETECT 9 38 #define DFS_ENABLE_DETECT 10 39 #define DFS_DISABLE_FFT 11 40 #define DFS_ENABLE_FFT 12 41 #define DFS_SET_DEBUG_LEVEL 13 42 #define DFS_GET_NOL 14 43 #define DFS_SET_NOL 15 44 45 #define DFS_SET_FALSE_RSSI_THRES 16 46 #define DFS_SET_PEAK_MAG 17 47 #define DFS_IGNORE_CAC 18 48 #define DFS_SET_NOL_TIMEOUT 19 49 #define DFS_GET_CAC_VALID_TIME 20 50 #define DFS_SET_CAC_VALID_TIME 21 51 #define DFS_SHOW_NOLHISTORY 22 52 #define DFS_SHOW_PRECAC_LISTS 23 53 #define DFS_RESET_PRECAC_LISTS 24 54 #define DFS_SET_DISABLE_RADAR_MARKING 25 55 #define DFS_GET_DISABLE_RADAR_MARKING 26 56 57 #define DFS_INJECT_SEQUENCE 27 58 #define DFS_ALLOW_HW_PULSES 28 59 #define DFS_SET_PRI_MULTIPILER 29 60 61 #define RESTRICTED_80P80_START_FREQ 5660 62 #define RESTRICTED_80P80_END_FREQ 5805 63 64 /* Check if the given frequencies are within restricted 80P80 start freq(5660) 65 * and end freq (5805). 66 */ 67 #define CHAN_WITHIN_RESTRICTED_80P80(cfreq1, cfreq2) \ 68 ((((cfreq1) >= RESTRICTED_80P80_START_FREQ) && \ 69 ((cfreq1) <= RESTRICTED_80P80_END_FREQ) && \ 70 ((cfreq2) >= RESTRICTED_80P80_START_FREQ) && \ 71 ((cfreq2) <= RESTRICTED_80P80_END_FREQ)) ? true : false) 72 73 /* 74 * Spectral IOCTLs use DFS_LAST_IOCTL as the base. 75 * This must always be the last IOCTL in DFS and have 76 * the highest value. 77 */ 78 #define DFS_LAST_IOCTL 29 79 80 #ifndef DFS_CHAN_MAX 81 #define DFS_CHAN_MAX 25 82 #endif 83 84 /** 85 * struct dfsreq_nolelem - NOL elements. 86 * @nol_freq: NOL channel frequency. 87 * @nol_chwidth: NOL channel width. 88 * @nol_start_us: OS microseconds when the NOL timer started. 89 * @nol_timeout_ms: Nol timeout value in msec. 90 */ 91 92 struct dfsreq_nolelem { 93 uint16_t nol_freq; 94 uint16_t nol_chwidth; 95 uint64_t nol_start_us; 96 uint32_t nol_timeout_ms; 97 }; 98 99 struct dfsreq_nolinfo { 100 uint32_t dfs_ch_nchans; 101 struct dfsreq_nolelem dfs_nol[DFS_CHAN_MAX]; 102 }; 103 104 /* 105 * IOCTL parameter types 106 */ 107 108 #define DFS_PARAM_FIRPWR 1 109 #define DFS_PARAM_RRSSI 2 110 #define DFS_PARAM_HEIGHT 3 111 #define DFS_PARAM_PRSSI 4 112 #define DFS_PARAM_INBAND 5 113 /* 5413 specific parameters */ 114 #define DFS_PARAM_RELPWR 7 115 #define DFS_PARAM_RELSTEP 8 116 #define DFS_PARAM_MAXLEN 9 117 118 /** 119 * struct dfs_ioctl_params - DFS ioctl params. 120 * @dfs_firpwr: FIR pwr out threshold. 121 * @dfs_rrssi: Radar rssi thresh. 122 * @dfs_height: Pulse height thresh. 123 * @dfs_prssi: Pulse rssi thresh. 124 * @dfs_inband: Inband thresh. 125 * @dfs_relpwr: Pulse relative pwr thresh. 126 * @dfs_relstep: Pulse relative step thresh. 127 * @dfs_maxlen: Pulse max duration. 128 */ 129 struct dfs_ioctl_params { 130 int32_t dfs_firpwr; 131 int32_t dfs_rrssi; 132 int32_t dfs_height; 133 int32_t dfs_prssi; 134 int32_t dfs_inband; 135 int32_t dfs_relpwr; 136 int32_t dfs_relstep; 137 int32_t dfs_maxlen; 138 }; 139 140 /* Types of Bangradar commands: 141 * @DFS_BANGRADAR_FOR_ALL_SUBCHANS : Bangradar with no arguments. 142 * All the subchannels in the current 143 * channel shall be added. 144 * @DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID : Bangradar with 1 (seg_id) argument 145 * All subchannels of the specific 146 * seg_id shall be added. 147 * @DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS : Bangradar with all (segment ID, 148 * is_chirp and frequency offset) 149 * arguments. 150 * Only radar infected subchannels 151 * of the specific seg_id shall be 152 * added. 153 * 154 * (Unless all arguments are given, we cannot determine which specific 155 * subchannels to simulate the radar on, hence simulate in all subchans). 156 */ 157 enum dfs_bangradar_types { 158 DFS_NO_BANGRADAR = 0, 159 DFS_BANGRADAR_FOR_ALL_SUBCHANS, 160 DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID, 161 DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS, 162 DFS_INVALID_BANGRADAR_TYPE 163 }; 164 165 /** 166 * struct dfs_bangradar_params - DFS bangradar params. 167 * @bangradar_type: Type of Bangradar. 168 * @seg_id: Segment ID information. 169 * @is_chirp: Chirp radar or not. 170 * @freq_offset: Frequency offset at which radar was found. 171 * @detector_id: Detector ID corresponding to primary/agile detectors. 172 * @is_fh_radar: Frequency Hopping Radar type or not. 173 */ 174 struct dfs_bangradar_params { 175 enum dfs_bangradar_types bangradar_type; 176 uint8_t seg_id; 177 uint8_t is_chirp; 178 int32_t freq_offset; 179 uint8_t detector_id; 180 uint8_t is_fh_radar; 181 }; 182 #define DFS_IOCTL_PARAM_NOVAL 65535 183 #define DFS_IOCTL_PARAM_ENABLE 0x8000 184 185 /* Random channel flags */ 186 /* Flag to exclude current operating channels */ 187 #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH 0x0001 /* 0000 0000 0000 0001 */ 188 189 /* Flag to exclude weather channels */ 190 #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH 0x0002 /* 0000 0000 0000 0010 */ 191 192 /* Flag to exclude indoor channels */ 193 #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH 0x0004 /* 0000 0000 0000 0100 */ 194 195 /* Flag to exclude outdoor channels */ 196 #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH 0x0008 /* 0000 0000 0000 1000 */ 197 198 /* Flag to exclude dfs channels */ 199 #define DFS_RANDOM_CH_FLAG_NO_DFS_CH 0x0010 /* 0000 0000 0001 0000 */ 200 201 /* Flag to exclude all 5GHz channels */ 202 #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH 0x0020 /* 0000 0000 0010 0000 */ 203 204 /* Flag to exclude all 2.4GHz channels */ 205 #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH 0x0040 /* 0000 0000 0100 0000 */ 206 207 /* Flag to enable Reduced BW Agile DFS */ 208 #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW 0x0080 /* 0000 0000 1000 0000 */ 209 210 /* Flag to exclude Japan W53 channels */ 211 #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH 0x0100 /* 0000 0001 0000 0000 */ 212 213 /* Restricted 80P80 MHz is enabled */ 214 #define DFS_RANDOM_CH_FLAG_RESTRICTED_80P80_ENABLED 0x0200 215 /* 0000 0010 0000 0000 */ 216 217 /* Flag to exclude all 6GHz channels */ 218 #define DFS_RANDOM_CH_FLAG_NO_6GHZ_CH 0x00400 /* 0000 0100 0000 0000 */ 219 220 /* Flag to exclude spruce spur adjacent channels */ 221 #define DFS_RANDOM_CH_FLAG_NO_SPRUCE_SPUR_ADJ_CH \ 222 0x0800 /* 0000 1000 0000 0000 */ 223 /** 224 * struct wlan_dfs_caps - DFS capability structure. 225 * @wlan_dfs_ext_chan_ok: Can radar be detected on the extension chan? 226 * @wlan_dfs_combined_rssi_ok: Can use combined radar RSSI? 227 * @wlan_dfs_use_enhancement: This flag is used to indicate if radar 228 * detection scheme should use enhanced chirping 229 * detection algorithm. This flag also determines 230 * if certain radar data should be discarded to 231 * minimize false detection of radar. 232 * @wlan_strong_signal_diversiry: Strong Signal fast diversity count. 233 * @wlan_chip_is_bb_tlv: Chip is BB TLV? 234 * @wlan_chip_is_over_sampled: Is Over sampled. 235 * @wlan_chip_is_ht160: IS VHT160? 236 * @wlan_chip_is_false_detect: Is False detected? 237 * @wlan_fastdiv_val: Goes with wlan_strong_signal_diversiry: If we 238 * have fast diversity capability, read off 239 * Strong Signal fast diversity count set in the 240 * ini file, and store so we can restore the 241 * value when radar is disabled. 242 */ 243 struct wlan_dfs_caps { 244 uint32_t wlan_dfs_ext_chan_ok:1, 245 wlan_dfs_combined_rssi_ok:1, 246 wlan_dfs_use_enhancement:1, 247 wlan_strong_signal_diversiry:1, 248 wlan_chip_is_bb_tlv:1, 249 wlan_chip_is_over_sampled:1, 250 wlan_chip_is_ht160:1, 251 wlan_chip_is_false_detect:1; 252 uint32_t wlan_fastdiv_val; 253 }; 254 255 /** 256 * struct wlan_dfs_phyerr_param - DFS Phyerr structure. 257 * @pe_firpwr: FIR pwr out threshold. 258 * @pe_rrssi: Radar rssi thresh. 259 * @pe_height: Pulse height thresh. 260 * @pe_prssi: Pulse rssi thresh. 261 * @pe_inband: Inband thresh. 262 * @pe_relpwr: Relative power threshold in 0.5dB steps. 263 * @pe_relstep: Pulse Relative step threshold in 0.5dB steps. 264 * @pe_maxlen: Max length of radar sign in 0.8us units. 265 * @pe_usefir128: Use the average in-band power measured over 128 cycles. 266 * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM 267 * weak signal detect or pkt is detected immediately after tx 268 * to rx transition. 269 * @pe_enmaxrssi: Enable to use the max rssi instead of the last rssi during 270 * fine gain changes for radar detection. 271 */ 272 struct wlan_dfs_phyerr_param { 273 int32_t pe_firpwr; 274 int32_t pe_rrssi; 275 int32_t pe_height; 276 int32_t pe_prssi; 277 int32_t pe_inband; 278 uint32_t pe_relpwr; 279 uint32_t pe_relstep; 280 uint32_t pe_maxlen; 281 bool pe_usefir128; 282 bool pe_blockradar; 283 bool pe_enmaxrssi; 284 }; 285 286 /** 287 * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace 288 * @WLAN_EV_RADAR_DETECTED: Radar is detected 289 * @WLAN_EV_CAC_RESET: CAC started or CAC completed status is reset 290 * @WLAN_EV_CAC_STARTED: CAC timer has started 291 * @WLAN_EV_CAC_COMPLETED: CAC timer completed 292 * @WLAN_EV_NOL_STARTED: NOL started 293 * @WLAN_EV_NOL_FINISHED: NOL Completed 294 * @WLAN_EV_PCAC_STARTED: PreCAC Started 295 * @WLAN_EV_PCAC_COMPLETED: PreCAC Completed 296 * 297 * DFS events such as radar detected, CAC started, 298 * CAC completed, NOL started, NOL finished 299 */ 300 enum WLAN_DFS_EVENTS { 301 WLAN_EV_RADAR_DETECTED, 302 WLAN_EV_CAC_RESET, 303 WLAN_EV_CAC_STARTED, 304 WLAN_EV_CAC_COMPLETED, 305 WLAN_EV_NOL_STARTED, 306 WLAN_EV_NOL_FINISHED, 307 WLAN_EV_PCAC_STARTED, 308 WLAN_EV_PCAC_COMPLETED, 309 }; 310 311 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR) 312 /* 313 * Structure of Pulse to be injected into the DFS Module 314 * ****************************************************** 315 * Header 316 * ====== 317 * ----------|--------------| 318 * num_pulses| total_len_seq| 319 * ----------|--------------| 320 * Buffer Contents per pulse: 321 * ========================== 322 * ------|----------|-----------|----------|-----------|---------------|-------- 323 * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT 324 * | | | | | |Buffer.. 325 * ------|----------|-----------|----------|-----------|---------------|-------- 326 */ 327 328 /** 329 * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the 330 * user file. 331 * @r_rssi: RSSI of the pulse. 332 * @r_ext_rssi: Extension Channel RSSI. 333 * @r_rs_tstamp: Timestamp. 334 * @r_fulltsf: TSF64. 335 * @fft_datalen: Total len of FFT. 336 * @total_len_pulse: Total len of the pulse. 337 * @fft_buf: Pointer to fft data. 338 */ 339 340 struct synthetic_pulse { 341 uint8_t r_rssi; 342 uint8_t r_ext_rssi; 343 uint32_t r_rs_tstamp; 344 uint64_t r_fulltsf; 345 uint16_t fft_datalen; 346 uint16_t total_len_pulse; 347 unsigned char *fft_buf; 348 } qdf_packed; 349 350 /** 351 * struct synthetic_seq - Structure to hold an array of pointers to the 352 * pulse structure. 353 * @num_pulses: Total num of pulses in the sequence. 354 * @total_len_seq: Total len of the sequence. 355 * @pulse: Array of pointers to synthetic_pulse structure. 356 */ 357 358 struct synthetic_seq { 359 uint8_t num_pulses; 360 uint32_t total_len_seq; 361 struct synthetic_pulse *pulse[]; 362 }; 363 364 /** 365 * struct seq_store - Structure to hold an array of pointers to the synthetic 366 * sequence structure. 367 * @num_sequence: Total number of "sequence of pulses" in the file. 368 * @seq_arr: Array of pointers to synthetic_seq structure. 369 */ 370 371 struct seq_store { 372 uint8_t num_sequence; 373 struct synthetic_seq *seq_arr[]; 374 }; 375 #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */ 376 377 /** 378 * enum dfs_agile_sm_evt - DFS Agile SM events. 379 * @DFS_AGILE_SM_EV_AGILE_START: Event to start AGILE PreCAC/RCAC. 380 * @DFS_AGILE_SM_EV_AGILE_STOP: Event to stop AGILE PreCAC/RCAC.. 381 * @DFS_AGILE_SM_EV_AGILE_DONE: Event to complete AGILE PreCAC/RCAC.. 382 * @DFS_AGILE_SM_EV_ADFS_RADAR: Event to restart AGILE PreCAC/RCAC after radar. 383 */ 384 enum dfs_agile_sm_evt { 385 DFS_AGILE_SM_EV_AGILE_START = 0, 386 DFS_AGILE_SM_EV_AGILE_STOP = 1, 387 DFS_AGILE_SM_EV_AGILE_DONE = 2, 388 DFS_AGILE_SM_EV_ADFS_RADAR = 3, 389 }; 390 391 /** 392 * enum precac_status_for_chan - preCAC status for channels. 393 * @DFS_NO_PRECAC_COMPLETED_CHANS: None of the channels are preCAC completed. 394 * @DFS_PRECAC_COMPLETED_CHAN: A given channel is preCAC completed. 395 * @DFS_PRECAC_REQUIRED_CHAN: A given channel required preCAC. 396 * @DFS_INVALID_PRECAC_STATUS: Invalid status. 397 * 398 * Note: "DFS_NO_PRECAC_COMPLETED_CHANS" has more priority than 399 * "DFS_PRECAC_COMPLETED_CHAN". This is because if the preCAC list does not 400 * have any channel that completed preCAC, "DFS_NO_PRECAC_COMPLETED_CHANS" 401 * is returned and search for preCAC completion (DFS_PRECAC_COMPLETED_CHAN) 402 * for a given channel is not done. 403 */ 404 enum precac_status_for_chan { 405 DFS_NO_PRECAC_COMPLETED_CHANS, 406 DFS_PRECAC_COMPLETED_CHAN, 407 DFS_PRECAC_REQUIRED_CHAN, 408 DFS_INVALID_PRECAC_STATUS, 409 }; 410 411 #endif /* _DFS_IOCTL_H_ */ 412