forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmwifi_channels.h
....@@ -1,17 +1,18 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Misc utility routines for WL and Apps
43 * This header file housing the define and function prototype use by
54 * both the wl driver, tools & Apps.
65 *
7
- * Copyright (C) 1999-2019, Broadcom Corporation
8
- *
6
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
7
+ *
8
+ * Copyright (C) 1999-2017, Broadcom Corporation
9
+ *
910 * Unless you and Broadcom execute a separate written software license
1011 * agreement governing use of this software, this software is licensed to you
1112 * under the terms of the GNU General Public License version 2 (the "GPL"),
1213 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1314 * following added to such license:
14
- *
15
+ *
1516 * As a special exception, the copyright holders of this software give you
1617 * permission to link this software with independent modules, and to copy and
1718 * distribute the resulting executable under terms of your choice, provided that
....@@ -19,7 +20,7 @@
1920 * the license of that module. An independent module is a module which is not
2021 * derived from this software. The special exception does not apply to any
2122 * modifications of the software.
22
- *
23
+ *
2324 * Notwithstanding the above, under no circumstances may you combine this
2425 * software in any way with any other Broadcom software provided under a license
2526 * other than the GPL, without Broadcom's express prior written consent.
....@@ -27,33 +28,41 @@
2728 *
2829 * <<Broadcom-WL-IPTag/Open:>>
2930 *
30
- * $Id: bcmwifi_channels.h 309193 2012-01-19 00:03:57Z $
31
+ * $Id: bcmwifi_channels.h 695288 2017-04-19 17:20:39Z $
3132 */
3233
3334 #ifndef _bcmwifi_channels_h_
3435 #define _bcmwifi_channels_h_
3536
36
-
37
-/* A chanspec holds the channel number, band, bandwidth and control sideband */
37
+/* A chanspec holds the channel number, band, bandwidth and primary 20MHz sideband */
3838 typedef uint16 chanspec_t;
39
+typedef uint16 chanspec_band_t;
40
+typedef uint16 chanspec_bw_t;
41
+typedef uint16 chanspec_subband_t;
3942
4043 /* channel defines */
41
-#define CH_UPPER_SB 0x01
42
-#define CH_LOWER_SB 0x02
43
-#define CH_EWA_VALID 0x04
4444 #define CH_80MHZ_APART 16
4545 #define CH_40MHZ_APART 8
4646 #define CH_20MHZ_APART 4
4747 #define CH_10MHZ_APART 2
4848 #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
49
-#define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
49
+
50
+#define CH_MIN_2G_CHANNEL 1u /* Min channel in 2G band */
51
+#define CH_MAX_2G_CHANNEL 14u /* Max channel in 2G band */
52
+#define CH_MIN_2G_40M_CHANNEL 3u /* Min 40MHz center channel in 2G band */
53
+#define CH_MAX_2G_40M_CHANNEL 11u /* Max 40MHz center channel in 2G band */
54
+
55
+#define CH_MIN_6G_CHANNEL 1u /* Min channel in 6G band */
56
+#define CH_MAX_6G_CHANNEL 233u /* Max channel in 6G band */
5057
5158 /* maximum # channels the s/w supports */
52
-#define MAXCHANNEL 224 /* max # supported channels. The max channel no is above,
53
- * this is that + 1 rounded up to a multiple of NBBY (8).
59
+#define MAXCHANNEL 240 /* max # supported channels. The max channel no is 233,
60
+ * this is that + 7 rounded up to a multiple of NBBY (8).
5461 * DO NOT MAKE it > 255: channels are uint8's all over
5562 */
56
-#define MAXCHANNEL_NUM (MAXCHANNEL - 1) /* max channel number */
63
+#define MAXCHANNEL_NUM (MAXCHANNEL - 7) /* max channel number */
64
+
65
+#define INVCHANNEL 255 /* error value for a bad channel */
5766
5867 /* channel bitvec */
5968 typedef struct {
....@@ -97,25 +106,27 @@
97106 #define WL_CHANSPEC_CTL_SB_UPPER WL_CHANSPEC_CTL_SB_LLU
98107 #define WL_CHANSPEC_CTL_SB_NONE WL_CHANSPEC_CTL_SB_LLL
99108
100
-#define WL_CHANSPEC_BW_MASK 0x3800
101
-#define WL_CHANSPEC_BW_SHIFT 11
102
-#define WL_CHANSPEC_BW_5 0x0000
103
-#define WL_CHANSPEC_BW_10 0x0800
104
-#define WL_CHANSPEC_BW_20 0x1000
105
-#define WL_CHANSPEC_BW_40 0x1800
106
-#define WL_CHANSPEC_BW_80 0x2000
107
-#define WL_CHANSPEC_BW_160 0x2800
108
-#define WL_CHANSPEC_BW_8080 0x3000
109
-#define WL_CHANSPEC_BW_2P5 0x3800
109
+#define WL_CHANSPEC_BW_MASK 0x3800u
110
+#define WL_CHANSPEC_BW_SHIFT 11u
111
+#define WL_CHANSPEC_BW_5 0x0000u
112
+#define WL_CHANSPEC_BW_10 0x0800u
113
+#define WL_CHANSPEC_BW_20 0x1000u
114
+#define WL_CHANSPEC_BW_40 0x1800u
115
+#define WL_CHANSPEC_BW_80 0x2000u
116
+#define WL_CHANSPEC_BW_160 0x2800u
117
+#define WL_CHANSPEC_BW_8080 0x3000u
110118
111
-#define WL_CHANSPEC_BAND_MASK 0xc000
112
-#define WL_CHANSPEC_BAND_SHIFT 14
113
-#define WL_CHANSPEC_BAND_2G 0x0000
114
-#define WL_CHANSPEC_BAND_3G 0x4000
115
-#define WL_CHANSPEC_BAND_4G 0x8000
116
-#define WL_CHANSPEC_BAND_5G 0xc000
117
-#define INVCHANSPEC 255
118
-#define MAX_CHANSPEC 0xFFFF
119
+#define WL_CHANSPEC_BAND_MASK 0xc000u
120
+#define WL_CHANSPEC_BAND_SHIFT 14u
121
+#define WL_CHANSPEC_BAND_2G 0x0000u
122
+#define WL_CHANSPEC_BAND_3G 0x4000u
123
+#define WL_CHANSPEC_BAND_6G 0x8000u
124
+#define WL_CHANSPEC_BAND_5G 0xc000u
125
+#define INVCHANSPEC 255u
126
+#define MAX_CHANSPEC 0xFFFFu
127
+
128
+#define WL_CHANNEL_BAND(ch) (((ch) <= CH_MAX_2G_CHANNEL) ? \
129
+ WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)
119130
120131 /* channel defines */
121132 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? \
....@@ -123,8 +134,9 @@
123134 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
124135 ((channel) + CH_10MHZ_APART) : 0)
125136
137
+/* pass a 80MHz channel number (uint8) to get respective LL, UU, LU, UL */
126138 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
127
-#define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
139
+#define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
128140 ((channel) + 3 * CH_10MHZ_APART) : 0)
129141 #define LU_20_SB(channel) LOWER_20_SB(channel)
130142 #define UL_20_SB(channel) UPPER_20_SB(channel)
....@@ -135,15 +147,6 @@
135147 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
136148 (((channel) <= CH_MAX_2G_CHANNEL) ? \
137149 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
138
-#define CH2P5MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_2P5 | \
139
- (((channel) <= CH_MAX_2G_CHANNEL) ? \
140
- WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
141
-#define CH5MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_5 | \
142
- (((channel) <= CH_MAX_2G_CHANNEL) ? \
143
- WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
144
-#define CH10MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_10 | \
145
- (((channel) <= CH_MAX_2G_CHANNEL) ? \
146
- WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
147150 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
148151 ((channel) + CH_20MHZ_APART) : 0)
149152 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
....@@ -156,16 +159,13 @@
156159 #define CH160MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
157160 ((channel) | (ctlsb) | \
158161 WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
159
-#define CHBW_CHSPEC(bw, channel) (chanspec_t)((chanspec_t)(channel) | (bw) | \
160
- (((channel) <= CH_MAX_2G_CHANNEL) ? \
161
- WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
162162
163163 /* simple MACROs to get different fields of chanspec */
164164 #ifdef WL11AC_80P80
165165 #define CHSPEC_CHANNEL(chspec) wf_chspec_channel(chspec)
166166 #else
167167 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
168
-#endif
168
+#endif // endif
169169 #define CHSPEC_CHAN1(chspec) ((chspec) & WL_CHANSPEC_CHAN1_MASK) >> WL_CHANSPEC_CHAN1_SHIFT
170170 #define CHSPEC_CHAN2(chspec) ((chspec) & WL_CHANSPEC_CHAN2_MASK) >> WL_CHANSPEC_CHAN2_SHIFT
171171 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
....@@ -173,68 +173,212 @@
173173 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
174174
175175 #ifdef WL11N_20MHZONLY
176
+#define CHSPEC_IS20(chspec) 1
177
+#define CHSPEC_IS20_2G(chspec) ((((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) && \
178
+ CHSPEC_IS2G(chspec))
179
+#ifndef CHSPEC_IS40
180
+#define CHSPEC_IS40(chspec) 0
181
+#endif // endif
182
+#ifndef CHSPEC_IS80
183
+#define CHSPEC_IS80(chspec) 0
184
+#endif // endif
185
+#ifndef CHSPEC_IS160
186
+#define CHSPEC_IS160(chspec) 0
187
+#endif // endif
188
+#ifndef CHSPEC_IS8080
189
+#define CHSPEC_IS8080(chspec) 0
190
+#endif // endif
176191
192
+/* see FOREACH_20_SB in !WL11N_20MHZONLY section */
193
+#define FOREACH_20_SB(chspec, channel) \
194
+ for (channel = CHSPEC_CHANNEL(chspec); channel; channel = 0)
195
+
196
+/* see GET_ALL_SB in !WL11N_20MHZONLY section */
197
+#define GET_ALL_SB(chspec, psb) do { \
198
+ psb[0] = CHSPEC_CHANNEL(chspec); \
199
+} while (0)
200
+
201
+#else /* !WL11N_20MHZONLY */
202
+
203
+#define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
204
+#define CHSPEC_IS20_5G(chspec) ((((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) && \
205
+ CHSPEC_IS5G(chspec))
206
+#ifndef CHSPEC_IS40
207
+#define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
208
+#endif // endif
209
+#ifndef CHSPEC_IS80
210
+#define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
211
+#endif // endif
212
+#ifndef CHSPEC_IS160
213
+#define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
214
+#endif // endif
215
+#ifndef CHSPEC_IS8080
216
+#define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
217
+#endif // endif
218
+
219
+/* pass a center channel and get channel offset from it by 10MHz */
220
+#define CH_OFF_10MHZ_MULTIPLES(channel, offset) ((uint8) (((offset) < 0) ? \
221
+ (((channel) > (WL_CHANSPEC_CHAN_MASK & ((uint16)((-(offset)) * CH_10MHZ_APART)))) ?\
222
+ ((channel) + (offset) * CH_10MHZ_APART) : 0) : \
223
+ (((channel) < (uint16)(MAXCHANNEL - (offset) * CH_10MHZ_APART)) ? \
224
+ ((channel) + (offset) * CH_10MHZ_APART) : 0)))
225
+
226
+#if defined(WL11AC_80P80) || defined(WL11AC_160)
227
+/* pass a 160MHz center channel to get 20MHz subband channel numbers */
228
+#define LLL_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, -7)
229
+#define LLU_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, -5)
230
+#define LUL_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, -3)
231
+#define LUU_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, -1)
232
+#define ULL_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, 1)
233
+#define ULU_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, 3)
234
+#define UUL_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, 5)
235
+#define UUU_20_SB_160(channel) CH_OFF_10MHZ_MULTIPLES(channel, 7)
236
+
237
+/* given an 80p80 channel, return the lower 80MHz sideband */
238
+#define LOWER_80_SB(chspec) (wf_chspec_primary80_channel(chspec) < \
239
+ wf_chspec_secondary80_channel(chspec) ? \
240
+ wf_chspec_primary80_channel(chspec) : wf_chspec_secondary80_channel(chspec))
241
+
242
+/* given an 80p80 channel, return the upper 80MHz sideband */
243
+#define UPPER_80_SB(chspec) (wf_chspec_primary80_channel(chspec) > \
244
+ wf_chspec_secondary80_channel(chspec) ? \
245
+ wf_chspec_primary80_channel(chspec) : wf_chspec_secondary80_channel(chspec))
246
+
247
+/* pass an 80P80 chanspec (not channel) to get 20MHz subnand channel numbers */
248
+#define LLL_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(LOWER_80_SB(chspec), -3)
249
+#define LLU_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(LOWER_80_SB(chspec), -1)
250
+#define LUL_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(LOWER_80_SB(chspec), 1)
251
+#define LUU_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(LOWER_80_SB(chspec), 3)
252
+#define ULL_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(UPPER_80_SB(chspec), -3)
253
+#define ULU_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(UPPER_80_SB(chspec), -1)
254
+#define UUL_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(UPPER_80_SB(chspec), 1)
255
+#define UUU_20_SB_8080(chspec) CH_OFF_10MHZ_MULTIPLES(UPPER_80_SB(chspec), 3)
256
+
257
+/* get lowest 20MHz sideband of a given chspec
258
+ * (works with 20, 40, 80, 160, 80p80)
259
+ */
260
+#define CH_FIRST_20_SB(chspec) ((uint8) (\
261
+ CHSPEC_IS160(chspec) ? LLL_20_SB_160(CHSPEC_CHANNEL(chspec)) : (\
262
+ CHSPEC_IS8080(chspec) ? LLL_20_SB_8080(chspec) : (\
263
+ CHSPEC_IS80(chspec) ? LL_20_SB(CHSPEC_CHANNEL(chspec)) : (\
264
+ CHSPEC_IS40(chspec) ? LOWER_20_SB(CHSPEC_CHANNEL(chspec)) : \
265
+ CHSPEC_CHANNEL(chspec))))))
266
+
267
+/* get upper most 20MHz sideband of a given chspec
268
+ * (works with 20, 40, 80, 160, 80p80)
269
+ */
270
+#define CH_LAST_20_SB(chspec) ((uint8) (\
271
+ CHSPEC_IS160(chspec) ? UUU_20_SB_160(CHSPEC_CHANNEL(chspec)) : (\
272
+ CHSPEC_IS8080(chspec) ? UUU_20_SB_8080(chspec) : (\
273
+ CHSPEC_IS80(chspec) ? UU_20_SB(CHSPEC_CHANNEL(chspec)) : (\
274
+ CHSPEC_IS40(chspec) ? UPPER_20_SB(CHSPEC_CHANNEL(chspec)) : \
275
+ CHSPEC_CHANNEL(chspec))))))
276
+
277
+/* call this with chspec and a valid 20MHz sideband of this channel to get the next 20MHz sideband
278
+ * (works with 80p80 only)
279
+ * resolves to 0 if called with upper most channel
280
+ */
281
+#define CH_NEXT_20_SB_IN_8080(chspec, channel) ((uint8) (\
282
+ ((uint8) ((channel) + CH_20MHZ_APART) > CH_LAST_20_SB(chspec) ? 0 : \
283
+ ((channel) == LUU_20_SB_8080(chspec) ? ULL_20_SB_8080(chspec) : \
284
+ (channel) + CH_20MHZ_APART))))
285
+
286
+/* call this with chspec and a valid 20MHz sideband of this channel to get the next 20MHz sideband
287
+ * (works with 20, 40, 80, 160, 80p80)
288
+ * resolves to 0 if called with upper most channel
289
+ */
290
+#define CH_NEXT_20_SB(chspec, channel) ((uint8) (\
291
+ (CHSPEC_IS8080(chspec) ? CH_NEXT_20_SB_IN_8080((chspec), (channel)) : \
292
+ ((uint8) ((channel) + CH_20MHZ_APART) > CH_LAST_20_SB(chspec) ? 0 : \
293
+ ((channel) + CH_20MHZ_APART)))))
294
+
295
+#else /* WL11AC_80P80, WL11AC_160 */
296
+
297
+#define LLL_20_SB_160(channel) 0
298
+#define LLU_20_SB_160(channel) 0
299
+#define LUL_20_SB_160(channel) 0
300
+#define LUU_20_SB_160(channel) 0
301
+#define ULL_20_SB_160(channel) 0
302
+#define ULU_20_SB_160(channel) 0
303
+#define UUL_20_SB_160(channel) 0
304
+#define UUU_20_SB_160(channel) 0
305
+
306
+#define LOWER_80_SB(chspec) 0
307
+
308
+#define UPPER_80_SB(chspec) 0
309
+
310
+#define LLL_20_SB_8080(chspec) 0
311
+#define LLU_20_SB_8080(chspec) 0
312
+#define LUL_20_SB_8080(chspec) 0
313
+#define LUU_20_SB_8080(chspec) 0
314
+#define ULL_20_SB_8080(chspec) 0
315
+#define ULU_20_SB_8080(chspec) 0
316
+#define UUL_20_SB_8080(chspec) 0
317
+#define UUU_20_SB_8080(chspec) 0
318
+
319
+/* get lowest 20MHz sideband of a given chspec
320
+ * (works with 20, 40, 80)
321
+ */
322
+#define CH_FIRST_20_SB(chspec) ((uint8) (\
323
+ CHSPEC_IS80(chspec) ? LL_20_SB(CHSPEC_CHANNEL(chspec)) : (\
324
+ CHSPEC_IS40(chspec) ? LOWER_20_SB(CHSPEC_CHANNEL(chspec)) : \
325
+ CHSPEC_CHANNEL(chspec))))
326
+/* get upper most 20MHz sideband of a given chspec
327
+ * (works with 20, 40, 80, 160, 80p80)
328
+ */
329
+#define CH_LAST_20_SB(chspec) ((uint8) (\
330
+ CHSPEC_IS80(chspec) ? UU_20_SB(CHSPEC_CHANNEL(chspec)) : (\
331
+ CHSPEC_IS40(chspec) ? UPPER_20_SB(CHSPEC_CHANNEL(chspec)) : \
332
+ CHSPEC_CHANNEL(chspec))))
333
+
334
+/* call this with chspec and a valid 20MHz sideband of this channel to get the next 20MHz sideband
335
+ * (works with 20, 40, 80, 160, 80p80)
336
+ * resolves to 0 if called with upper most channel
337
+ */
338
+#define CH_NEXT_20_SB(chspec, channel) ((uint8) (\
339
+ ((uint8) ((channel) + CH_20MHZ_APART) > CH_LAST_20_SB(chspec) ? 0 : \
340
+ ((channel) + CH_20MHZ_APART))))
341
+
342
+#endif /* WL11AC_80P80, WL11AC_160 */
343
+
344
+/* Iterator for 20MHz side bands of a chanspec: (chanspec_t chspec, uint8 channel)
345
+ * 'chspec' chanspec_t of interest (used in loop, better to pass a resolved value than a macro)
346
+ * 'channel' must be a variable (not an expression).
347
+ */
348
+#define FOREACH_20_SB(chspec, channel) \
349
+ for (channel = CH_FIRST_20_SB(chspec); channel; \
350
+ channel = CH_NEXT_20_SB((chspec), channel))
351
+
352
+/* Uses iterator to populate array with all side bands involved (sorted lower to upper).
353
+ * 'chspec' chanspec_t of interest
354
+ * 'psb' pointer to uint8 array of enough size to hold all side bands for the given chspec
355
+ */
356
+#define GET_ALL_SB(chspec, psb) do { \
357
+ uint8 channel, idx = 0; \
358
+ chanspec_t chspec_local = chspec; \
359
+ FOREACH_20_SB(chspec_local, channel) \
360
+ (psb)[idx++] = channel; \
361
+} while (0)
362
+
363
+/* given a chanspec of any bw, tests if primary20 SB is in lower 20, 40, 80 respectively */
364
+#define IS_CTL_IN_L20(chspec) !((chspec) & WL_CHANSPEC_CTL_SB_U) /* CTL SB is in low 20 of any 40 */
365
+#define IS_CTL_IN_L40(chspec) !((chspec) & WL_CHANSPEC_CTL_SB_UL) /* in low 40 of any 80 */
366
+#define IS_CTL_IN_L80(chspec) !((chspec) & WL_CHANSPEC_CTL_SB_ULL) /* in low 80 of 80p80/160 */
367
+
368
+#endif /* !WL11N_20MHZONLY */
369
+
370
+/* ULB introduced macros. Remove once ULB is cleaned from phy code */
177371 #define CHSPEC_IS2P5(chspec) 0
178372 #define CHSPEC_IS5(chspec) 0
179373 #define CHSPEC_IS10(chspec) 0
180
-#define CHSPEC_IS20(chspec) 1
181
-#ifndef CHSPEC_IS40
182
-#define CHSPEC_IS40(chspec) 0
183
-#endif
184
-#ifndef CHSPEC_IS80
185
-#define CHSPEC_IS80(chspec) 0
186
-#endif
187
-#ifndef CHSPEC_IS160
188
-#define CHSPEC_IS160(chspec) 0
189
-#endif
190
-#ifndef CHSPEC_IS8080
191
-#define CHSPEC_IS8080(chspec) 0
192
-#endif
193
-#define BW_LE20(bw) TRUE
194
-#define CHSPEC_ISLE20(chspec) TRUE
195
-#else /* !WL11N_20MHZONLY */
196
-
197
-#define CHSPEC_IS2P5(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_2P5)
198
-#define CHSPEC_IS5(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_5)
199
-#define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
200
-#define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
201
-#ifndef CHSPEC_IS40
202
-#define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
203
-#endif
204
-#ifndef CHSPEC_IS80
205
-#define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
206
-#endif
207
-#ifndef CHSPEC_IS160
208
-#define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
209
-#endif
210
-#ifndef CHSPEC_IS8080
211
-#define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
212
-#endif
213
-
214
-#ifdef WL11ULB
215
-#define BW_LT20(bw) (((bw) == WL_CHANSPEC_BW_2P5) || \
216
- ((bw) == WL_CHANSPEC_BW_5) || \
217
- ((bw) == WL_CHANSPEC_BW_10))
218
-#define CHSPEC_BW_LT20(chspec) (BW_LT20(CHSPEC_BW(chspec)))
219
-/* This MACRO is strictly to avoid abandons in existing code with ULB feature and is in no way
220
- * optimial to use. Should be replaced with CHSPEC_BW_LE() instead
221
- */
222
-#define BW_LE20(bw) (((bw) == WL_CHANSPEC_BW_2P5) || \
223
- ((bw) == WL_CHANSPEC_BW_5) || \
224
- ((bw) == WL_CHANSPEC_BW_10) || \
225
- ((bw) == WL_CHANSPEC_BW_20))
226
-#define CHSPEC_ISLE20(chspec) (BW_LE20(CHSPEC_BW(chspec)))
227
-
228
-#else /* WL11ULB */
229
-#define BW_LE20(bw) ((bw) == WL_CHANSPEC_BW_20)
230374 #define CHSPEC_ISLE20(chspec) (CHSPEC_IS20(chspec))
231
-#endif /* WL11ULB */
232
-#endif /* !WL11N_20MHZONLY */
375
+#define CHSPEC_BW_LE20(chspec) (CHSPEC_IS20(chspec))
233376
234
-#define BW_LE40(bw) (BW_LE20(bw) || ((bw) == WL_CHANSPEC_BW_40))
377
+#define BW_LE40(bw) ((bw) == WL_CHANSPEC_BW_20 || ((bw) == WL_CHANSPEC_BW_40))
235378 #define BW_LE80(bw) (BW_LE40(bw) || ((bw) == WL_CHANSPEC_BW_80))
236379 #define BW_LE160(bw) (BW_LE80(bw) || ((bw) == WL_CHANSPEC_BW_160))
237
-#define CHSPEC_BW_LE20(chspec) (BW_LE20(CHSPEC_BW(chspec)))
380
+
381
+#define CHSPEC_IS6G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_6G)
238382 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
239383 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
240384 #define CHSPEC_SB_UPPER(chspec) \
....@@ -250,6 +394,11 @@
250394 */
251395 #define CHANSPEC_STR_LEN 20
252396
397
+/*
398
+ * This function returns TRUE if both the chanspec can co-exist in PHY.
399
+ * Addition to primary20 channel, the function checks for side band for 2g 40 channels
400
+ */
401
+extern bool wf_chspec_coexist(chanspec_t chspec1, chanspec_t chspec2);
253402
254403 #define CHSPEC_IS_BW_160_WIDE(chspec) (CHSPEC_BW(chspec) == WL_CHANSPEC_BW_160 ||\
255404 CHSPEC_BW(chspec) == WL_CHANSPEC_BW_8080)
....@@ -261,57 +410,25 @@
261410 * The LT/LE/GT/GE macros check first checks whether both chspec bandwidth and bw are 160 wide.
262411 * If both chspec bandwidth and bw is not 160 wide, then the comparison is made.
263412 */
264
-#ifdef WL11ULB
265
-#define CHSPEC_BW_GE(chspec, bw) \
266
- (((CHSPEC_IS_BW_160_WIDE(chspec) &&\
267
- ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) ||\
268
- (CHSPEC_BW(chspec) >= (bw))) && \
269
- (!(CHSPEC_BW(chspec) == WL_CHANSPEC_BW_2P5 && (bw) != WL_CHANSPEC_BW_2P5)))
270
-#else /* WL11ULB */
271413 #define CHSPEC_BW_GE(chspec, bw) \
272414 ((CHSPEC_IS_BW_160_WIDE(chspec) &&\
273415 ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) ||\
274416 (CHSPEC_BW(chspec) >= (bw)))
275
-#endif /* WL11ULB */
276417
277
-#ifdef WL11ULB
278
-#define CHSPEC_BW_LE(chspec, bw) \
279
- (((CHSPEC_IS_BW_160_WIDE(chspec) &&\
280
- ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) ||\
281
- (CHSPEC_BW(chspec) <= (bw))) || \
282
- (CHSPEC_BW(chspec) == WL_CHANSPEC_BW_2P5))
283
-#else /* WL11ULB */
284418 #define CHSPEC_BW_LE(chspec, bw) \
285419 ((CHSPEC_IS_BW_160_WIDE(chspec) &&\
286420 ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) ||\
287421 (CHSPEC_BW(chspec) <= (bw)))
288
-#endif /* WL11ULB */
289422
290
-#ifdef WL11ULB
291
-#define CHSPEC_BW_GT(chspec, bw) \
292
- ((!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
293
- ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) &&\
294
- (CHSPEC_BW(chspec) > (bw))) && \
295
- (CHSPEC_BW(chspec) != WL_CHANSPEC_BW_2P5))
296
-#else /* WL11ULB */
297423 #define CHSPEC_BW_GT(chspec, bw) \
298424 (!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
299425 ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) &&\
300426 (CHSPEC_BW(chspec) > (bw)))
301
-#endif /* WL11ULB */
302427
303
-#ifdef WL11ULB
304
-#define CHSPEC_BW_LT(chspec, bw) \
305
- ((!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
306
- ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) &&\
307
- (CHSPEC_BW(chspec) < (bw))) || \
308
- ((CHSPEC_BW(chspec) == WL_CHANSPEC_BW_2P5 && (bw) != WL_CHANSPEC_BW_2P5)))
309
-#else /* WL11ULB */
310428 #define CHSPEC_BW_LT(chspec, bw) \
311429 (!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
312430 ((bw) == WL_CHANSPEC_BW_160 || (bw) == WL_CHANSPEC_BW_8080)) &&\
313431 (CHSPEC_BW(chspec) < (bw)))
314
-#endif /* WL11ULB */
315432
316433 /* Legacy Chanspec defines
317434 * These are the defines for the previous format of the chanspec_t
....@@ -360,6 +477,8 @@
360477 WL_LCHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
361478 WL_LCHANSPEC_BAND_2G : WL_LCHANSPEC_BAND_5G))
362479
480
+#define GET_ALL_EXT wf_get_all_ext
481
+
363482 /*
364483 * WF_CHAN_FACTOR_* constants are used to calculate channel frequency
365484 * given a channel number.
....@@ -387,12 +506,28 @@
387506 #define WLC_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
388507
389508 /**
509
+ * Starting frequence of 6 GHz channels.
510
+ * Wi-Fi 6E operates in the 6 GHz band from 5.925 to 7.125 GHz.
511
+ */
512
+#define FREQ_START_6G_CHANNEL 5925 /* 6G band starting frequence */
513
+
514
+/**
390515 * No of sub-band vlaue of the specified Mhz chanspec
391516 */
392517 #define WF_NUM_SIDEBANDS_40MHZ 2
393518 #define WF_NUM_SIDEBANDS_80MHZ 4
394519 #define WF_NUM_SIDEBANDS_8080MHZ 4
395520 #define WF_NUM_SIDEBANDS_160MHZ 8
521
+
522
+/**
523
+ * Return the chanspec bandwidth in MHz
524
+ * Bandwidth of 160 MHz will be returned for 80+80MHz chanspecs.
525
+ *
526
+ * @param chspec chanspec_t
527
+ *
528
+ * @return bandwidth of chspec in MHz units
529
+ */
530
+extern uint wf_bw_chspec_to_mhz(chanspec_t chspec);
396531
397532 /**
398533 * Convert chanspec to ascii string
....@@ -430,10 +565,20 @@
430565 extern chanspec_t wf_chspec_aton(const char *a);
431566
432567 /**
568
+ * Convert ascii string to chanspec
569
+ *
570
+ * @param a pointer to chanspec input string
571
+ * @param default_bw default bandwidth to use if not specified in chanspec input string
572
+ *
573
+ * @return >= 0 if successful or 0 otherwise
574
+ */
575
+extern chanspec_t wf_chspec_aton_ex(const char *a, const uint default_bw);
576
+
577
+/**
433578 * Verify the chanspec fields are valid.
434579 *
435580 * Verify the chanspec is using a legal set field values, i.e. that the chanspec
436
- * specified a band, bw, ctl_sb and channel and that the combination could be
581
+ * specified a band, bw, primary_sb, and channel and that the combination could be
437582 * legal given some set of circumstances.
438583 *
439584 * @param chanspec input chanspec to verify
....@@ -452,7 +597,7 @@
452597 extern bool wf_chspec_valid(chanspec_t chanspec);
453598
454599 /**
455
- * Return the primary (control) channel.
600
+ * Return the primary 20MHz channel.
456601 *
457602 * This function returns the channel number of the primary 20MHz channel. For
458603 * 20MHz channels this is just the channel number. For 40MHz or wider channels
....@@ -462,21 +607,30 @@
462607 *
463608 * @return Returns the channel number of the primary 20MHz channel
464609 */
465
-extern uint8 wf_chspec_ctlchan(chanspec_t chspec);
610
+extern uint8 wf_chspec_primary20_chan(chanspec_t chspec);
466611
467
-/*
612
+/* alias for old function name */
613
+#define wf_chspec_ctlchan(c) wf_chspec_primary20_chan(c)
614
+
615
+/**
468616 * Return the bandwidth string.
469617 *
470618 * This function returns the bandwidth string for the passed chanspec.
471619 *
472620 * @param chspec input chanspec
473621 *
474
- * @return Returns the bandwidth string
622
+ * @return Returns the bandwidth string:
623
+ * "5", "10", "20", "40", "80", "160", "80+80"
475624 */
476
-extern char * wf_chspec_to_bw_str(chanspec_t chspec);
625
+extern const char *wf_chspec_to_bw_str(chanspec_t chspec);
477626
478627 /**
479
- * Return the primary (control) chanspec.
628
+ * Create a 20MHz chanspec for the given band.
629
+ */
630
+chanspec_t wf_create_20MHz_chspec(uint channel, chanspec_band_t band);
631
+
632
+/**
633
+ * Return the primary 20MHz chanspec.
480634 *
481635 * This function returns the chanspec of the primary 20MHz channel. For 20MHz
482636 * channels this is just the chanspec. For 40MHz or wider channels it is the
....@@ -486,14 +640,17 @@
486640 *
487641 * @return Returns the chanspec of the primary 20MHz channel
488642 */
489
-extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
643
+extern chanspec_t wf_chspec_primary20_chspec(chanspec_t chspec);
644
+
645
+/* alias for old function name */
646
+#define wf_chspec_ctlchspec(c) wf_chspec_primary20_chspec(c)
490647
491648 /**
492
- * Return a channel number corresponding to a frequency.
649
+ * Return the primary 40MHz chanspec.
493650 *
494
- * This function returns the chanspec for the primary 40MHz of an 80MHz channel.
495
- * The control sideband specifies the same 20MHz channel that the 80MHz channel is using
496
- * as the primary 20MHz channel.
651
+ * This function returns the chanspec for the primary 40MHz of an 80MHz or wider channel.
652
+ * The primary 20MHz channel of the returned 40MHz chanspec is the same as the primary 20MHz
653
+ * channel of the input chanspec.
497654 */
498655 extern chanspec_t wf_chspec_primary40_chspec(chanspec_t chspec);
499656
....@@ -514,7 +671,7 @@
514671 * frequency is not a 2.4 GHz channel, or if the frequency is not and even
515672 * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
516673 *
517
- * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
674
+ * Reference 802.11-2016, section 17.3.8.3 and section 16.3.6.3
518675 *
519676 * @param freq frequency in MHz
520677 * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
....@@ -542,7 +699,7 @@
542699 * the answer is rounded down to an integral MHz.
543700 * -1 is returned for an out of range channel.
544701 *
545
- * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
702
+ * Reference 802.11-2016, section 17.3.8.3 and section 16.3.6.3
546703 *
547704 * @param channel input channel number
548705 * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
....@@ -594,33 +751,61 @@
594751 *
595752 * Returns INVCHANSPEC in case of error.
596753 *
597
- * Refer to IEEE802.11ac section 22.3.14 "Channelization".
754
+ * Refer to 802.11-2016 section 22.3.14 "Channelization".
598755 */
599756 extern chanspec_t wf_chspec_get8080_chspec(uint8 primary_20mhz,
600757 uint8 chan0_80Mhz, uint8 chan1_80Mhz);
601758
602
-/*
603
- * Returns the primary 80 Mhz channel for the provided chanspec
759
+/**
760
+ * Returns the center channel of the primary 80 MHz sub-band of the provided chanspec
604761 *
605
- * chanspec - Input chanspec for which the 80MHz primary channel has to be retrieved
762
+ * @param chspec input chanspec
606763 *
607
- * returns -1 in case the provided channel is 20/40 Mhz chanspec
764
+ * @return center channel number of the primary 80MHz sub-band of the input.
765
+ * Will return the center channel of an input 80MHz chspec.
766
+ * Will return INVCHANNEL if the chspec is malformed or less than 80MHz bw.
608767 */
609768 extern uint8 wf_chspec_primary80_channel(chanspec_t chanspec);
610769
611
-/*
612
- * Returns the secondary 80 Mhz channel for the provided chanspec
770
+/**
771
+ * Returns the center channel of the secondary 80 MHz sub-band of the provided chanspec
613772 *
614
- * chanspec - Input chanspec for which the 80MHz secondary channel has to be retrieved
773
+ * @param chspec input chanspec
615774 *
616
- * returns -1 in case the provided channel is 20/40 Mhz chanspec
775
+ * @return center channel number of the secondary 80MHz sub-band of the input.
776
+ * Will return INVCHANNEL if the chspec is malformed or bw is not greater than 80MHz.
617777 */
618778 extern uint8 wf_chspec_secondary80_channel(chanspec_t chanspec);
619779
620
-/*
621
- * This function returns the chanspec for the primary 80MHz of an 160MHz or 80+80 channel.
780
+/**
781
+ * Returns the chanspec for the primary 80MHz sub-band of an 160MHz or 80+80 channel
782
+ *
783
+ * @param chspec input chanspec
784
+ *
785
+ * @return An 80MHz chanspec describing the primary 80MHz sub-band of the input.
786
+ * Will return an input 80MHz chspec as is.
787
+ * Will return INVCHANSPEC if the chspec is malformed or less than 80MHz bw.
622788 */
623789 extern chanspec_t wf_chspec_primary80_chspec(chanspec_t chspec);
790
+
791
+/**
792
+ * Returns the chanspec for the secondary 80MHz sub-band of an 160MHz or 80+80 channel
793
+ * The sideband in the chanspec is always set to WL_CHANSPEC_CTL_SB_LL since this sub-band
794
+ * does not contain the primary 20MHz channel.
795
+ *
796
+ * @param chspec input chanspec
797
+ *
798
+ * @return An 80MHz chanspec describing the secondary 80MHz sub-band of the input.
799
+ * Will return INVCHANSPEC if the chspec is malformed or bw is not greater than 80MHz.
800
+ */
801
+extern chanspec_t wf_chspec_secondary80_chspec(chanspec_t chspec);
802
+
803
+/*
804
+ * For 160MHz or 80P80 chanspec, set ch[0]/ch[1] to be the low/high 80 Mhz channels
805
+ *
806
+ * For 20/40/80MHz chanspec, set ch[0] to be the center freq, and chan[1]=-1
807
+ */
808
+extern void wf_chspec_get_80p80_channels(chanspec_t chspec, uint8 *ch);
624809
625810 #ifdef WL11AC_80P80
626811 /*
....@@ -628,37 +813,25 @@
628813 * In case of 80+80 chanspec it returns the primary 80 Mhz centre channel
629814 */
630815 extern uint8 wf_chspec_channel(chanspec_t chspec);
631
-#endif
816
+#endif // endif
817
+extern chanspec_t wf_channel_create_chspec_frm_opclass(uint8 opclass, uint8 channel);
818
+extern int wf_channel_create_opclass_frm_chspec(chanspec_t chspec);
632819
633
-#ifdef WL_OLDPPR
634
-#define WL_CHANSPEC_CTL_SB_MASK_OLD 0x0300
635
-#define WL_CHANSPEC_CTL_SB_SHIFT_OLD 8
636
-#define WL_CHANSPEC_CTL_SB_LOWER_OLD 0x0100
637
-#define WL_CHANSPEC_CTL_SB_UPPER_OLD 0x0200
638
-#define WL_CHANSPEC_CTL_SB_NONE_OLD 0x0300
820
+/* Populates array with all 20MHz side bands of a given chanspec_t in the following order:
821
+ * primary20, ext20, two ext40s, four ext80s.
822
+ * 'chspec' is the chanspec of interest
823
+ * 'pext' must point to an uint8 array of long enough to hold all side bands of the given chspec
824
+ *
825
+ * Works with 20, 40, 80, 80p80 and 160MHz chspec
826
+ */
639827
640
-#define WL_CHANSPEC_BW_MASK_OLD 0x0C00
641
-#define WL_CHANSPEC_BW_SHIFT_OLD 10
642
-#define WL_CHANSPEC_BW_10_OLD 0x0400
643
-#define WL_CHANSPEC_BW_20_OLD 0x0800
644
-#define WL_CHANSPEC_BW_40_OLD 0x0C00
828
+extern void wf_get_all_ext(chanspec_t chspec, uint8 *chan_ptr);
645829
646
-#define WL_CHANSPEC_BAND_MASK_OLD 0xf000
647
-#define WL_CHANSPEC_BAND_SHIFT_OLD 12
648
-#define WL_CHANSPEC_BAND_5G_OLD 0x1000
649
-#define WL_CHANSPEC_BAND_2G_OLD 0x2000
830
+/*
831
+ * Given two chanspecs, returns true if they overlap.
832
+ * (Overlap: At least one 20MHz subband is common between the two chanspecs provided)
833
+ */
834
+extern bool wf_chspec_overlap(chanspec_t chspec0, chanspec_t chspec1);
650835
651
-#define CHSPEC_CHANNEL_OLD(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
652
-#define CHSPEC_BAND_OLD(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK_OLD)
653
-
654
-#define CHSPEC_IS10_OLD(chspec) (((chspec) & WL_CHANSPEC_BW_MASK_OLD) == WL_CHANSPEC_BW_10_OLD)
655
-#define CHSPEC_IS20_OLD(chspec) (((chspec) & WL_CHANSPEC_BW_MASK_OLD) == WL_CHANSPEC_BW_20_OLD)
656
-#define CHSPEC_IS40_OLD(chspec) (((chspec) & WL_CHANSPEC_BW_MASK_OLD) == WL_CHANSPEC_BW_40_OLD)
657
-#define CHSPEC_IS5G_OLD(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK_OLD) == WL_CHANSPEC_BAND_5G_OLD)
658
-#define CHSPEC_IS2G_OLD(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK_OLD) == WL_CHANSPEC_BAND_2G_OLD)
659
-#define CHSPEC_SB_NONE_OLD(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK_OLD) == WL_CHANSPEC_CTL_SB_NONE_OLD)
660
-#define CHSPEC_SB_UPPER_OLD(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK_OLD) == WL_CHANSPEC_CTL_SB_UPPER_OLD)
661
-#define CHSPEC_SB_LOWER_OLD(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK_OLD) == WL_CHANSPEC_CTL_SB_LOWER_OLD)
662
-#endif /* WL_OLDPPR */
663
-
836
+extern uint8 channel_bw_to_width(chanspec_t chspec);
664837 #endif /* _bcmwifi_channels_h_ */