xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/dispatcher/inc/wlan_dfs_ioctl.h (revision ad85c389289a03e320cd08dea21861f9857892fc)
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 /*
57  * Spectral IOCTLs use DFS_LAST_IOCTL as the base.
58  * This must always be the last IOCTL in DFS and have
59  * the highest value.
60  */
61 #define DFS_LAST_IOCTL 27
62 
63 #ifndef DFS_CHAN_MAX
64 #define DFS_CHAN_MAX 1023
65 #endif
66 
67 /**
68  * struct dfsreq_nolelem - NOL elements.
69  * @nol_freq:          NOL channel frequency.
70  * @nol_chwidth:       NOL channel width.
71  * @nol_start_ticks:   OS ticks when the NOL timer started.
72  * @nol_timeout_ms:    Nol timeout value in msec.
73  */
74 
75 struct dfsreq_nolelem {
76 	uint16_t        nol_freq;
77 	uint16_t        nol_chwidth;
78 	unsigned long   nol_start_ticks;
79 	uint32_t        nol_timeout_ms;
80 };
81 
82 struct dfsreq_nolinfo {
83 	uint32_t  dfs_ch_nchans;
84 	struct dfsreq_nolelem dfs_nol[DFS_CHAN_MAX];
85 };
86 
87 /*
88  * IOCTL parameter types
89  */
90 
91 #define DFS_PARAM_FIRPWR  1
92 #define DFS_PARAM_RRSSI   2
93 #define DFS_PARAM_HEIGHT  3
94 #define DFS_PARAM_PRSSI   4
95 #define DFS_PARAM_INBAND  5
96 /* 5413 specific parameters */
97 #define DFS_PARAM_RELPWR  7
98 #define DFS_PARAM_RELSTEP 8
99 #define DFS_PARAM_MAXLEN  9
100 
101 /**
102  * struct dfs_ioctl_params - DFS ioctl params.
103  * @dfs_firpwr:     FIR pwr out threshold.
104  * @dfs_rrssi:      Radar rssi thresh.
105  * @dfs_height:     Pulse height thresh.
106  * @dfs_prssi:      Pulse rssi thresh.
107  * @dfs_inband:     Inband thresh.
108  * @dfs_relpwr:     Pulse relative pwr thresh.
109  * @dfs_relstep:    Pulse relative step thresh.
110  * @dfs_maxlen:     Pulse max duration.
111  */
112 struct dfs_ioctl_params {
113 	int32_t dfs_firpwr;
114 	int32_t dfs_rrssi;
115 	int32_t dfs_height;
116 	int32_t dfs_prssi;
117 	int32_t dfs_inband;
118 	int32_t dfs_relpwr;
119 	int32_t dfs_relstep;
120 	int32_t dfs_maxlen;
121 };
122 
123 /* Types of Bangradar commands:
124  * @DFS_BANGRADAR_FOR_ALL_SUBCHANS          : Bangradar with no arguments.
125  *                                            All the subchannels in the current
126  *                                            channel shall be added.
127  * @DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID : Bangradar with 1 (seg_id) argument
128  *                                            All subchannels of the specific
129  *                                            seg_id shall be added.
130  * @DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS     : Bangradar with all (segment ID,
131  *                                            is_chirp and frequency offset)
132  *                                            arguments.
133  *                                            Only radar infected subchannels
134  *                                            of the specific seg_id shall be
135  *                                            added.
136  *
137  * (Unless all arguments are given, we cannot determine which specific
138  * subchannels to simulate the radar on, hence simulate in all subchans).
139  */
140 enum dfs_bangradar_types {
141 	DFS_NO_BANGRADAR = 0,
142 	DFS_BANGRADAR_FOR_ALL_SUBCHANS,
143 	DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID,
144 	DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS,
145 	DFS_INVALID_BANGRADAR_TYPE
146 };
147 
148 /**
149  * struct dfs_bangradar_params - DFS bangradar params.
150  * @bangradar_type: Type of Bangradar.
151  * @seg_id:         Segment ID information.
152  * @is_chirp:       Chirp radar or not.
153  * @freq_offset:    Frequency offset at which radar was found.
154  */
155 struct dfs_bangradar_params {
156 	enum dfs_bangradar_types bangradar_type;
157 	uint8_t seg_id;
158 	uint8_t is_chirp;
159 	int32_t freq_offset;
160 };
161 #define DFS_IOCTL_PARAM_NOVAL  65535
162 #define DFS_IOCTL_PARAM_ENABLE 0x8000
163 
164 /* Random channel flags */
165 /* Flag to exclude current operating channels */
166 #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH       0x0001 /* 0000 0000 0000 0001 */
167 
168 /* Flag to exclude weather channels */
169 #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH        0x0002 /* 0000 0000 0000 0010 */
170 
171 /* Flag to exclude indoor channels */
172 #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH       0x0004 /* 0000 0000 0000 0100 */
173 
174 /* Flag to exclude outdoor channels */
175 #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH       0x0008 /* 0000 0000 0000 1000 */
176 
177 /* Flag to exclude dfs channels */
178 #define DFS_RANDOM_CH_FLAG_NO_DFS_CH            0x0010 /* 0000 0000 0001 0000 */
179 
180 /* Flag to exclude all 5GHz channels */
181 #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH           0x0020 /* 0000 0000 0010 0000 */
182 
183 /* Flag to exclude all 2.4GHz channels */
184 #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH           0x0040 /* 0000 0000 0100 0000 */
185 
186 /* Flag to enable Reduced BW Agile DFS */
187 #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW    0x0080 /* 0000 0000 1000 0000 */
188 
189 /* Flag to exclude Japan W53 channnels */
190 #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH      0x0100 /* 0000 0001 0000 0000 */
191 
192 /**
193  * struct wlan_dfs_caps - DFS capability structure.
194  * @wlan_dfs_ext_chan_ok:         Can radar be detected on the extension chan?
195  * @wlan_dfs_combined_rssi_ok:    Can use combined radar RSSI?
196  * @wlan_dfs_use_enhancement:     This flag is used to indicate if radar
197  *                                detection scheme should use enhanced chirping
198  *                                detection algorithm. This flag also determines
199  *                                if certain radar data should be discarded to
200  *                                minimize false detection of radar.
201  * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
202  * @wlan_chip_is_bb_tlv:          Chip is BB TLV?
203  * @wlan_chip_is_over_sampled:    Is Over sampled.
204  * @wlan_chip_is_ht160:           IS VHT160?
205  * @wlan_chip_is_false_detect:    Is False detected?
206  * @wlan_fastdiv_val:             Goes with wlan_strong_signal_diversiry: If we
207  *                                have fast diversity capability, read off
208  *                                Strong Signal fast diversity count set in the
209  *                                ini file, and store so we can restore the
210  *                                value when radar is disabled.
211  */
212 struct wlan_dfs_caps {
213 	uint32_t wlan_dfs_ext_chan_ok:1,
214 			 wlan_dfs_combined_rssi_ok:1,
215 			 wlan_dfs_use_enhancement:1,
216 			 wlan_strong_signal_diversiry:1,
217 			 wlan_chip_is_bb_tlv:1,
218 			 wlan_chip_is_over_sampled:1,
219 			 wlan_chip_is_ht160:1,
220 			 wlan_chip_is_false_detect:1;
221 	uint32_t wlan_fastdiv_val;
222 };
223 
224 /**
225  * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
226  * @pe_firpwr:     FIR pwr out threshold.
227  * @pe_rrssi:      Radar rssi thresh.
228  * @pe_height:     Pulse height thresh.
229  * @pe_prssi:      Pulse rssi thresh.
230  * @pe_inband:     Inband thresh.
231  * @pe_relpwr:     Relative power threshold in 0.5dB steps.
232  * @pe_relstep:    Pulse Relative step threshold in 0.5dB steps.
233  * @pe_maxlen:     Max length of radar sign in 0.8us units.
234  * @pe_usefir128:  Use the average in-band power measured over 128 cycles.
235  * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
236  *                 weak signal detect or pkt is detected immediately after tx
237  *                 to rx transition.
238  * @pe_enmaxrssi:  Enable to use the max rssi instead of the last rssi during
239  *                 fine gain changes for radar detection.
240  */
241 struct wlan_dfs_phyerr_param {
242 	int32_t    pe_firpwr;
243 	int32_t    pe_rrssi;
244 	int32_t    pe_height;
245 	int32_t    pe_prssi;
246 	int32_t    pe_inband;
247 	uint32_t   pe_relpwr;
248 	uint32_t   pe_relstep;
249 	uint32_t   pe_maxlen;
250 	bool       pe_usefir128;
251 	bool       pe_blockradar;
252 	bool       pe_enmaxrssi;
253 };
254 
255 #endif  /* _DFS_IOCTL_H_ */
256