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