GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / shared / bcmwifi / include / bcmwifi_channels.h
blobe8034474215ebbe3cb95016ac6602fdd7ef5d77a
1 /*
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) 2012, Broadcom Corporation. All Rights Reserved.
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
17 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * $Id: bcmwifi_channels.h 309193 2012-01-19 00:03:57Z $
23 #ifndef _bcmwifi_channels_h_
24 #define _bcmwifi_channels_h_
27 /* A chanspec holds the channel number, band, bandwidth and control sideband */
28 typedef uint16 chanspec_t;
30 /* channel defines */
31 #define CH_UPPER_SB 0x01
32 #define CH_LOWER_SB 0x02
33 #define CH_EWA_VALID 0x04
34 #define CH_80MHZ_APART 16
35 #define CH_40MHZ_APART 8
36 #define CH_20MHZ_APART 4
37 #define CH_10MHZ_APART 2
38 #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
39 #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
40 #define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216,
41 * this is that + 1 rounded up to a multiple of NBBY (8).
42 * DO NOT MAKE it > 255: channels are uint8's all over
44 #define CHSPEC_CTLOVLP(sp1, sp2, sep) ABS(wf_chspec_ctlchan(sp1) - wf_chspec_ctlchan(sp2)) < (sep)
46 /* All builds use the new 11ac ratespec/chanspec */
47 #undef D11AC_IOTYPES
48 #define D11AC_IOTYPES
50 #ifndef D11AC_IOTYPES
52 #define WL_CHANSPEC_CHAN_MASK 0x00ff
53 #define WL_CHANSPEC_CHAN_SHIFT 0
55 #define WL_CHANSPEC_CTL_SB_MASK 0x0300
56 #define WL_CHANSPEC_CTL_SB_SHIFT 8
57 #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
58 #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
59 #define WL_CHANSPEC_CTL_SB_NONE 0x0300
61 #define WL_CHANSPEC_BW_MASK 0x0C00
62 #define WL_CHANSPEC_BW_SHIFT 10
63 #define WL_CHANSPEC_BW_10 0x0400
64 #define WL_CHANSPEC_BW_20 0x0800
65 #define WL_CHANSPEC_BW_40 0x0C00
67 #define WL_CHANSPEC_BAND_MASK 0xf000
68 #define WL_CHANSPEC_BAND_SHIFT 12
69 #ifdef WL_CHANSPEC_BAND_5G
70 #undef WL_CHANSPEC_BAND_5G
71 #endif
72 #ifdef WL_CHANSPEC_BAND_2G
73 #undef WL_CHANSPEC_BAND_2G
74 #endif
75 #define WL_CHANSPEC_BAND_5G 0x1000
76 #define WL_CHANSPEC_BAND_2G 0x2000
77 #define INVCHANSPEC 255
79 /* channel defines */
80 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0)
81 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
82 ((channel) + CH_10MHZ_APART) : 0)
84 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
85 #define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
86 ((channel) + 3 * CH_10MHZ_APART) : 0)
87 #define LU_20_SB(channel) LOWER_20_SB(channel)
88 #define UL_20_SB(channel) UPPER_20_SB(channel)
90 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
91 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
92 WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
93 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
94 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
95 ((channel) + CH_20MHZ_APART) : 0)
96 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
97 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
98 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
99 WL_CHANSPEC_BAND_5G))
100 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
101 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
103 /* chanspec stores radio channel & flags to indicate control channel location, i.e. upper/lower */
104 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
105 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
107 #ifdef WL11N_20MHZONLY
109 #define CHSPEC_IS10(chspec) 0
110 #define CHSPEC_IS20(chspec) 1
111 #ifndef CHSPEC_IS40
112 #define CHSPEC_IS40(chspec) 0
113 #endif
115 #else /* !WL11N_20MHZONLY */
117 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
118 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
119 #ifndef CHSPEC_IS40
120 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
121 #endif
123 #endif /* !WL11N_20MHZONLY */
125 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
126 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
127 #define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
128 #define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
129 #define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
130 #define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \
131 (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
132 (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))))
133 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
135 #define CHANSPEC_STR_LEN 8
137 #else /* D11AC_IOTYPES */
139 #define WL_CHANSPEC_CHAN_MASK 0x00ff
140 #define WL_CHANSPEC_CHAN_SHIFT 0
141 #define WL_CHANSPEC_CHAN1_MASK 0x000f
142 #define WL_CHANSPEC_CHAN1_SHIFT 0
143 #define WL_CHANSPEC_CHAN2_MASK 0x00f0
144 #define WL_CHANSPEC_CHAN2_SHIFT 4
146 #define WL_CHANSPEC_CTL_SB_MASK 0x0700
147 #define WL_CHANSPEC_CTL_SB_SHIFT 8
148 #define WL_CHANSPEC_CTL_SB_LLL 0x0000
149 #define WL_CHANSPEC_CTL_SB_LLU 0x0100
150 #define WL_CHANSPEC_CTL_SB_LUL 0x0200
151 #define WL_CHANSPEC_CTL_SB_LUU 0x0300
152 #define WL_CHANSPEC_CTL_SB_ULL 0x0400
153 #define WL_CHANSPEC_CTL_SB_ULU 0x0500
154 #define WL_CHANSPEC_CTL_SB_UUL 0x0600
155 #define WL_CHANSPEC_CTL_SB_UUU 0x0700
156 #define WL_CHANSPEC_CTL_SB_LL WL_CHANSPEC_CTL_SB_LLL
157 #define WL_CHANSPEC_CTL_SB_LU WL_CHANSPEC_CTL_SB_LLU
158 #define WL_CHANSPEC_CTL_SB_UL WL_CHANSPEC_CTL_SB_LUL
159 #define WL_CHANSPEC_CTL_SB_UU WL_CHANSPEC_CTL_SB_LUU
160 #define WL_CHANSPEC_CTL_SB_L WL_CHANSPEC_CTL_SB_LLL
161 #define WL_CHANSPEC_CTL_SB_U WL_CHANSPEC_CTL_SB_LLU
162 #define WL_CHANSPEC_CTL_SB_LOWER WL_CHANSPEC_CTL_SB_LLL
163 #define WL_CHANSPEC_CTL_SB_UPPER WL_CHANSPEC_CTL_SB_LLU
165 #define WL_CHANSPEC_BW_MASK 0x3800
166 #define WL_CHANSPEC_BW_SHIFT 11
167 #define WL_CHANSPEC_BW_5 0x0000
168 #define WL_CHANSPEC_BW_10 0x0800
169 #define WL_CHANSPEC_BW_20 0x1000
170 #define WL_CHANSPEC_BW_40 0x1800
171 #define WL_CHANSPEC_BW_80 0x2000
172 #define WL_CHANSPEC_BW_160 0x2800
173 #define WL_CHANSPEC_BW_8080 0x3000
175 #define WL_CHANSPEC_BAND_MASK 0xc000
176 #define WL_CHANSPEC_BAND_SHIFT 14
177 #define WL_CHANSPEC_BAND_2G 0x0000
178 #define WL_CHANSPEC_BAND_3G 0x4000
179 #define WL_CHANSPEC_BAND_4G 0x8000
180 #define WL_CHANSPEC_BAND_5G 0xc000
181 #define INVCHANSPEC 255
183 /* channel defines */
184 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? \
185 ((channel) - CH_10MHZ_APART) : 0)
186 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
187 ((channel) + CH_10MHZ_APART) : 0)
189 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
190 #define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
191 ((channel) + 3 * CH_10MHZ_APART) : 0)
192 #define LU_20_SB(channel) LOWER_20_SB(channel)
193 #define UL_20_SB(channel) UPPER_20_SB(channel)
195 #define LOWER_40_SB(channel) ((channel) - CH_20MHZ_APART)
196 #define UPPER_40_SB(channel) ((channel) + CH_20MHZ_APART)
197 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
198 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
199 (((channel) <= CH_MAX_2G_CHANNEL) ? \
200 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
201 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
202 ((channel) + CH_20MHZ_APART) : 0)
203 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
204 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
205 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
206 WL_CHANSPEC_BAND_5G))
207 #define CH80MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
208 ((channel) | (ctlsb) | \
209 WL_CHANSPEC_BW_80 | WL_CHANSPEC_BAND_5G)
210 #define CH160MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
211 ((channel) | (ctlsb) | \
212 WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
214 /* simple MACROs to get different fields of chanspec */
215 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
216 #define CHSPEC_CHAN1(chspec) ((chspec) & WL_CHANSPEC_CHAN1_MASK)
217 #define CHSPEC_CHAN2(chspec) ((chspec) & WL_CHANSPEC_CHAN2_MASK)
218 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
219 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
220 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
222 #ifdef WL11N_20MHZONLY
224 #define CHSPEC_IS10(chspec) 0
225 #define CHSPEC_IS20(chspec) 1
226 #ifndef CHSPEC_IS40
227 #define CHSPEC_IS40(chspec) 0
228 #endif
229 #ifndef CHSPEC_IS80
230 #define CHSPEC_IS80(chspec) 0
231 #endif
232 #ifndef CHSPEC_IS160
233 #define CHSPEC_IS160(chspec) 0
234 #endif
235 #ifndef CHSPEC_IS8080
236 #define CHSPEC_IS8080(chspec) 0
237 #endif
239 #else /* !WL11N_20MHZONLY */
241 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
242 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
243 #ifndef CHSPEC_IS40
244 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
245 #endif
246 #ifndef CHSPEC_IS80
247 #define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
248 #endif
249 #ifndef CHSPEC_IS160
250 #define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
251 #endif
252 #ifndef CHSPEC_IS8080
253 #define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
254 #endif
256 #endif /* !WL11N_20MHZONLY */
258 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
259 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
260 #define CHSPEC_SB_UPPER(chspec) \
261 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) && \
262 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
263 #define CHSPEC_SB_LOWER(chspec) \
264 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) && \
265 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
266 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
269 * Number of chars needed for wf_chspec_ntoa() destination character buffer.
271 #define CHANSPEC_STR_LEN 20
274 /* Legacy Chanspec defines
275 * These are the defines for the previous format of the chanspec_t
277 #define WL_LCHANSPEC_CHAN_MASK 0x00ff
278 #define WL_LCHANSPEC_CHAN_SHIFT 0
280 #define WL_LCHANSPEC_CTL_SB_MASK 0x0300
281 #define WL_LCHANSPEC_CTL_SB_SHIFT 8
282 #define WL_LCHANSPEC_CTL_SB_LOWER 0x0100
283 #define WL_LCHANSPEC_CTL_SB_UPPER 0x0200
284 #define WL_LCHANSPEC_CTL_SB_NONE 0x0300
286 #define WL_LCHANSPEC_BW_MASK 0x0C00
287 #define WL_LCHANSPEC_BW_SHIFT 10
288 #define WL_LCHANSPEC_BW_10 0x0400
289 #define WL_LCHANSPEC_BW_20 0x0800
290 #define WL_LCHANSPEC_BW_40 0x0C00
292 #define WL_LCHANSPEC_BAND_MASK 0xf000
293 #define WL_LCHANSPEC_BAND_SHIFT 12
294 #define WL_LCHANSPEC_BAND_5G 0x1000
295 #define WL_LCHANSPEC_BAND_2G 0x2000
297 #define LCHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_LCHANSPEC_CHAN_MASK))
298 #define LCHSPEC_BAND(chspec) ((chspec) & WL_LCHANSPEC_BAND_MASK)
299 #define LCHSPEC_CTL_SB(chspec) ((chspec) & WL_LCHANSPEC_CTL_SB_MASK)
300 #define LCHSPEC_BW(chspec) ((chspec) & WL_LCHANSPEC_BW_MASK)
301 #define LCHSPEC_IS10(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_10)
302 #define LCHSPEC_IS20(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_20)
303 #define LCHSPEC_IS40(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40)
304 #define LCHSPEC_IS5G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_5G)
305 #define LCHSPEC_IS2G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_2G)
307 #define LCHSPEC_CREATE(chan, band, bw, sb) ((uint16)((chan) | (sb) | (bw) | (band)))
309 #endif /* D11AC_IOTYPES */
312 * WF_CHAN_FACTOR_* constants are used to calculate channel frequency
313 * given a channel number.
314 * chan_freq = chan_factor * 500Mhz + chan_number * 5
318 * Channel Factor for the starting frequence of 2.4 GHz channels.
319 * The value corresponds to 2407 MHz.
321 #define WF_CHAN_FACTOR_2_4_G 4814 /* 2.4 GHz band, 2407 MHz */
324 * Channel Factor for the starting frequence of 5 GHz channels.
325 * The value corresponds to 5000 MHz.
327 #define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */
330 * Channel Factor for the starting frequence of 4.9 GHz channels.
331 * The value corresponds to 4000 MHz.
333 #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */
335 /* defined rate in 500kbps */
336 #define WLC_MAXRATE 108 /* in 500kbps units */
337 #define WLC_RATE_1M 2 /* in 500kbps units */
338 #define WLC_RATE_2M 4 /* in 500kbps units */
339 #define WLC_RATE_5M5 11 /* in 500kbps units */
340 #define WLC_RATE_11M 22 /* in 500kbps units */
341 #define WLC_RATE_6M 12 /* in 500kbps units */
342 #define WLC_RATE_9M 18 /* in 500kbps units */
343 #define WLC_RATE_12M 24 /* in 500kbps units */
344 #define WLC_RATE_18M 36 /* in 500kbps units */
345 #define WLC_RATE_24M 48 /* in 500kbps units */
346 #define WLC_RATE_36M 72 /* in 500kbps units */
347 #define WLC_RATE_48M 96 /* in 500kbps units */
348 #define WLC_RATE_54M 108 /* in 500kbps units */
350 #define WLC_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
353 * Convert chanspec to ascii string
355 * @param chspec chanspec format
356 * @param buf ascii string of chanspec
358 * @return pointer to buf with room for at least CHANSPEC_STR_LEN bytes
360 * @see CHANSPEC_STR_LEN
362 extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf);
365 * Convert ascii string to chanspec
367 * @param a pointer to input string
369 * @return >= 0 if successful or 0 otherwise
371 extern chanspec_t wf_chspec_aton(const char *a);
374 * Verify the chanspec fields are valid.
376 * Verify the chanspec is using a legal set field values, i.e. that the chanspec
377 * specified a band, bw, ctl_sb and channel and that the combination could be
378 * legal given some set of circumstances.
380 * @param chanspec input chanspec to verify
382 * @return TRUE if the chanspec is malformed, FALSE if it looks good.
384 extern bool wf_chspec_malformed(chanspec_t chanspec);
387 * Verify the chanspec specifies a valid channel according to 802.11.
389 * @param chanspec input chanspec to verify
391 * @return TRUE if the chanspec is a valid 802.11 channel
393 extern bool wf_chspec_valid(chanspec_t chanspec);
396 * Return the primary (control) channel.
398 * This function returns the channel number of the primary 20MHz channel. For
399 * 20MHz channels this is just the channel number. For 40MHz or wider channels
400 * it is the primary 20MHz channel specified by the chanspec.
402 * @param chspec input chanspec
404 * @return Returns the channel number of the primary 20MHz channel
406 extern uint8 wf_chspec_ctlchan(chanspec_t chspec);
409 * Return the primary (control) chanspec.
411 * This function returns the chanspec of the primary 20MHz channel. For 20MHz
412 * channels this is just the chanspec. For 40MHz or wider channels it is the
413 * chanspec of the primary 20MHZ channel specified by the chanspec.
415 * @param chspec input chanspec
417 * @return Returns the chanspec of the primary 20MHz channel
419 extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
422 * Return a channel number corresponding to a frequency.
424 * This function returns the chanspec for the primary 40MHz of an 80MHz channel.
425 * The control sideband specifies the same 20MHz channel that the 80MHz channel is using
426 * as the primary 20MHz channel.
428 extern chanspec_t wf_chspec_primary40_chspec(chanspec_t chspec);
431 * Return the channel number for a given frequency and base frequency.
432 * The returned channel number is relative to the given base frequency.
433 * If the given base frequency is zero, a base frequency of 5 GHz is assumed for
434 * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz.
436 * Frequency is specified in MHz.
437 * The base frequency is specified as (start_factor * 500 kHz).
438 * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
439 * 2.4 GHz and 5 GHz bands.
441 * The returned channel will be in the range [1, 14] in the 2.4 GHz band
442 * and [0, 200] otherwise.
443 * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the
444 * frequency is not a 2.4 GHz channel, or if the frequency is not and even
445 * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
447 * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
449 * @param freq frequency in MHz
450 * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
452 * @return Returns a channel number
454 * @see WF_CHAN_FACTOR_2_4_G
455 * @see WF_CHAN_FACTOR_5_G
457 extern int wf_mhz2channel(uint freq, uint start_factor);
460 * Return the center frequency in MHz of the given channel and base frequency.
462 * Return the center frequency in MHz of the given channel and base frequency.
463 * The channel number is interpreted relative to the given base frequency.
465 * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise.
466 * The base frequency is specified as (start_factor * 500 kHz).
467 * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
468 * 2.4 GHz and 5 GHz bands.
469 * The channel range of [1, 14] is only checked for a start_factor of
470 * WF_CHAN_FACTOR_2_4_G (4814).
471 * Odd start_factors produce channels on .5 MHz boundaries, in which case
472 * the answer is rounded down to an integral MHz.
473 * -1 is returned for an out of range channel.
475 * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
477 * @param channel input channel number
478 * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
480 * @return Returns a frequency in MHz
482 * @see WF_CHAN_FACTOR_2_4_G
483 * @see WF_CHAN_FACTOR_5_G
485 extern int wf_channel2mhz(uint channel, uint start_factor);
488 * Convert ctl chan and bw to chanspec
490 * @param ctl_ch channel
491 * @param bw bandwidth
493 * @return > 0 if successful or 0 otherwise
496 extern uint16 wf_channel2chspec(uint ctl_ch, uint bw);
498 #endif /* _bcmwifi_channels_h_ */