xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/dfs_channel.h (revision 878d42c770e8f4f39f616b20412de44faeced7b9)
1 /*
2  * Copyright (c) 2016-2018,2020-2021 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 #ifdef WLAN_COMP_CHAN_MODE
29 
30 #define WLAN_CHAN_20MHZ            0x0000000000000100
31 
32 #define WLAN_CHAN_40PLUS           0x0000000000000200
33 
34 #define WLAN_CHAN_40MINUS          0x0000000000000300
35 
36 #define WLAN_CHAN_80MHZ            0x0000000000000400
37 
38 #define WLAN_CHAN_160MHZ           0x0000000000000500
39 
40 #define WLAN_CHAN_80_80MHZ         0x0000000000000600
41 
42 #define WLAN_CHAN_HTCAP            0x0000000000001000
43 
44 #define WLAN_CHAN_VHTCAP           0x0000000000002000
45 
46 #define WLAN_CHAN_HECAP            0x0000000000003000
47 
48 /* 2 GHz spectrum channel. */
49 #define WLAN_CHAN_2GHZ             0x0000000000000010
50 
51 /* 5 GHz spectrum channel */
52 #define WLAN_CHAN_5GHZ             0x0000000000000020
53 
54 /* 6 GHz spectrum channel */
55 #define WLAN_CHAN_6GHZ             0x0000000000000030
56 
57 /* HT 20 channel */
58 #define WLAN_CHAN_HT20             (WLAN_CHAN_HTCAP | WLAN_CHAN_20MHZ)
59 
60 /* HT 40 with extension channel above */
61 #define WLAN_CHAN_HT40PLUS         (WLAN_CHAN_HTCAP | WLAN_CHAN_40PLUS)
62 
63 /* HT 40 with extension channel below */
64 #define WLAN_CHAN_HT40MINUS        (WLAN_CHAN_HTCAP | WLAN_CHAN_40MINUS)
65 
66 /* VHT 20 channel */
67 #define WLAN_CHAN_VHT20            (WLAN_CHAN_VHTCAP | WLAN_CHAN_20MHZ)
68 
69 /* VHT 40 with extension channel above */
70 #define WLAN_CHAN_VHT40PLUS        (WLAN_CHAN_VHTCAP | WLAN_CHAN_40PLUS)
71 
72 /* VHT 40 with extension channel below */
73 #define WLAN_CHAN_VHT40MINUS       (WLAN_CHAN_VHTCAP | WLAN_CHAN_40MINUS)
74 
75 /* VHT 80 channel */
76 #define WLAN_CHAN_VHT80            (WLAN_CHAN_VHTCAP | WLAN_CHAN_80MHZ)
77 
78 /* VHT 160 channel */
79 #define WLAN_CHAN_VHT160           (WLAN_CHAN_VHTCAP | WLAN_CHAN_160MHZ)
80 
81 /* VHT 80_80 channel */
82 #define WLAN_CHAN_VHT80_80         (WLAN_CHAN_VHTCAP | WLAN_CHAN_80_80MHZ)
83 
84 /* HE 20 channel */
85 #define WLAN_CHAN_HE20             (WLAN_CHAN_HECAP | WLAN_CHAN_20MHZ)
86 
87 /* HE 40 with extension channel above */
88 #define WLAN_CHAN_HE40PLUS         (WLAN_CHAN_HECAP | WLAN_CHAN_40PLUS)
89 
90 /* HE 40 with extension channel below */
91 #define WLAN_CHAN_HE40MINUS        (WLAN_CHAN_HECAP | WLAN_CHAN_40MINUS)
92 
93 /* HE 80 channel */
94 #define WLAN_CHAN_HE80             (WLAN_CHAN_HECAP | WLAN_CHAN_80MHZ)
95 
96 /* HE 160 channel */
97 #define WLAN_CHAN_HE160            (WLAN_CHAN_HECAP | WLAN_CHAN_160MHZ)
98 
99 /* HE 80_80 channel */
100 #define WLAN_CHAN_HE80_80          (WLAN_CHAN_HECAP | WLAN_CHAN_80_80MHZ)
101 
102 /* OFDM channel */
103 #define WLAN_CHAN_OFDM             0x0000000000400000
104 
105 /* Turbo Channel */
106 #define WLAN_CHAN_TURBO            0x0000000020000000
107 
108 /* Radar found on channel */
109 #define WLAN_CHAN_DFS_RADAR        0x0000000002000000
110 
111 #define WLAN_CHAN_BAND_MASK        0x00000000000000F0
112 
113 #define WLAN_CHAN_BW_MASK          0x000000000000FF00
114 
115 #define WLAN_IS_CHAN_2GHZ(_c)        WLAN_IS_FLAG_2GHZ((_c)->dfs_ch_flags)
116 
117 #define WLAN_IS_CHAN_5GHZ(_c)        WLAN_IS_FLAG_5GHZ((_c)->dfs_ch_flags)
118 
119 #define WLAN_IS_CHAN_6GHZ(_c)        WLAN_IS_FLAG_6GHZ((_c)->dfs_ch_flags)
120 
121 #define WLAN_IS_CHAN_HT20(_c)        WLAN_IS_FLAG_HT20((_c)->dfs_ch_flags)
122 
123 #define WLAN_IS_CHAN_HT40PLUS(_c)    WLAN_IS_FLAG_HT40PLUS((_c)->dfs_ch_flags)
124 
125 #define WLAN_IS_CHAN_HT40MINUS(_c)   WLAN_IS_FLAG_HT40MINUS((_c)->dfs_ch_flags)
126 
127 #define WLAN_IS_CHAN_HT40(_c)        WLAN_IS_FLAG_HT40((_c)->dfs_ch_flags)
128 
129 #define WLAN_IS_CHAN_VHT20(_c)       WLAN_IS_FLAG_VHT20((_c)->dfs_ch_flags)
130 
131 #define WLAN_IS_CHAN_VHT40PLUS(_c)   WLAN_IS_FLAG_VHT40PLUS((_c)->dfs_ch_flags)
132 
133 #define WLAN_IS_CHAN_VHT40MINUS(_c)  WLAN_IS_FLAG_VHT40MINUS((_c)->dfs_ch_flags)
134 
135 #define WLAN_IS_CHAN_VHT40(_c)       WLAN_IS_FLAG_VHT40((_c)->dfs_ch_flags)
136 
137 #define WLAN_IS_CHAN_VHT80(_c)       WLAN_IS_FLAG_VHT80((_c)->dfs_ch_flags)
138 
139 #define WLAN_IS_CHAN_VHT160(_c)      WLAN_IS_FLAG_VHT160((_c)->dfs_ch_flags)
140 
141 #define WLAN_IS_CHAN_VHT80_80(_c)    WLAN_IS_FLAG_VHT80_80((_c)->dfs_ch_flags)
142 
143 #define WLAN_IS_CHAN_VHT40(_c)       WLAN_IS_FLAG_VHT40((_c)->dfs_ch_flags)
144 
145 #define WLAN_IS_CHAN_HE20(_c)        WLAN_IS_FLAG_HE20((_c)->dfs_ch_flags)
146 
147 #define WLAN_IS_CHAN_HE40PLUS(_c)    WLAN_IS_FLAG_HE40PLUS((_c)->dfs_ch_flags)
148 
149 #define WLAN_IS_CHAN_HE40MINUS(_c)   WLAN_IS_FLAG_HE40MINUS((_c)->dfs_ch_flags)
150 
151 #define WLAN_IS_CHAN_HE40(_c)        WLAN_IS_FLAG_HE40((_c)->dfs_ch_flags)
152 
153 #define WLAN_IS_CHAN_HE80(_c)        WLAN_IS_FLAG_HE80((_c)->dfs_ch_flags)
154 
155 #define WLAN_IS_CHAN_HE160(_c)       WLAN_IS_FLAG_HE160((_c)->dfs_ch_flags)
156 
157 #define WLAN_IS_CHAN_HE80_80(_c)     WLAN_IS_FLAG_HE80_80((_c)->dfs_ch_flags)
158 
159 #define WLAN_IS_CHAN_OFDM(_c)        WLAN_IS_FLAG_OFDM((_c)->dfs_ch_flags)
160 
161 #define WLAN_IS_CHAN_TURBO(_c)       WLAN_IS_FLAG_TURBO((_c)->dfs_ch_flags)
162 
163 #define WLAN_IS_FLAG_2GHZ(_flag) \
164 	(((_flag) & WLAN_CHAN_BAND_MASK) == WLAN_CHAN_2GHZ)
165 
166 #define WLAN_IS_FLAG_5GHZ(_flag) \
167 	(((_flag) & WLAN_CHAN_BAND_MASK) == WLAN_CHAN_5GHZ)
168 
169 #define WLAN_IS_FLAG_6GHZ(_flag) \
170 	(((_flag) & WLAN_CHAN_BAND_MASK) == WLAN_CHAN_6GHZ)
171 
172 #define WLAN_IS_FLAG_HT20(_flag) \
173 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HT20)
174 
175 #define WLAN_IS_FLAG_HT40PLUS(_flag) \
176 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HT40PLUS)
177 
178 #define WLAN_IS_FLAG_HT40MINUS(_flag) \
179 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HT40MINUS)
180 
181 #define WLAN_IS_FLAG_VHT20(_flag) \
182 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT20)
183 
184 #define WLAN_IS_FLAG_VHT40PLUS(_flag) \
185 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT40PLUS)
186 
187 #define WLAN_IS_FLAG_VHT40MINUS(_flag) \
188 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT40MINUS)
189 
190 #define WLAN_IS_FLAG_VHT80(_flag) \
191 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT80)
192 
193 #define WLAN_IS_FLAG_VHT160(_flag) \
194 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT160)
195 
196 #define WLAN_IS_FLAG_VHT80_80(_flag) \
197 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_VHT80_80)
198 
199 #define WLAN_IS_FLAG_HE20(_flag) \
200 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE20)
201 
202 #define WLAN_IS_FLAG_HE40PLUS(_flag) \
203 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE40PLUS)
204 
205 #define WLAN_IS_FLAG_HE40MINUS(_flag) \
206 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE40MINUS)
207 
208 #define WLAN_IS_FLAG_HE80(_flag) \
209 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE80)
210 
211 #define WLAN_IS_FLAG_HE160(_flag) \
212 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE160)
213 
214 #define WLAN_IS_FLAG_HE80_80(_flag) \
215 	(((_flag) & WLAN_CHAN_BW_MASK) == WLAN_CHAN_HE80_80)
216 
217 #define WLAN_IS_FLAG_OFDM(_flag) \
218 	((_flag) & WLAN_CHAN_OFDM)
219 
220 #define WLAN_IS_FLAG_TURBO(_flag) \
221 	((_flag) & WLAN_CHAN_TURBO)
222 
223 #define WLAN_IS_CHAN_11N_HT40(_c) \
224 	(WLAN_IS_CHAN_HT40PLUS(_c) || WLAN_IS_CHAN_HT40MINUS(_c))
225 
226 #define WLAN_IS_CHAN_11N_HT40PLUS(_c) WLAN_IS_CHAN_HT40PLUS(_c)
227 
228 #define WLAN_IS_CHAN_11N_HT40MINUS(_c) WLAN_IS_CHAN_HT40MINUS(_c)
229 
230 #define WLAN_IS_CHAN_A(_c) \
231 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_OFDM(_c))
232 
233 #define WLAN_IS_CHAN_11NA_HT20(_c) \
234 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HT20(_c))
235 
236 #define WLAN_IS_CHAN_11NA_HT40PLUS(_c) \
237 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HT40PLUS(_c))
238 
239 #define WLAN_IS_CHAN_11NA_HT40MINUS(_c) \
240 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HT40MINUS(_c))
241 
242 #define WLAN_IS_CHAN_11AC_VHT20(_c) \
243 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT20(_c))
244 
245 #define WLAN_IS_CHAN_11AC_VHT40(_c) \
246 	(WLAN_IS_CHAN_11AC_VHT40MINUS(_c) || WLAN_IS_CHAN_11AC_VHT40PLUS(_c))
247 
248 #define WLAN_IS_CHAN_11AC_VHT40PLUS(_c) \
249 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT40PLUS(_c))
250 
251 #define WLAN_IS_CHAN_11AC_VHT40MINUS(_c) \
252 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT40MINUS(_c))
253 
254 #define WLAN_IS_CHAN_11AC_VHT80(_c) \
255 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT80(_c))
256 
257 #define WLAN_IS_CHAN_11AC_VHT160(_c) \
258 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT160(_c))
259 
260 #define WLAN_IS_CHAN_11AC_VHT80_80(_c) \
261 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_VHT80_80(_c))
262 
263 #define WLAN_IS_CHAN_11AXA_HE20_5G(_c) \
264 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE20(_c))
265 
266 #define WLAN_IS_CHAN_11AXA_HE40_5G(_c) \
267 	(WLAN_IS_CHAN_11AXA_HE40MINUS_5G(_c) ||  \
268 	 WLAN_IS_CHAN_11AXA_HE40PLUS_5G(_c))
269 
270 #define WLAN_IS_CHAN_11AXA_HE40PLUS_5G(_c) \
271 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE40PLUS(_c))
272 
273 #define WLAN_IS_CHAN_11AXA_HE40MINUS_5G(_c) \
274 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE40MINUS(_c))
275 
276 #define WLAN_IS_CHAN_11AXA_HE80_5G(_c) \
277 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE80(_c))
278 
279 #define WLAN_IS_CHAN_11AXA_HE160_5G(_c) \
280 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE160(_c))
281 
282 #define WLAN_IS_CHAN_11AXA_HE80_80_5G(_c) \
283 	(WLAN_IS_CHAN_5GHZ(_c) && WLAN_IS_CHAN_HE80_80(_c))
284 
285 #define WLAN_IS_CHAN_11AXA_HE20_6G(_c) \
286 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE20(_c))
287 
288 #define WLAN_IS_CHAN_11AXA_HE40_6G(_c) \
289 	(WLAN_IS_CHAN_11AXA_HE40MINUS_6G(_c) || \
290 	 WLAN_IS_CHAN_11AXA_HE40PLUS_6G(_c))
291 
292 #define WLAN_IS_CHAN_11AXA_HE40PLUS_6G(_c) \
293 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE40PLUS(_c))
294 
295 #define WLAN_IS_CHAN_11AXA_HE40MINUS_6G(_c) \
296 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE40MINUS(_c))
297 
298 #define WLAN_IS_CHAN_11AXA_HE80_6G(_c) \
299 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE80(_c))
300 
301 #define WLAN_IS_CHAN_11AXA_HE160_6G(_c) \
302 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE160(_c))
303 
304 #define WLAN_IS_CHAN_11AXA_HE80_80_6G(_c) \
305 	(WLAN_IS_CHAN_6GHZ(_c) && WLAN_IS_CHAN_HE80_80(_c))
306 
307 #define WLAN_IS_CHAN_11AXA_HE20(_c) \
308 	(WLAN_IS_CHAN_11AXA_HE20_5G(_c) || WLAN_IS_CHAN_11AXA_HE20_6G(_c))
309 
310 #define WLAN_IS_CHAN_11AXA_HE40PLUS(_c) \
311 	(WLAN_IS_CHAN_11AXA_HE40PLUS_5G(_c) || \
312 	 WLAN_IS_CHAN_11AXA_HE40PLUS_6G(_c))
313 
314 #define WLAN_IS_CHAN_11AXA_HE40MINUS(_c) \
315 	(WLAN_IS_CHAN_11AXA_HE40MINUS_5G(_c) || \
316 	 WLAN_IS_CHAN_11AXA_HE40MINUS_6G(_c))
317 
318 #define WLAN_IS_CHAN_11AXA_HE80(_c) \
319 	(WLAN_IS_CHAN_11AXA_HE80_5G(_c) || WLAN_IS_CHAN_11AXA_HE80_6G(_c))
320 
321 #define WLAN_IS_CHAN_11AXA_HE160(_c) \
322 	(WLAN_IS_CHAN_11AXA_HE160_5G(_c) || WLAN_IS_CHAN_11AXA_HE160_6G(_c))
323 
324 #define WLAN_IS_CHAN_11AXA_HE80_80(_c) \
325 	(WLAN_IS_CHAN_11AXA_HE80_80_5G(_c) || WLAN_IS_CHAN_11AXA_HE80_80_6G(_c))
326 
327 #define WLAN_IS_CHAN_11AXA_HE80_80(_c) \
328 	(WLAN_IS_CHAN_11AXA_HE80_80_5G(_c) || WLAN_IS_CHAN_11AXA_HE80_80_6G(_c))
329 
330 #else
331 
332 /* OFDM channel */
333 #define WLAN_CHAN_OFDM             0x0000000000000040
334 
335 /* 2 GHz spectrum channel. */
336 #define WLAN_CHAN_2GHZ             0x0000000000000080
337 
338 /* 5 GHz spectrum channel */
339 #define WLAN_CHAN_5GHZ             0x0000000000000100
340 
341 /* 6 GHz spectrum channel */
342 #define WLAN_CHAN_6GHZ             0x0000001000000000
343 
344 /* Radar found on channel */
345 #define WLAN_CHAN_DFS_RADAR        0x0000000000001000
346 
347 /* HT 20 channel */
348 #define WLAN_CHAN_HT20             0x0000000000010000
349 
350 /* HT 40 with extension channel above */
351 #define WLAN_CHAN_HT40PLUS         0x0000000000020000
352 
353 /* HT 40 with extension channel below */
354 #define WLAN_CHAN_HT40MINUS        0x0000000000040000
355 
356 /* VHT 20 channel */
357 #define WLAN_CHAN_VHT20            0x0000000000100000
358 
359 /* VHT 40 with extension channel above */
360 #define WLAN_CHAN_VHT40PLUS        0x0000000000200000
361 
362 /* VHT 40 with extension channel below */
363 #define WLAN_CHAN_VHT40MINUS       0x0000000000400000
364 
365 /* VHT 80 channel */
366 #define WLAN_CHAN_VHT80            0x0000000000800000
367 
368 /* VHT 160 channel */
369 #define WLAN_CHAN_VHT160           0x0000000004000000
370 
371 /* VHT 80_80 channel */
372 #define WLAN_CHAN_VHT80_80         0x0000000008000000
373 
374 /* HE 20 channel */
375 #define WLAN_CHAN_HE20             0x0000000010000000
376 
377 /* HE 40 with extension channel above */
378 #define WLAN_CHAN_HE40PLUS         0x0000000020000000
379 
380 /* HE 40 with extension channel below */
381 #define WLAN_CHAN_HE40MINUS        0x0000000040000000
382 
383 /* HE 80 channel */
384 #define WLAN_CHAN_HE80             0x0000000200000000
385 
386 /* HE 160 channel */
387 #define WLAN_CHAN_HE160            0x0000000400000000
388 
389 /* HE 80_80 channel */
390 #define WLAN_CHAN_HE80_80          0x0000000800000000
391 
392 /* Turbo Channel */
393 #define WLAN_CHAN_TURBO            0x0000000000000010
394 
395 #define WLAN_IS_CHAN_2GHZ(_c) \
396 	(((_c)->dfs_ch_flags & WLAN_CHAN_2GHZ) != 0)
397 
398 #define WLAN_IS_CHAN_5GHZ(_c) \
399 	(((_c)->dfs_ch_flags & WLAN_CHAN_5GHZ) != 0)
400 
401 #define WLAN_IS_CHAN_11N_HT40(_c) \
402 	(((_c)->dfs_ch_flags & (WLAN_CHAN_HT40PLUS | \
403 					WLAN_CHAN_HT40MINUS)) != 0)
404 
405 #define WLAN_IS_CHAN_11N_HT40PLUS(_c) \
406 	(((_c)->dfs_ch_flags & WLAN_CHAN_HT40PLUS) != 0)
407 
408 #define WLAN_IS_CHAN_11N_HT40MINUS(_c) \
409 	(((_c)->dfs_ch_flags & WLAN_CHAN_HT40MINUS) != 0)
410 
411 #define WLAN_IS_CHAN_VHT40PLUS(_c) \
412 	(((_c)->dfs_ch_flags & WLAN_CHAN_VHT40PLUS) != 0)
413 
414 #define WLAN_IS_CHAN_VHT40MINUS(_c) \
415 	(((_c)->dfs_ch_flags & WLAN_CHAN_VHT40MINUS) != 0)
416 
417 #define WLAN_CHAN_A \
418 	(WLAN_CHAN_5GHZ | WLAN_CHAN_OFDM)
419 
420 #define WLAN_IS_CHAN_A(_c) \
421 	(((_c)->dfs_ch_flags & WLAN_CHAN_A) == WLAN_CHAN_A)
422 
423 #define WLAN_CHAN_11NA_HT20 \
424 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT20)
425 
426 #define WLAN_CHAN_11NA_HT40PLUS \
427 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT40PLUS)
428 
429 #define WLAN_CHAN_11NA_HT40MINUS \
430 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HT40MINUS)
431 
432 #define WLAN_IS_CHAN_11NA_HT20(_c) \
433 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT20) == \
434 	 WLAN_CHAN_11NA_HT20)
435 
436 #define WLAN_IS_CHAN_11NA_HT40PLUS(_c) \
437 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40PLUS) == \
438 	WLAN_CHAN_11NA_HT40PLUS)
439 
440 #define WLAN_IS_CHAN_11NA_HT40MINUS(_c) \
441 	(((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40MINUS) == \
442 	 WLAN_CHAN_11NA_HT40MINUS)
443 
444 #define WLAN_CHAN_11AC_VHT20 \
445 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT20)
446 
447 #define WLAN_CHAN_11AC_VHT40PLUS \
448 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40PLUS)
449 
450 #define WLAN_CHAN_11AC_VHT40MINUS \
451 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40MINUS)
452 
453 #define WLAN_CHAN_11AC_VHT80 \
454 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80)
455 
456 #define WLAN_CHAN_11AC_VHT160 \
457 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT160)
458 
459 #define WLAN_CHAN_11AC_VHT80_80 \
460 	(WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80_80)
461 
462 #define WLAN_IS_CHAN_11AC_VHT20(_c) \
463 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT20) == \
464 	 WLAN_CHAN_11AC_VHT20)
465 
466 #define WLAN_IS_CHAN_11AC_VHT40(_c) \
467 	(((_c)->dfs_ch_flags & (WLAN_CHAN_VHT40PLUS | \
468 			    WLAN_CHAN_VHT40MINUS)) != 0)
469 
470 #define WLAN_IS_CHAN_11AC_VHT40PLUS(_c) \
471 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40PLUS) == \
472 	WLAN_CHAN_11AC_VHT40PLUS)
473 
474 #define WLAN_IS_CHAN_11AC_VHT40MINUS(_c) \
475 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40MINUS) == \
476 	WLAN_CHAN_11AC_VHT40MINUS)
477 
478 #define WLAN_IS_CHAN_11AC_VHT80(_c) \
479 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80) == \
480 	 WLAN_CHAN_11AC_VHT80)
481 
482 #define WLAN_IS_CHAN_11AC_VHT160(_c) \
483 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT160) == \
484 	 WLAN_CHAN_11AC_VHT160)
485 
486 #define WLAN_IS_CHAN_11AC_VHT80_80(_c) \
487 	(((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80_80) == \
488 	WLAN_CHAN_11AC_VHT80_80)
489 
490 #define WLAN_CHAN_11AXA_HE20 \
491 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE20)
492 
493 #define WLAN_CHAN_11AXA_HE20_6G \
494 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE20)
495 
496 #define WLAN_CHAN_11AXA_HE40PLUS \
497 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE40PLUS)
498 
499 #define WLAN_CHAN_11AXA_HE40PLUS_6G \
500 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE40PLUS)
501 
502 #define WLAN_CHAN_11AXA_HE40MINUS \
503 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE40MINUS)
504 
505 #define WLAN_CHAN_11AXA_HE40MINUS_6G \
506 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE40MINUS)
507 
508 #define WLAN_CHAN_11AXA_HE80 \
509 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE80)
510 
511 #define WLAN_CHAN_11AXA_HE80_6G \
512 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE80)
513 
514 #define WLAN_CHAN_11AXA_HE160 \
515 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE160)
516 
517 #define WLAN_CHAN_11AXA_HE160_6G \
518 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE160)
519 
520 #define WLAN_CHAN_11AXA_HE80_80 \
521 	(WLAN_CHAN_5GHZ | WLAN_CHAN_HE80_80)
522 
523 #define WLAN_CHAN_11AXA_HE80_80_6G \
524 	(WLAN_CHAN_6GHZ | WLAN_CHAN_HE80_80)
525 
526 #define WLAN_CHAN_108G \
527 	(WLAN_CHAN_2GHZ | WLAN_CHAN_OFDM | WLAN_CHAN_TURBO)
528 
529 #define WLAN_IS_CHAN_11AXA_HE20(_c) \
530 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE20) == \
531 	 WLAN_CHAN_11AXA_HE20) || \
532 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE20_6G) == \
533 	 WLAN_CHAN_11AXA_HE20_6G))
534 
535 #define WLAN_IS_CHAN_11AXA_HE40PLUS(_c) \
536 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40PLUS) == \
537 	 WLAN_CHAN_11AXA_HE40PLUS) || \
538 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40PLUS_6G) == \
539 	  WLAN_CHAN_11AXA_HE40PLUS_6G))
540 
541 #define WLAN_IS_CHAN_11AXA_HE40MINUS(_c) \
542 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40MINUS) == \
543 	 WLAN_CHAN_11AXA_HE40MINUS) || \
544 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40MINUS_6G) == \
545 	 WLAN_CHAN_11AXA_HE40MINUS_6G))
546 
547 #define WLAN_IS_CHAN_11AXA_HE80(_c) \
548 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80) == \
549 	 WLAN_CHAN_11AXA_HE80) || \
550 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_6G) == \
551 	  WLAN_CHAN_11AXA_HE80_6G))
552 
553 #define WLAN_IS_CHAN_11AXA_HE160(_c) \
554 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE160) == \
555 	 WLAN_CHAN_11AXA_HE160) || \
556 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE160_6G) == \
557 	  WLAN_CHAN_11AXA_HE160_6G))
558 
559 #define WLAN_IS_CHAN_11AXA_HE80_80(_c) \
560 	((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_80) == \
561 	 WLAN_CHAN_11AXA_HE80_80) || \
562 	 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_80_6G) == \
563 	  WLAN_CHAN_11AXA_HE80_80_6G))
564 
565 #define WLAN_IS_CHAN_TURBO(_c) \
566 	(((_c)->dfs_ch_flags & WLAN_CHAN_TURBO) != 0)
567 
568 #endif /* WLAN_COMP_CHAN_MODE */
569 
570 #define WLAN_CHAN_108G \
571 	(WLAN_CHAN_2GHZ | WLAN_CHAN_OFDM | WLAN_CHAN_TURBO)
572 
573 #define WLAN_IS_CHAN_108G(_c) \
574 	(((_c)->dfs_ch_flags & WLAN_CHAN_108G) == WLAN_CHAN_108G)
575 
576 /* flagext */
577 #define WLAN_CHAN_DFS_RADAR_FOUND    0x01
578 
579 /* DFS required on channel */
580 #define WLAN_CHAN_DFS              0x0002
581 
582 /* DFS required on channel for 2nd band of 80+80*/
583 #define WLAN_CHAN_DFS_CFREQ2       0x0004
584 
585 /* if channel has been checked for DFS */
586 #define WLAN_CHAN_DFS_CLEAR        0x0008
587 
588 /* DFS radar history for slave device(STA mode) */
589 #define WLAN_CHAN_HISTORY_RADAR    0x0100
590 
591 /* DFS CAC valid for  slave device(STA mode) */
592 #define WLAN_CHAN_CAC_VALID        0x0200
593 
594 #define WLAN_IS_CHAN_DFS(_c) \
595 	(((_c)->dfs_ch_flagext & \
596 	(WLAN_CHAN_DFS | WLAN_CHAN_DFS_CLEAR)) == WLAN_CHAN_DFS)
597 
598 #define WLAN_IS_CHAN_DFS_CFREQ2(_c) \
599 	(((_c)->dfs_ch_flagext & \
600 	(WLAN_CHAN_DFS_CFREQ2|WLAN_CHAN_DFS_CLEAR)) == \
601 	WLAN_CHAN_DFS_CFREQ2)
602 
603 #define WLAN_IS_PRIMARY_OR_SECONDARY_CHAN_DFS(_c) \
604 	(WLAN_IS_CHAN_DFS(_c) || \
605 	 ((WLAN_IS_CHAN_11AC_VHT160(_c) || \
606 	 WLAN_IS_CHAN_11AC_VHT80_80(_c) || \
607 	 WLAN_IS_CHAN_11AXA_HE160(_c) || \
608 	 WLAN_IS_CHAN_11AXA_HE80_80(_c)) \
609 	&& WLAN_IS_CHAN_DFS_CFREQ2(_c)))
610 
611 #ifdef CONFIG_HOST_FIND_CHAN
612 #define WLAN_IS_CHAN_RADAR wlan_is_chan_radar
613 #define WLAN_IS_CHAN_HISTORY_RADAR wlan_is_chan_history_radar
614 #else
615 #define WLAN_IS_CHAN_RADAR(_dfs, _c)    \
616 	(((_c)->dfs_ch_flags & WLAN_CHAN_DFS_RADAR) == \
617 	 WLAN_CHAN_DFS_RADAR)
618 
619 #define WLAN_IS_CHAN_HISTORY_RADAR(_dfs, _c)    \
620 	(((_c)->dfs_ch_flagext & WLAN_CHAN_HISTORY_RADAR) == \
621 	WLAN_CHAN_HISTORY_RADAR)
622 
623 #endif
624 
625 #define WLAN_CHAN_CLR_HISTORY_RADAR(_c)    \
626 	((_c)->dfs_ch_flagext &= ~WLAN_CHAN_HISTORY_RADAR)
627 
628 #define WLAN_CHAN_ANY      (-1)    /* token for ``any channel'' */
629 
630 #define WLAN_CHAN_ANYC \
631 	((struct dfs_channel *) WLAN_CHAN_ANY)
632 
633 #define WLAN_IS_CHAN_MODE_20(_c)      \
634 	(WLAN_IS_CHAN_A(_c)        ||    \
635 	 WLAN_IS_CHAN_11NA_HT20(_c)  ||  \
636 	 WLAN_IS_CHAN_11AC_VHT20(_c) ||  \
637 	 WLAN_IS_CHAN_11AXA_HE20(_c))
638 
639 #define WLAN_IS_CHAN_MODE_40(_c)          \
640 	(WLAN_IS_CHAN_11AC_VHT40PLUS(_c)  || \
641 	 WLAN_IS_CHAN_11AC_VHT40MINUS(_c) || \
642 	 WLAN_IS_CHAN_11NA_HT40PLUS(_c)   || \
643 	 WLAN_IS_CHAN_11NA_HT40MINUS(_c)  || \
644 	 WLAN_IS_CHAN_11AXA_HE40PLUS(_c)  || \
645 	 WLAN_IS_CHAN_11AXA_HE40MINUS(_c))
646 
647 #define WLAN_IS_CHAN_MODE_80(_c)          \
648 	(WLAN_IS_CHAN_11AC_VHT80(_c)      || \
649 	 WLAN_IS_CHAN_11AXA_HE80(_c))
650 
651 #define WLAN_IS_CHAN_MODE_160(_c)         \
652 	(WLAN_IS_CHAN_11AC_VHT160(_c)     || \
653 	 WLAN_IS_CHAN_11AXA_HE160(_c))
654 
655 #define WLAN_IS_CHAN_MODE_80_80(_c)       \
656 	(WLAN_IS_CHAN_11AC_VHT80_80(_c)   || \
657 	 WLAN_IS_CHAN_11AXA_HE80_80(_c))
658 
659 #define WLAN_IS_CHAN_MODE_165(_dfs, _c) \
660 	(dfs_is_restricted_80p80mhz_supported(_dfs) && \
661 	WLAN_IS_CHAN_MODE_80_80(_c))
662 
663 #endif /* _DFS_CHANNEL_H_ */
664