xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/dispatcher/inc/wlan_dfs_ioctl.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
1 /*
2  * Copyright (c) 2011, 2016-2020 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 #define RESTRICTED_80P80_START_FREQ 5660
61 #define RESTRICTED_80P80_END_FREQ 5805
62 
63 /* Check if the given frequencies are within restricted 80P80 start freq(5660)
64  * and end freq (5805).
65  */
66 #define CHAN_WITHIN_RESTRICTED_80P80(cfreq1, cfreq2) \
67 	((((cfreq1) >= RESTRICTED_80P80_START_FREQ) && \
68 	  ((cfreq1) <= RESTRICTED_80P80_END_FREQ) && \
69 	  ((cfreq2) >= RESTRICTED_80P80_START_FREQ) && \
70 	  ((cfreq2) <= RESTRICTED_80P80_END_FREQ)) ? true : false)
71 
72 /*
73  * Spectral IOCTLs use DFS_LAST_IOCTL as the base.
74  * This must always be the last IOCTL in DFS and have
75  * the highest value.
76  */
77 #define DFS_LAST_IOCTL 29
78 
79 #ifndef DFS_CHAN_MAX
80 #define DFS_CHAN_MAX 25
81 #endif
82 
83 /**
84  * struct dfsreq_nolelem - NOL elements.
85  * @nol_freq:          NOL channel frequency.
86  * @nol_chwidth:       NOL channel width.
87  * @nol_start_us:      OS microseconds when the NOL timer started.
88  * @nol_timeout_ms:    Nol timeout value in msec.
89  */
90 
91 struct dfsreq_nolelem {
92 	uint16_t        nol_freq;
93 	uint16_t        nol_chwidth;
94 	uint64_t        nol_start_us;
95 	uint32_t        nol_timeout_ms;
96 };
97 
98 struct dfsreq_nolinfo {
99 	uint32_t  dfs_ch_nchans;
100 	struct dfsreq_nolelem dfs_nol[DFS_CHAN_MAX];
101 };
102 
103 /*
104  * IOCTL parameter types
105  */
106 
107 #define DFS_PARAM_FIRPWR  1
108 #define DFS_PARAM_RRSSI   2
109 #define DFS_PARAM_HEIGHT  3
110 #define DFS_PARAM_PRSSI   4
111 #define DFS_PARAM_INBAND  5
112 /* 5413 specific parameters */
113 #define DFS_PARAM_RELPWR  7
114 #define DFS_PARAM_RELSTEP 8
115 #define DFS_PARAM_MAXLEN  9
116 
117 /**
118  * struct dfs_ioctl_params - DFS ioctl params.
119  * @dfs_firpwr:     FIR pwr out threshold.
120  * @dfs_rrssi:      Radar rssi thresh.
121  * @dfs_height:     Pulse height thresh.
122  * @dfs_prssi:      Pulse rssi thresh.
123  * @dfs_inband:     Inband thresh.
124  * @dfs_relpwr:     Pulse relative pwr thresh.
125  * @dfs_relstep:    Pulse relative step thresh.
126  * @dfs_maxlen:     Pulse max duration.
127  */
128 struct dfs_ioctl_params {
129 	int32_t dfs_firpwr;
130 	int32_t dfs_rrssi;
131 	int32_t dfs_height;
132 	int32_t dfs_prssi;
133 	int32_t dfs_inband;
134 	int32_t dfs_relpwr;
135 	int32_t dfs_relstep;
136 	int32_t dfs_maxlen;
137 };
138 
139 /* Types of Bangradar commands:
140  * @DFS_BANGRADAR_FOR_ALL_SUBCHANS          : Bangradar with no arguments.
141  *                                            All the subchannels in the current
142  *                                            channel shall be added.
143  * @DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID : Bangradar with 1 (seg_id) argument
144  *                                            All subchannels of the specific
145  *                                            seg_id shall be added.
146  * @DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS     : Bangradar with all (segment ID,
147  *                                            is_chirp and frequency offset)
148  *                                            arguments.
149  *                                            Only radar infected subchannels
150  *                                            of the specific seg_id shall be
151  *                                            added.
152  *
153  * (Unless all arguments are given, we cannot determine which specific
154  * subchannels to simulate the radar on, hence simulate in all subchans).
155  */
156 enum dfs_bangradar_types {
157 	DFS_NO_BANGRADAR = 0,
158 	DFS_BANGRADAR_FOR_ALL_SUBCHANS,
159 	DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID,
160 	DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS,
161 	DFS_INVALID_BANGRADAR_TYPE
162 };
163 
164 /**
165  * struct dfs_bangradar_params - DFS bangradar params.
166  * @bangradar_type: Type of Bangradar.
167  * @seg_id:         Segment ID information.
168  * @is_chirp:       Chirp radar or not.
169  * @freq_offset:    Frequency offset at which radar was found.
170  * @detector_id:    Detector ID corresponding to primary/agile detectors.
171  */
172 struct dfs_bangradar_params {
173 	enum dfs_bangradar_types bangradar_type;
174 	uint8_t seg_id;
175 	uint8_t is_chirp;
176 	int32_t freq_offset;
177 	uint8_t detector_id;
178 };
179 #define DFS_IOCTL_PARAM_NOVAL  65535
180 #define DFS_IOCTL_PARAM_ENABLE 0x8000
181 
182 /* Random channel flags */
183 /* Flag to exclude current operating channels */
184 #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH       0x0001 /* 0000 0000 0000 0001 */
185 
186 /* Flag to exclude weather channels */
187 #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH        0x0002 /* 0000 0000 0000 0010 */
188 
189 /* Flag to exclude indoor channels */
190 #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH       0x0004 /* 0000 0000 0000 0100 */
191 
192 /* Flag to exclude outdoor channels */
193 #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH       0x0008 /* 0000 0000 0000 1000 */
194 
195 /* Flag to exclude dfs channels */
196 #define DFS_RANDOM_CH_FLAG_NO_DFS_CH            0x0010 /* 0000 0000 0001 0000 */
197 
198 /* Flag to exclude all 5GHz channels */
199 #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH           0x0020 /* 0000 0000 0010 0000 */
200 
201 /* Flag to exclude all 2.4GHz channels */
202 #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH           0x0040 /* 0000 0000 0100 0000 */
203 
204 /* Flag to enable Reduced BW Agile DFS */
205 #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW    0x0080 /* 0000 0000 1000 0000 */
206 
207 /* Flag to exclude Japan W53 channnels */
208 #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH      0x0100 /* 0000 0001 0000 0000 */
209 
210 /* Restricted 80P80 MHz is enabled */
211 #define DFS_RANDOM_CH_FLAG_RESTRICTED_80P80_ENABLED 0x0200
212 						       /* 0000 0010 0000 0000 */
213 
214 /**
215  * struct wlan_dfs_caps - DFS capability structure.
216  * @wlan_dfs_ext_chan_ok:         Can radar be detected on the extension chan?
217  * @wlan_dfs_combined_rssi_ok:    Can use combined radar RSSI?
218  * @wlan_dfs_use_enhancement:     This flag is used to indicate if radar
219  *                                detection scheme should use enhanced chirping
220  *                                detection algorithm. This flag also determines
221  *                                if certain radar data should be discarded to
222  *                                minimize false detection of radar.
223  * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
224  * @wlan_chip_is_bb_tlv:          Chip is BB TLV?
225  * @wlan_chip_is_over_sampled:    Is Over sampled.
226  * @wlan_chip_is_ht160:           IS VHT160?
227  * @wlan_chip_is_false_detect:    Is False detected?
228  * @wlan_fastdiv_val:             Goes with wlan_strong_signal_diversiry: If we
229  *                                have fast diversity capability, read off
230  *                                Strong Signal fast diversity count set in the
231  *                                ini file, and store so we can restore the
232  *                                value when radar is disabled.
233  */
234 struct wlan_dfs_caps {
235 	uint32_t wlan_dfs_ext_chan_ok:1,
236 			 wlan_dfs_combined_rssi_ok:1,
237 			 wlan_dfs_use_enhancement:1,
238 			 wlan_strong_signal_diversiry:1,
239 			 wlan_chip_is_bb_tlv:1,
240 			 wlan_chip_is_over_sampled:1,
241 			 wlan_chip_is_ht160:1,
242 			 wlan_chip_is_false_detect:1;
243 	uint32_t wlan_fastdiv_val;
244 };
245 
246 /**
247  * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
248  * @pe_firpwr:     FIR pwr out threshold.
249  * @pe_rrssi:      Radar rssi thresh.
250  * @pe_height:     Pulse height thresh.
251  * @pe_prssi:      Pulse rssi thresh.
252  * @pe_inband:     Inband thresh.
253  * @pe_relpwr:     Relative power threshold in 0.5dB steps.
254  * @pe_relstep:    Pulse Relative step threshold in 0.5dB steps.
255  * @pe_maxlen:     Max length of radar sign in 0.8us units.
256  * @pe_usefir128:  Use the average in-band power measured over 128 cycles.
257  * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
258  *                 weak signal detect or pkt is detected immediately after tx
259  *                 to rx transition.
260  * @pe_enmaxrssi:  Enable to use the max rssi instead of the last rssi during
261  *                 fine gain changes for radar detection.
262  */
263 struct wlan_dfs_phyerr_param {
264 	int32_t    pe_firpwr;
265 	int32_t    pe_rrssi;
266 	int32_t    pe_height;
267 	int32_t    pe_prssi;
268 	int32_t    pe_inband;
269 	uint32_t   pe_relpwr;
270 	uint32_t   pe_relstep;
271 	uint32_t   pe_maxlen;
272 	bool       pe_usefir128;
273 	bool       pe_blockradar;
274 	bool       pe_enmaxrssi;
275 };
276 
277 /**
278  * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace
279  * @WLAN_EV_RADAR_DETECTED: Radar is detected
280  * @WLAN_EV_CAC_STARTED:    CAC timer has started
281  * @WLAN_EV_CAC_COMPLETED:  CAC timer completed
282  * @WLAN_EV_NOL_STARTED:    NOL started
283  * @WLAN_EV_NOL_FINISHED:   NOL Completed
284  *
285  * DFS events such as radar detected, CAC started,
286  * CAC completed, NOL started, NOL finished
287  */
288 enum WLAN_DFS_EVENTS {
289 	WLAN_EV_RADAR_DETECTED,
290 	WLAN_EV_CAC_STARTED,
291 	WLAN_EV_CAC_COMPLETED,
292 	WLAN_EV_NOL_STARTED,
293 	WLAN_EV_NOL_FINISHED,
294 };
295 
296 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR)
297 /**
298  * Structure of Pulse to be injected into the DFS Module
299  * ******************************************************
300  * Header
301  * ======
302  * ----------|--------------|
303  * num_pulses| total_len_seq|
304  * ----------|--------------|
305  * Buffer Contents per pulse:
306  * ==========================
307  * ------|----------|-----------|----------|-----------|---------------|--------
308  * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT
309  *       |          |           |          |           |               |Buffer..
310  * ------|----------|-----------|----------|-----------|---------------|--------
311  */
312 
313 /**
314  * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the
315  * user file.
316  * @r_rssi:          RSSI of the pulse.
317  * @r_ext_rssi:      Extension Channel RSSI.
318  * @r_rs_tstamp:     Timestamp.
319  * @r_fulltsf:       TSF64.
320  * @fft_datalen:     Total len of FFT.
321  * @total_len_pulse: Total len of the pulse.
322  * @fft_buf:         Pointer to fft data.
323  */
324 
325 struct synthetic_pulse {
326 	uint8_t r_rssi;
327 	uint8_t r_ext_rssi;
328 	uint32_t r_rs_tstamp;
329 	uint64_t r_fulltsf;
330 	uint16_t fft_datalen;
331 	uint16_t total_len_pulse;
332 	unsigned char *fft_buf;
333 } qdf_packed;
334 
335 /**
336  * struct synthetic_seq - Structure to hold an array of pointers to the
337  * pulse structure.
338  * @num_pulses:    Total num of pulses in the sequence.
339  * @total_len_seq: Total len of the sequence.
340  * @pulse:         Array of pointers to synthetic_pulse structure.
341  */
342 
343 struct synthetic_seq {
344 	uint8_t num_pulses;
345 	uint32_t total_len_seq;
346 	struct synthetic_pulse *pulse[0];
347 };
348 
349 /**
350  * struct seq_store - Structure to hold an array of pointers to the synthetic
351  * sequence structure.
352  * @num_sequence: Total number of "sequence of pulses" in the file.
353  * @seq_arr:      Array of pointers to synthetic_seq structure.
354  */
355 
356 struct seq_store {
357 	uint8_t num_sequence;
358 	struct synthetic_seq *seq_arr[0];
359 };
360 #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */
361 
362 /**
363  * enum dfs_rcac_sm_evt - DFS Rolling CAC SM events.
364  * @DFS_RCAC_SM_EV_RCAC_START: Event to start RCAC.
365  * @DFS_RCAC_SM_EV_RCAC_DOWN:  Event to stop RCAC.
366  * @DFS_RCAC_SM_EV_RCAC_DONE:  Event to complete RCAC.
367  * @DFS_RCAC_SM_EV_ADFS_RADAR: Event to restart RCAC after radar in agile.
368  */
369 enum dfs_rcac_sm_evt {
370 	DFS_RCAC_SM_EV_RCAC_START = 0,
371 	DFS_RCAC_SM_EV_RCAC_STOP = 1,
372 	DFS_RCAC_SM_EV_RCAC_DONE = 2,
373 	DFS_RCAC_SM_EV_ADFS_RADAR_FOUND = 3,
374 };
375 
376 #endif  /* _DFS_IOCTL_H_ */
377