2 * Misc utility routines for WL and Apps
3 * This header file housing the define and function prototype use by
4 * both the wl driver, tools & Apps.
6 * Copyright (C) 1999-2011, Broadcom Corporation
8 * Unless you and Broadcom execute a separate written software license
9 * agreement governing use of this software, this software is licensed to you
10 * under the terms of the GNU General Public License version 2 (the "GPL"),
11 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12 * following added to such license:
14 * As a special exception, the copyright holders of this software give you
15 * permission to link this software with independent modules, and to copy and
16 * distribute the resulting executable under terms of your choice, provided that
17 * you also meet, for each linked independent module, the terms and conditions of
18 * the license of that module. An independent module is a module which is not
19 * derived from this software. The special exception does not apply to any
20 * modifications of the software.
22 * Notwithstanding the above, under no circumstances may you combine this
23 * software in any way with any other Broadcom software provided under a license
24 * other than the GPL, without Broadcom's express prior written consent.
26 * $Id: bcmwifi.h 300516 2011-12-04 17:39:44Z $
29 #ifndef _bcmwifi_channels_h_
30 #define _bcmwifi_channels_h_
32 typedef uint16 chanspec_t;
35 #define CH_UPPER_SB 0x01
36 #define CH_LOWER_SB 0x02
37 #define CH_EWA_VALID 0x04
38 #define CH_80MHZ_APART 16
39 #define CH_40MHZ_APART 8
40 #define CH_20MHZ_APART 4
41 #define CH_10MHZ_APART 2
42 #define CH_5MHZ_APART 1
43 #define CH_MAX_2G_CHANNEL 14
44 #define MAXCHANNEL 224
45 #define CHSPEC_CTLOVLP(sp1, sp2, sep) ABS(wf_chspec_ctlchan(sp1) - wf_chspec_ctlchan(sp2)) < (sep)
49 #define WL_CHANSPEC_CHAN_MASK 0x00ff
50 #define WL_CHANSPEC_CHAN_SHIFT 0
52 #define WL_CHANSPEC_CTL_SB_MASK 0x0300
53 #define WL_CHANSPEC_CTL_SB_SHIFT 8
54 #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
55 #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
56 #define WL_CHANSPEC_CTL_SB_NONE 0x0300
58 #define WL_CHANSPEC_BW_MASK 0x0C00
59 #define WL_CHANSPEC_BW_SHIFT 10
60 #define WL_CHANSPEC_BW_10 0x0400
61 #define WL_CHANSPEC_BW_20 0x0800
62 #define WL_CHANSPEC_BW_40 0x0C00
64 #define WL_CHANSPEC_BAND_MASK 0xf000
65 #define WL_CHANSPEC_BAND_SHIFT 12
66 #define WL_CHANSPEC_BAND_5G 0x1000
67 #define WL_CHANSPEC_BAND_2G 0x2000
68 #define INVCHANSPEC 255
70 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0)
71 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
72 ((channel) + CH_10MHZ_APART) : 0)
73 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
74 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
75 WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
76 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
77 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
78 ((channel) + CH_20MHZ_APART) : 0)
79 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
80 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
81 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
83 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
84 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
87 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
88 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
90 #ifdef WL11N_20MHZONLY
92 #define CHSPEC_IS10(chspec) 0
93 #define CHSPEC_IS20(chspec) 1
95 #define CHSPEC_IS40(chspec) 0
100 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
101 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
103 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
106 #endif /* WL11N_20MHZONLY */
108 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
109 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
110 #define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
111 #define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
112 #define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
113 #define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \
114 (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
115 (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))))
116 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
118 #define CHANSPEC_STR_LEN 8
122 #define WL_CHANSPEC_CHAN_MASK 0x00ff
123 #define WL_CHANSPEC_CHAN_SHIFT 0
124 #define WL_CHANSPEC_CHAN1_MASK 0x000f
125 #define WL_CHANSPEC_CHAN1_SHIFT 0
126 #define WL_CHANSPEC_CHAN2_MASK 0x00f0
127 #define WL_CHANSPEC_CHAN2_SHIFT 4
129 #define WL_CHANSPEC_CTL_SB_MASK 0x0700
130 #define WL_CHANSPEC_CTL_SB_SHIFT 8
131 #define WL_CHANSPEC_CTL_SB_LLL 0x0000
132 #define WL_CHANSPEC_CTL_SB_LLU 0x0100
133 #define WL_CHANSPEC_CTL_SB_LUL 0x0200
134 #define WL_CHANSPEC_CTL_SB_LUU 0x0300
135 #define WL_CHANSPEC_CTL_SB_ULL 0x0400
136 #define WL_CHANSPEC_CTL_SB_ULU 0x0500
137 #define WL_CHANSPEC_CTL_SB_UUL 0x0600
138 #define WL_CHANSPEC_CTL_SB_UUU 0x0700
139 #define WL_CHANSPEC_CTL_SB_LL WL_CHANSPEC_CTL_SB_LLL
140 #define WL_CHANSPEC_CTL_SB_LU WL_CHANSPEC_CTL_SB_LLU
141 #define WL_CHANSPEC_CTL_SB_UL WL_CHANSPEC_CTL_SB_LUL
142 #define WL_CHANSPEC_CTL_SB_UU WL_CHANSPEC_CTL_SB_LUU
143 #define WL_CHANSPEC_CTL_SB_L WL_CHANSPEC_CTL_SB_LLL
144 #define WL_CHANSPEC_CTL_SB_U WL_CHANSPEC_CTL_SB_LLU
145 #define WL_CHANSPEC_CTL_SB_LOWER WL_CHANSPEC_CTL_SB_LLL
146 #define WL_CHANSPEC_CTL_SB_UPPER WL_CHANSPEC_CTL_SB_LLU
148 #define WL_CHANSPEC_BW_MASK 0x3800
149 #define WL_CHANSPEC_BW_SHIFT 11
150 #define WL_CHANSPEC_BW_5 0x0000
151 #define WL_CHANSPEC_BW_10 0x0800
152 #define WL_CHANSPEC_BW_20 0x1000
153 #define WL_CHANSPEC_BW_40 0x1800
154 #define WL_CHANSPEC_BW_80 0x2000
155 #define WL_CHANSPEC_BW_160 0x2800
156 #define WL_CHANSPEC_BW_8080 0x3000
158 #define WL_CHANSPEC_BAND_MASK 0xc000
159 #define WL_CHANSPEC_BAND_SHIFT 14
160 #define WL_CHANSPEC_BAND_2G 0x0000
161 #define WL_CHANSPEC_BAND_3G 0x4000
162 #define WL_CHANSPEC_BAND_4G 0x8000
163 #define WL_CHANSPEC_BAND_5G 0xc000
164 #define INVCHANSPEC 255
166 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? \
167 ((channel) - CH_10MHZ_APART) : 0)
168 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
169 ((channel) + CH_10MHZ_APART) : 0)
170 #define LOWER_40_SB(channel) ((channel) - CH_20MHZ_APART)
171 #define UPPER_40_SB(channel) ((channel) + CH_20MHZ_APART)
172 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
173 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
174 (((channel) <= CH_MAX_2G_CHANNEL) ? \
175 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
176 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
177 ((channel) + CH_20MHZ_APART) : 0)
178 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
179 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
180 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
181 WL_CHANSPEC_BAND_5G))
182 #define CH80MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
183 ((channel) | (ctlsb) | \
184 WL_CHANSPEC_BW_80 | WL_CHANSPEC_BAND_5G)
185 #define CH160MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
186 ((channel) | (ctlsb) | \
187 WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
190 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
191 #define CHSPEC_CHAN1(chspec) ((chspec) & WL_CHANSPEC_CHAN1_MASK)
192 #define CHSPEC_CHAN2(chspec) ((chspec) & WL_CHANSPEC_CHAN2_MASK)
193 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
194 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
195 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
197 #ifdef WL11N_20MHZONLY
199 #define CHSPEC_IS10(chspec) 0
200 #define CHSPEC_IS20(chspec) 1
202 #define CHSPEC_IS40(chspec) 0
205 #define CHSPEC_IS80(chspec) 0
208 #define CHSPEC_IS160(chspec) 0
210 #ifndef CHSPEC_IS8080
211 #define CHSPEC_IS8080(chspec) 0
216 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
217 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
219 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
222 #define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
225 #define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
227 #ifndef CHSPEC_IS8080
228 #define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
231 #endif /* WL11N_20MHZONLY */
233 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
234 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
235 #define CHSPEC_SB_UPPER(chspec) \
236 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) && \
237 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
238 #define CHSPEC_SB_LOWER(chspec) \
239 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) && \
240 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
241 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
244 #define CHANSPEC_STR_LEN 20
246 #define WL_LCHANSPEC_CHAN_MASK 0x00ff
247 #define WL_LCHANSPEC_CHAN_SHIFT 0
249 #define WL_LCHANSPEC_CTL_SB_MASK 0x0300
250 #define WL_LCHANSPEC_CTL_SB_SHIFT 8
251 #define WL_LCHANSPEC_CTL_SB_LOWER 0x0100
252 #define WL_LCHANSPEC_CTL_SB_UPPER 0x0200
253 #define WL_LCHANSPEC_CTL_SB_NONE 0x0300
255 #define WL_LCHANSPEC_BW_MASK 0x0C00
256 #define WL_LCHANSPEC_BW_SHIFT 10
257 #define WL_LCHANSPEC_BW_10 0x0400
258 #define WL_LCHANSPEC_BW_20 0x0800
259 #define WL_LCHANSPEC_BW_40 0x0C00
261 #define WL_LCHANSPEC_BAND_MASK 0xf000
262 #define WL_LCHANSPEC_BAND_SHIFT 12
263 #define WL_LCHANSPEC_BAND_5G 0x1000
264 #define WL_LCHANSPEC_BAND_2G 0x2000
266 #define LCHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_LCHANSPEC_CHAN_MASK))
267 #define LCHSPEC_BAND(chspec) ((chspec) & WL_LCHANSPEC_BAND_MASK)
268 #define LCHSPEC_CTL_SB(chspec) ((chspec) & WL_LCHANSPEC_CTL_SB_MASK)
269 #define LCHSPEC_BW(chspec) ((chspec) & WL_LCHANSPEC_BW_MASK)
270 #define LCHSPEC_IS10(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_10)
271 #define LCHSPEC_IS20(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_20)
272 #define LCHSPEC_IS40(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40)
273 #define LCHSPEC_IS5G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_5G)
274 #define LCHSPEC_IS2G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_2G)
276 #define LCHSPEC_CREATE(chan, band, bw, sb) ((uint16)((chan) | (sb) | (bw) | (band)))
278 #endif /* D11AC_IOTYPES */
280 #define WF_CHAN_FACTOR_2_4_G 4814
281 #define WF_CHAN_FACTOR_5_G 10000
282 #define WF_CHAN_FACTOR_4_G 8000
285 #define WLC_MAXRATE 108
286 #define WLC_RATE_1M 2
287 #define WLC_RATE_2M 4
288 #define WLC_RATE_5M5 11
289 #define WLC_RATE_11M 22
290 #define WLC_RATE_6M 12
291 #define WLC_RATE_9M 18
292 #define WLC_RATE_12M 24
293 #define WLC_RATE_18M 36
294 #define WLC_RATE_24M 48
295 #define WLC_RATE_36M 72
296 #define WLC_RATE_48M 96
297 #define WLC_RATE_54M 108
299 #define WLC_2G_25MHZ_OFFSET 5
302 extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf);
305 extern chanspec_t wf_chspec_aton(const char *a);
308 extern bool wf_chspec_malformed(chanspec_t chanspec);
311 extern bool wf_chspec_valid(chanspec_t chanspec);
314 extern uint8 wf_chspec_ctlchan(chanspec_t chspec);
317 extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
320 extern chanspec_t wf_chspec_primary40_chspec(chanspec_t chspec);
323 extern int wf_mhz2channel(uint freq, uint start_factor);
326 extern int wf_channel2mhz(uint channel, uint start_factor);
328 #endif /* _bcmwifi_h_ */