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 /* 6 GHz spectrum channel */ 39 #define WLAN_CHAN_6GHZ 0x0000001000000000 40 41 /* Radar found on channel */ 42 #define WLAN_CHAN_DFS_RADAR 0x0000000000001000 43 44 /* HT 20 channel */ 45 #define WLAN_CHAN_HT20 0x0000000000010000 46 47 /* HT 40 with extension channel above */ 48 #define WLAN_CHAN_HT40PLUS 0x0000000000020000 49 50 /* HT 40 with extension channel below */ 51 #define WLAN_CHAN_HT40MINUS 0x0000000000040000 52 53 /* VHT 20 channel */ 54 #define WLAN_CHAN_VHT20 0x0000000000100000 55 56 /* VHT 40 with extension channel above */ 57 #define WLAN_CHAN_VHT40PLUS 0x0000000000200000 58 59 /* VHT 40 with extension channel below */ 60 #define WLAN_CHAN_VHT40MINUS 0x0000000000400000 61 62 /* VHT 80 channel */ 63 #define WLAN_CHAN_VHT80 0x0000000000800000 64 65 /* VHT 160 channel */ 66 #define WLAN_CHAN_VHT160 0x0000000004000000 67 68 /* VHT 80_80 channel */ 69 #define WLAN_CHAN_VHT80_80 0x0000000008000000 70 71 /* HE 20 channel */ 72 #define WLAN_CHAN_HE20 0x0000000010000000 73 74 /* HE 40 with extension channel above */ 75 #define WLAN_CHAN_HE40PLUS 0x0000000020000000 76 77 /* HE 40 with extension channel below */ 78 #define WLAN_CHAN_HE40MINUS 0x0000000040000000 79 80 /* HE 80 channel */ 81 #define WLAN_CHAN_HE80 0x0000000200000000 82 83 /* HE 160 channel */ 84 #define WLAN_CHAN_HE160 0x0000000400000000 85 86 /* HE 80_80 channel */ 87 #define WLAN_CHAN_HE80_80 0x0000000800000000 88 89 /* flagext */ 90 #define WLAN_CHAN_DFS_RADAR_FOUND 0x01 91 92 /* DFS required on channel */ 93 #define WLAN_CHAN_DFS 0x0002 94 95 /* DFS required on channel for 2nd band of 80+80*/ 96 #define WLAN_CHAN_DFS_CFREQ2 0x0004 97 98 /* if channel has been checked for DFS */ 99 #define WLAN_CHAN_DFS_CLEAR 0x0008 100 101 /* DFS radar history for slave device(STA mode) */ 102 #define WLAN_CHAN_HISTORY_RADAR 0x0100 103 104 /* DFS CAC valid for slave device(STA mode) */ 105 #define WLAN_CHAN_CAC_VALID 0x0200 106 107 #define WLAN_IS_CHAN_2GHZ(_c) \ 108 (((_c)->dfs_ch_flags & WLAN_CHAN_2GHZ) != 0) 109 110 #define WLAN_IS_CHAN_5GHZ(_c) \ 111 (((_c)->dfs_ch_flags & WLAN_CHAN_5GHZ) != 0) 112 113 #define WLAN_IS_CHAN_11N_HT40(_c) \ 114 (((_c)->dfs_ch_flags & (WLAN_CHAN_HT40PLUS | \ 115 WLAN_CHAN_HT40MINUS)) != 0) 116 117 #define WLAN_IS_CHAN_11N_HT40PLUS(_c) \ 118 (((_c)->dfs_ch_flags & WLAN_CHAN_HT40PLUS) != 0) 119 120 #define WLAN_IS_CHAN_11N_HT40MINUS(_c) \ 121 (((_c)->dfs_ch_flags & WLAN_CHAN_HT40MINUS) != 0) 122 123 #define WLAN_CHAN_A \ 124 (WLAN_CHAN_5GHZ | WLAN_CHAN_OFDM) 125 126 #define WLAN_IS_CHAN_A(_c) \ 127 (((_c)->dfs_ch_flags & WLAN_CHAN_A) == WLAN_CHAN_A) 128 129 #define WLAN_CHAN_11NA_HT20 \ 130 (WLAN_CHAN_5GHZ | WLAN_CHAN_HT20) 131 132 #define WLAN_CHAN_11NA_HT40PLUS \ 133 (WLAN_CHAN_5GHZ | WLAN_CHAN_HT40PLUS) 134 135 #define WLAN_CHAN_11NA_HT40MINUS \ 136 (WLAN_CHAN_5GHZ | WLAN_CHAN_HT40MINUS) 137 138 #define WLAN_IS_CHAN_11NA_HT20(_c) \ 139 (((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT20) == \ 140 WLAN_CHAN_11NA_HT20) 141 142 #define WLAN_IS_CHAN_11NA_HT40PLUS(_c) \ 143 (((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40PLUS) == \ 144 WLAN_CHAN_11NA_HT40PLUS) 145 146 #define WLAN_IS_CHAN_11NA_HT40MINUS(_c) \ 147 (((_c)->dfs_ch_flags & WLAN_CHAN_11NA_HT40MINUS) == \ 148 WLAN_CHAN_11NA_HT40MINUS) 149 150 #define WLAN_CHAN_11AC_VHT20 \ 151 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT20) 152 153 #define WLAN_CHAN_11AC_VHT40PLUS \ 154 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40PLUS) 155 156 #define WLAN_CHAN_11AC_VHT40MINUS \ 157 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT40MINUS) 158 159 #define WLAN_CHAN_11AC_VHT80 \ 160 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80) 161 162 #define WLAN_CHAN_11AC_VHT160 \ 163 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT160) 164 165 #define WLAN_CHAN_11AC_VHT80_80 \ 166 (WLAN_CHAN_5GHZ | WLAN_CHAN_VHT80_80) 167 168 #define WLAN_IS_CHAN_11AC_VHT20(_c) \ 169 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT20) == \ 170 WLAN_CHAN_11AC_VHT20) 171 172 #define WLAN_IS_CHAN_11AC_VHT40(_c) \ 173 (((_c)->dfs_ch_flags & (WLAN_CHAN_VHT40PLUS | \ 174 WLAN_CHAN_VHT40MINUS)) != 0) 175 176 #define WLAN_IS_CHAN_11AC_VHT40PLUS(_c) \ 177 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40PLUS) == \ 178 WLAN_CHAN_11AC_VHT40PLUS) 179 180 #define WLAN_IS_CHAN_11AC_VHT40MINUS(_c) \ 181 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT40MINUS) == \ 182 WLAN_CHAN_11AC_VHT40MINUS) 183 184 #define WLAN_IS_CHAN_11AC_VHT80(_c) \ 185 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80) == \ 186 WLAN_CHAN_11AC_VHT80) 187 188 #define WLAN_IS_CHAN_11AC_VHT160(_c) \ 189 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT160) == \ 190 WLAN_CHAN_11AC_VHT160) 191 192 #define WLAN_IS_CHAN_11AC_VHT80_80(_c) \ 193 (((_c)->dfs_ch_flags & WLAN_CHAN_11AC_VHT80_80) == \ 194 WLAN_CHAN_11AC_VHT80_80) 195 196 #define WLAN_CHAN_11AXA_HE20 \ 197 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE20) 198 199 #define WLAN_CHAN_11AXA_HE20_6G \ 200 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE20) 201 202 #define WLAN_CHAN_11AXA_HE40PLUS \ 203 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE40PLUS) 204 205 #define WLAN_CHAN_11AXA_HE40PLUS_6G \ 206 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE40PLUS) 207 208 #define WLAN_CHAN_11AXA_HE40MINUS \ 209 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE40MINUS) 210 211 #define WLAN_CHAN_11AXA_HE40MINUS_6G \ 212 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE40MINUS) 213 214 #define WLAN_CHAN_11AXA_HE80 \ 215 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE80) 216 217 #define WLAN_CHAN_11AXA_HE80_6G \ 218 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE80) 219 220 #define WLAN_CHAN_11AXA_HE160 \ 221 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE160) 222 223 #define WLAN_CHAN_11AXA_HE160_6G \ 224 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE160) 225 226 #define WLAN_CHAN_11AXA_HE80_80 \ 227 (WLAN_CHAN_5GHZ | WLAN_CHAN_HE80_80) 228 229 #define WLAN_CHAN_11AXA_HE80_80_6G \ 230 (WLAN_CHAN_6GHZ | WLAN_CHAN_HE80_80) 231 232 #define WLAN_IS_CHAN_11AXA_HE20(_c) \ 233 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE20) == \ 234 WLAN_CHAN_11AXA_HE20) || \ 235 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE20_6G) == \ 236 WLAN_CHAN_11AXA_HE20_6G)) 237 238 #define WLAN_IS_CHAN_11AXA_HE40PLUS(_c) \ 239 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40PLUS) == \ 240 WLAN_CHAN_11AXA_HE40PLUS) || \ 241 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40PLUS_6G) == \ 242 WLAN_CHAN_11AXA_HE40PLUS_6G)) 243 244 #define WLAN_IS_CHAN_11AXA_HE40MINUS(_c) \ 245 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40MINUS) == \ 246 WLAN_CHAN_11AXA_HE40MINUS) || \ 247 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE40MINUS_6G) == \ 248 WLAN_CHAN_11AXA_HE40MINUS_6G)) 249 250 #define WLAN_IS_CHAN_11AXA_HE80(_c) \ 251 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80) == \ 252 WLAN_CHAN_11AXA_HE80) || \ 253 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_6G) == \ 254 WLAN_CHAN_11AXA_HE80_6G)) 255 256 #define WLAN_IS_CHAN_11AXA_HE160(_c) \ 257 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE160) == \ 258 WLAN_CHAN_11AXA_HE160) || \ 259 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE160_6G) == \ 260 WLAN_CHAN_11AXA_HE160_6G)) 261 262 #define WLAN_IS_CHAN_11AXA_HE80_80(_c) \ 263 ((((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_80) == \ 264 WLAN_CHAN_11AXA_HE80_80) || \ 265 (((_c)->dfs_ch_flags & WLAN_CHAN_11AXA_HE80_80_6G) == \ 266 WLAN_CHAN_11AXA_HE80_80_6G)) 267 268 #define WLAN_IS_CHAN_DFS(_c) \ 269 (((_c)->dfs_ch_flagext & \ 270 (WLAN_CHAN_DFS | WLAN_CHAN_DFS_CLEAR)) == WLAN_CHAN_DFS) 271 272 #define WLAN_IS_CHAN_DFS_CFREQ2(_c) \ 273 (((_c)->dfs_ch_flagext & \ 274 (WLAN_CHAN_DFS_CFREQ2|WLAN_CHAN_DFS_CLEAR)) == \ 275 WLAN_CHAN_DFS_CFREQ2) 276 277 #define WLAN_IS_PRIMARY_OR_SECONDARY_CHAN_DFS(_c) \ 278 (WLAN_IS_CHAN_DFS(_c) || \ 279 ((WLAN_IS_CHAN_11AC_VHT160(_c) || \ 280 WLAN_IS_CHAN_11AC_VHT80_80(_c) || \ 281 WLAN_IS_CHAN_11AXA_HE160(_c) || \ 282 WLAN_IS_CHAN_11AXA_HE80_80(_c)) \ 283 && WLAN_IS_CHAN_DFS_CFREQ2(_c))) 284 285 #define WLAN_IS_CHAN_RADAR(_c) \ 286 (((_c)->dfs_ch_flags & WLAN_CHAN_DFS_RADAR) == \ 287 WLAN_CHAN_DFS_RADAR) 288 289 #define WLAN_IS_CHAN_HISTORY_RADAR(_c) \ 290 (((_c)->dfs_ch_flagext & WLAN_CHAN_HISTORY_RADAR) == \ 291 WLAN_CHAN_HISTORY_RADAR) 292 293 #define WLAN_CHAN_CLR_HISTORY_RADAR(_c) \ 294 ((_c)->dfs_ch_flagext &= ~WLAN_CHAN_HISTORY_RADAR) 295 296 #define WLAN_CHAN_ANY (-1) /* token for ``any channel'' */ 297 298 #define WLAN_CHAN_ANYC \ 299 ((struct dfs_channel *) WLAN_CHAN_ANY) 300 301 #define WLAN_IS_CHAN_MODE_20(_c) \ 302 (WLAN_IS_CHAN_A(_c) || \ 303 WLAN_IS_CHAN_11NA_HT20(_c) || \ 304 WLAN_IS_CHAN_11AC_VHT20(_c) || \ 305 WLAN_IS_CHAN_11AXA_HE20(_c)) 306 307 #define WLAN_IS_CHAN_MODE_40(_c) \ 308 (WLAN_IS_CHAN_11AC_VHT40PLUS(_c) || \ 309 WLAN_IS_CHAN_11AC_VHT40MINUS(_c) || \ 310 WLAN_IS_CHAN_11NA_HT40PLUS(_c) || \ 311 WLAN_IS_CHAN_11NA_HT40MINUS(_c) || \ 312 WLAN_IS_CHAN_11AXA_HE40PLUS(_c) || \ 313 WLAN_IS_CHAN_11AXA_HE40MINUS(_c)) 314 315 #define WLAN_IS_CHAN_MODE_80(_c) \ 316 (WLAN_IS_CHAN_11AC_VHT80(_c) || \ 317 WLAN_IS_CHAN_11AXA_HE80(_c)) 318 319 #define WLAN_IS_CHAN_MODE_160(_c) \ 320 (WLAN_IS_CHAN_11AC_VHT160(_c) || \ 321 WLAN_IS_CHAN_11AXA_HE160(_c)) 322 323 #define WLAN_IS_CHAN_MODE_80_80(_c) \ 324 (WLAN_IS_CHAN_11AC_VHT80_80(_c) || \ 325 WLAN_IS_CHAN_11AXA_HE80_80(_c)) 326 327 #define WLAN_IS_CHAN_MODE_165(_dfs, _c) \ 328 (dfs_is_restricted_80p80mhz_supported(_dfs) && \ 329 WLAN_IS_CHAN_MODE_80_80(_c)) 330 331 #endif /* _DFS_CHANNEL_H_ */ 332