xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/dfs_channel.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2016-2018,2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2008 Atheros Communications, Inc.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: This file has channel related information.
22  */
23 
24 #ifndef _DFS_CHANNEL_H_
25 #define _DFS_CHANNEL_H_
26 
27 /* Channel attributes */
28 
29 /* OFDM channel */
30 #define WLAN_CHAN_OFDM             0x0000000000000040
31 
32 /* 2 GHz spectrum channel. */
33 #define WLAN_CHAN_2GHZ             0x0000000000000080
34 
35 /* 5 GHz spectrum channel */
36 #define WLAN_CHAN_5GHZ             0x0000000000000100
37 
38 /* Radar found on channel */
39 #define WLAN_CHAN_DFS_RADAR        0x0000000000001000
40 
41 /* HT 20 channel */
42 #define WLAN_CHAN_HT20             0x0000000000010000
43 
44 /* HT 40 with extension channel above */
45 #define WLAN_CHAN_HT40PLUS         0x0000000000020000
46 
47 /* HT 40 with extension channel below */
48 #define WLAN_CHAN_HT40MINUS        0x0000000000040000
49 
50 /* VHT 20 channel */
51 #define WLAN_CHAN_VHT20            0x0000000000100000
52 
53 /* VHT 40 with extension channel above */
54 #define WLAN_CHAN_VHT40PLUS        0x0000000000200000
55 
56 /* VHT 40 with extension channel below */
57 #define WLAN_CHAN_VHT40MINUS       0x0000000000400000
58 
59 /* VHT 80 channel */
60 #define WLAN_CHAN_VHT80            0x0000000000800000
61 
62 /* VHT 160 channel */
63 #define WLAN_CHAN_VHT160           0x0000000004000000
64 
65 /* VHT 80_80 channel */
66 #define WLAN_CHAN_VHT80_80         0x0000000008000000
67 
68 /* HE 20 channel */
69 #define WLAN_CHAN_HE20             0x0000000010000000
70 
71 /* HE 40 with extension channel above */
72 #define WLAN_CHAN_HE40PLUS         0x0000000020000000
73 
74 /* HE 40 with extension channel below */
75 #define WLAN_CHAN_HE40MINUS        0x0000000040000000
76 
77 /* HE 80 channel */
78 #define WLAN_CHAN_HE80             0x0000000200000000
79 
80 /* HE 160 channel */
81 #define WLAN_CHAN_HE160            0x0000000400000000
82 
83 /* HE 80_80 channel */
84 #define WLAN_CHAN_HE80_80          0x0000000800000000
85 
86 /* flagext */
87 #define WLAN_CHAN_DFS_RADAR_FOUND    0x01
88 
89 /* DFS required on channel */
90 #define WLAN_CHAN_DFS              0x0002
91 
92 /* DFS required on channel for 2nd band of 80+80*/
93 #define WLAN_CHAN_DFS_CFREQ2       0x0004
94 
95 /* if channel has been checked for DFS */
96 #define WLAN_CHAN_DFS_CLEAR        0x0008
97 
98 /* DFS radar history for slave device(STA mode) */
99 #define WLAN_CHAN_HISTORY_RADAR    0x0100
100 
101 /* DFS CAC valid for  slave device(STA mode) */
102 #define WLAN_CHAN_CAC_VALID        0x0200
103 
104 #define WLAN_IS_CHAN_2GHZ(_c) \
105 	(((_c)->dfs_ch_flags & WLAN_CHAN_2GHZ) != 0)
106 
107 #define WLAN_IS_CHAN_5GHZ(_c) \
108 	(((_c)->dfs_ch_flags & WLAN_CHAN_5GHZ) != 0)
109 
110 #define WLAN_IS_CHAN_11N_HT40(_c) \
111 	(((_c)->dfs_ch_flags & (WLAN_CHAN_HT40PLUS | \
112 					WLAN_CHAN_HT40MINUS)) != 0)
113 
114 #define WLAN_IS_CHAN_11N_HT40PLUS(_c) \
115 	(((_c)->dfs_ch_flags & WLAN_CHAN_HT40PLUS) != 0)
116 
117 #define WLAN_IS_CHAN_11N_HT40MINUS(_c) \
118 	(((_c)->dfs_ch_flags & WLAN_CHAN_HT40MINUS) != 0)
119 
120 #define WLAN_CHAN_A \
121 	(WLAN_CHAN_5GHZ | WLAN_CHAN_OFDM)
122 
123 #define WLAN_IS_CHAN_A(_c) \
124 	(((_c)->dfs_ch_flags & WLAN_CHAN_A) == WLAN_CHAN_A)
125 
126 #define WLAN_CHAN_11NA_HT20 \
127 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT20)
128 
129 #define WLAN_CHAN_11NA_HT40PLUS \
130 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT40PLUS)
131 
132 #define WLAN_CHAN_11NA_HT40MINUS \
133 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT40MINUS)
134 
135 #define WLAN_IS_CHAN_11NA_HT20(_c) \
136 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT20) == \
137 	 WLAN_CHAN_11NA_HT20)
138 
139 #define WLAN_IS_CHAN_11NA_HT40PLUS(_c) \
140 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40PLUS) == \
141 	WLAN_CHAN_11NA_HT40PLUS)
142 
143 #define WLAN_IS_CHAN_11NA_HT40MINUS(_c) \
144 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40MINUS) == \
145 	 WLAN_CHAN_11NA_HT40MINUS)
146 
147 #define WLAN_CHAN_11AC_VHT20 \
148 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT20)
149 
150 #define WLAN_CHAN_11AC_VHT40PLUS \
151 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40PLUS)
152 
153 #define WLAN_CHAN_11AC_VHT40MINUS \
154 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40MINUS)
155 
156 #define WLAN_CHAN_11AC_VHT80 \
157 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80)
158 
159 #define WLAN_CHAN_11AC_VHT160 \
160 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT160)
161 
162 #define WLAN_CHAN_11AC_VHT80_80 \
163 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80_80)
164 
165 #define WLAN_IS_CHAN_11AC_VHT20(_c) \
166 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT20) == \
167 	 WLAN_CHAN_11AC_VHT20)
168 
169 #define WLAN_IS_CHAN_11AC_VHT40(_c) \
170 	(((_c)->dfs_ch_flags & (WLAN_CHAN_VHT40PLUS | \
171 			    WLAN_CHAN_VHT40MINUS)) != 0)
172 
173 #define WLAN_IS_CHAN_11AC_VHT40PLUS(_c) \
174 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40PLUS) == \
175 	WLAN_CHAN_11AC_VHT40PLUS)
176 
177 #define WLAN_IS_CHAN_11AC_VHT40MINUS(_c) \
178 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40MINUS) == \
179 	WLAN_CHAN_11AC_VHT40MINUS)
180 
181 #define WLAN_IS_CHAN_11AC_VHT80(_c) \
182 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80) == \
183 	 WLAN_CHAN_11AC_VHT80)
184 
185 #define WLAN_IS_CHAN_11AC_VHT160(_c) \
186 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT160) == \
187 	 WLAN_CHAN_11AC_VHT160)
188 
189 #define WLAN_IS_CHAN_11AC_VHT80_80(_c) \
190 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80_80) == \
191 	WLAN_CHAN_11AC_VHT80_80)
192 
193 #define WLAN_CHAN_11AXA_HE20 \
194 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE20)
195 
196 #define WLAN_CHAN_11AXA_HE40PLUS \
197 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE40PLUS)
198 
199 #define WLAN_CHAN_11AXA_HE40MINUS \
200 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE40MINUS)
201 
202 #define WLAN_CHAN_11AXA_HE80 \
203 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE80)
204 
205 #define WLAN_CHAN_11AXA_HE160 \
206 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE160)
207 
208 #define WLAN_CHAN_11AXA_HE80_80 \
209 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE80_80)
210 
211 #define WLAN_IS_CHAN_11AXA_HE20(_c) \
212 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE20) == \
213 	 WLAN_CHAN_11AXA_HE20)
214 
215 #define WLAN_IS_CHAN_11AXA_HE40PLUS(_c) \
216 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40PLUS) == \
217 	 WLAN_CHAN_11AXA_HE40PLUS)
218 
219 #define WLAN_IS_CHAN_11AXA_HE40MINUS(_c) \
220 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40MINUS) == \
221 	 WLAN_CHAN_11AXA_HE40MINUS)
222 
223 #define WLAN_IS_CHAN_11AXA_HE80(_c) \
224 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80) == \
225 	 WLAN_CHAN_11AXA_HE80)
226 
227 #define WLAN_IS_CHAN_11AXA_HE160(_c) \
228 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE160) == \
229 	 WLAN_CHAN_11AXA_HE160)
230 
231 #define WLAN_IS_CHAN_11AXA_HE80_80(_c) \
232 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_80) == \
233 	 WLAN_CHAN_11AXA_HE80_80)
234 
235 #define WLAN_IS_CHAN_DFS(_c) \
236 	(((_c)->dfs_ch_flagext & \
237 	(WLAN_CHAN_DFS | WLAN_CHAN_DFS_CLEAR)) == WLAN_CHAN_DFS)
238 
239 #define WLAN_IS_CHAN_DFS_CFREQ2(_c) \
240 	(((_c)->dfs_ch_flagext & \
241 	(WLAN_CHAN_DFS_CFREQ2|WLAN_CHAN_DFS_CLEAR)) == \
242 	WLAN_CHAN_DFS_CFREQ2)
243 
244 #define WLAN_IS_PRIMARY_OR_SECONDARY_CHAN_DFS(_c) \
245 	(WLAN_IS_CHAN_DFS(_c) || \
246 	 ((WLAN_IS_CHAN_11AC_VHT160(_c) || \
247 	 WLAN_IS_CHAN_11AC_VHT80_80(_c) || \
248 	 WLAN_IS_CHAN_11AXA_HE160(_c) || \
249 	 WLAN_IS_CHAN_11AXA_HE80_80(_c)) \
250 	&& WLAN_IS_CHAN_DFS_CFREQ2(_c)))
251 
252 #define WLAN_IS_CHAN_RADAR(_c)    \
253 	(((_c)->dfs_ch_flags & WLAN_CHAN_DFS_RADAR) == \
254 	 WLAN_CHAN_DFS_RADAR)
255 
256 #define WLAN_IS_CHAN_HISTORY_RADAR(_c)    \
257 	(((_c)->dfs_ch_flagext & WLAN_CHAN_HISTORY_RADAR) == \
258 	WLAN_CHAN_HISTORY_RADAR)
259 
260 #define WLAN_CHAN_CLR_HISTORY_RADAR(_c)    \
261 	((_c)->dfs_ch_flagext &= ~WLAN_CHAN_HISTORY_RADAR)
262 
263 #define WLAN_CHAN_ANY      (-1)    /* token for ``any channel'' */
264 
265 #define WLAN_CHAN_ANYC \
266 	((struct dfs_channel *) WLAN_CHAN_ANY)
267 
268 #define WLAN_IS_CHAN_MODE_20(_c)      \
269 	(WLAN_IS_CHAN_A(_c)        ||    \
270 	 WLAN_IS_CHAN_11NA_HT20(_c)  ||  \
271 	 WLAN_IS_CHAN_11AC_VHT20(_c) ||  \
272 	 WLAN_IS_CHAN_11AXA_HE20(_c))
273 
274 #define WLAN_IS_CHAN_MODE_40(_c)          \
275 	(WLAN_IS_CHAN_11AC_VHT40PLUS(_c)  || \
276 	 WLAN_IS_CHAN_11AC_VHT40MINUS(_c) || \
277 	 WLAN_IS_CHAN_11NA_HT40PLUS(_c)   || \
278 	 WLAN_IS_CHAN_11NA_HT40MINUS(_c)  || \
279 	 WLAN_IS_CHAN_11AXA_HE40PLUS(_c)  || \
280 	 WLAN_IS_CHAN_11AXA_HE40MINUS(_c))
281 
282 #define WLAN_IS_CHAN_MODE_80(_c)          \
283 	(WLAN_IS_CHAN_11AC_VHT80(_c)      || \
284 	 WLAN_IS_CHAN_11AXA_HE80(_c))
285 
286 #define WLAN_IS_CHAN_MODE_160(_c)         \
287 	(WLAN_IS_CHAN_11AC_VHT160(_c)     || \
288 	 WLAN_IS_CHAN_11AXA_HE160(_c))
289 
290 #define WLAN_IS_CHAN_MODE_80_80(_c)       \
291 	(WLAN_IS_CHAN_11AC_VHT80_80(_c)   || \
292 	 WLAN_IS_CHAN_11AXA_HE80_80(_c))
293 
294 #define WLAN_IS_CHAN_MODE_165(_dfs, _c) \
295 	(dfs_is_restricted_80p80mhz_supported(_dfs) && \
296 	WLAN_IS_CHAN_MODE_80_80(_c))
297 
298 #endif /* _DFS_CHANNEL_H_ */
299