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.
5  *
6  * Copyright (C) 1999-2013, Broadcom Corporation
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.
11  *
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.
19  *
20  * $Id: bcmwifi_channels.h 309193 2012-01-19 00:03:57Z $
21  */
22 
23 #ifndef	_bcmwifi_channels_h_
24 #define	_bcmwifi_channels_h_
25 
26 
27 /* A chanspec holds the channel number, band, bandwidth and control sideband */
28 typedef uint16 chanspec_t;
29 
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
43 					 */
44 #define CHSPEC_CTLOVLP(sp1, sp2, sep)	(ABS(wf_chspec_ctlchan(sp1) - wf_chspec_ctlchan(sp2)) < \
45 				  (sep))
46 
47 /* All builds use the new 11ac ratespec/chanspec */
48 #undef  D11AC_IOTYPES
49 #define D11AC_IOTYPES
50 
51 #ifndef D11AC_IOTYPES
52 
53 #define WL_CHANSPEC_CHAN_MASK		0x00ff
54 #define WL_CHANSPEC_CHAN_SHIFT		0
55 
56 #define WL_CHANSPEC_CTL_SB_MASK		0x0300
57 #define WL_CHANSPEC_CTL_SB_SHIFT	     8
58 #define WL_CHANSPEC_CTL_SB_LOWER	0x0100
59 #define WL_CHANSPEC_CTL_SB_UPPER	0x0200
60 #define WL_CHANSPEC_CTL_SB_NONE		0x0300
61 
62 #define WL_CHANSPEC_BW_MASK		0x0C00
63 #define WL_CHANSPEC_BW_SHIFT		    10
64 #define WL_CHANSPEC_BW_10		0x0400
65 #define WL_CHANSPEC_BW_20		0x0800
66 #define WL_CHANSPEC_BW_40		0x0C00
67 
68 #define WL_CHANSPEC_BAND_MASK		0xf000
69 #define WL_CHANSPEC_BAND_SHIFT		12
70 #ifdef WL_CHANSPEC_BAND_5G
71 #undef WL_CHANSPEC_BAND_5G
72 #endif
73 #ifdef WL_CHANSPEC_BAND_2G
74 #undef WL_CHANSPEC_BAND_2G
75 #endif
76 #define WL_CHANSPEC_BAND_5G		0x1000
77 #define WL_CHANSPEC_BAND_2G		0x2000
78 #define INVCHANSPEC			255
79 
80 /* channel defines */
81 #define LOWER_20_SB(channel)	(((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0)
82 #define UPPER_20_SB(channel)	(((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
83 				((channel) + CH_10MHZ_APART) : 0)
84 
85 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
86 #define UU_20_SB(channel) 	(((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
87 				((channel) + 3 * CH_10MHZ_APART) : 0)
88 #define LU_20_SB(channel) LOWER_20_SB(channel)
89 #define UL_20_SB(channel) UPPER_20_SB(channel)
90 
91 #define CHSPEC_WLCBANDUNIT(chspec)	(CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
92 #define CH20MHZ_CHSPEC(channel)	(chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
93 				WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
94 				WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
95 #define NEXT_20MHZ_CHAN(channel)	(((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
96 					((channel) + CH_20MHZ_APART) : 0)
97 #define CH40MHZ_CHSPEC(channel, ctlsb)	(chanspec_t) \
98 					((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
99 					((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
100 					WL_CHANSPEC_BAND_5G))
101 #define CHSPEC_CHANNEL(chspec)	((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
102 #define CHSPEC_BAND(chspec)	((chspec) & WL_CHANSPEC_BAND_MASK)
103 
104 /* chanspec stores radio channel & flags to indicate control channel location, i.e. upper/lower */
105 #define CHSPEC_CTL_SB(chspec)	((chspec) & WL_CHANSPEC_CTL_SB_MASK)
106 #define CHSPEC_BW(chspec)	((chspec) & WL_CHANSPEC_BW_MASK)
107 
108 #ifdef WL11N_20MHZONLY
109 
110 #define CHSPEC_IS10(chspec)	0
111 #define CHSPEC_IS20(chspec)	1
112 #ifndef CHSPEC_IS40
113 #define CHSPEC_IS40(chspec)	0
114 #endif
115 
116 #else /* !WL11N_20MHZONLY */
117 
118 #define CHSPEC_IS10(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
119 #define CHSPEC_IS20(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
120 #ifndef CHSPEC_IS40
121 #define CHSPEC_IS40(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
122 #endif
123 
124 #endif /* !WL11N_20MHZONLY */
125 
126 #define CHSPEC_IS5G(chspec)	(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
127 #define CHSPEC_IS2G(chspec)	(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
128 #define CHSPEC_SB_NONE(chspec)	(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
129 #define CHSPEC_SB_UPPER(chspec)	(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
130 #define CHSPEC_SB_LOWER(chspec)	(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
131 #define CHSPEC_CTL_CHAN(chspec)  ((CHSPEC_SB_LOWER(chspec)) ? \
132 				  (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
133 				  (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))))
134 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
135 
136 #define CHANSPEC_STR_LEN    8
137 
138 #else /* D11AC_IOTYPES */
139 
140 #define WL_CHANSPEC_CHAN_MASK		0x00ff
141 #define WL_CHANSPEC_CHAN_SHIFT		0
142 #define WL_CHANSPEC_CHAN1_MASK		0x000f
143 #define WL_CHANSPEC_CHAN1_SHIFT		0
144 #define WL_CHANSPEC_CHAN2_MASK		0x00f0
145 #define WL_CHANSPEC_CHAN2_SHIFT		4
146 
147 #define WL_CHANSPEC_CTL_SB_MASK		0x0700
148 #define WL_CHANSPEC_CTL_SB_SHIFT	8
149 #define WL_CHANSPEC_CTL_SB_LLL		0x0000
150 #define WL_CHANSPEC_CTL_SB_LLU		0x0100
151 #define WL_CHANSPEC_CTL_SB_LUL		0x0200
152 #define WL_CHANSPEC_CTL_SB_LUU		0x0300
153 #define WL_CHANSPEC_CTL_SB_ULL		0x0400
154 #define WL_CHANSPEC_CTL_SB_ULU		0x0500
155 #define WL_CHANSPEC_CTL_SB_UUL		0x0600
156 #define WL_CHANSPEC_CTL_SB_UUU		0x0700
157 #define WL_CHANSPEC_CTL_SB_LL		WL_CHANSPEC_CTL_SB_LLL
158 #define WL_CHANSPEC_CTL_SB_LU		WL_CHANSPEC_CTL_SB_LLU
159 #define WL_CHANSPEC_CTL_SB_UL		WL_CHANSPEC_CTL_SB_LUL
160 #define WL_CHANSPEC_CTL_SB_UU		WL_CHANSPEC_CTL_SB_LUU
161 #define WL_CHANSPEC_CTL_SB_L		WL_CHANSPEC_CTL_SB_LLL
162 #define WL_CHANSPEC_CTL_SB_U		WL_CHANSPEC_CTL_SB_LLU
163 #define WL_CHANSPEC_CTL_SB_LOWER 	WL_CHANSPEC_CTL_SB_LLL
164 #define WL_CHANSPEC_CTL_SB_UPPER	WL_CHANSPEC_CTL_SB_LLU
165 
166 #define WL_CHANSPEC_BW_MASK		0x3800
167 #define WL_CHANSPEC_BW_SHIFT		11
168 #define WL_CHANSPEC_BW_5		0x0000
169 #define WL_CHANSPEC_BW_10		0x0800
170 #define WL_CHANSPEC_BW_20		0x1000
171 #define WL_CHANSPEC_BW_40		0x1800
172 #define WL_CHANSPEC_BW_80		0x2000
173 #define WL_CHANSPEC_BW_160		0x2800
174 #define WL_CHANSPEC_BW_8080		0x3000
175 
176 #define WL_CHANSPEC_BAND_MASK		0xc000
177 #define WL_CHANSPEC_BAND_SHIFT		14
178 #define WL_CHANSPEC_BAND_2G		0x0000
179 #define WL_CHANSPEC_BAND_3G		0x4000
180 #define WL_CHANSPEC_BAND_4G		0x8000
181 #define WL_CHANSPEC_BAND_5G		0xc000
182 #define INVCHANSPEC			255
183 
184 /* channel defines */
185 #define LOWER_20_SB(channel)		(((channel) > CH_10MHZ_APART) ? \
186 					((channel) - CH_10MHZ_APART) : 0)
187 #define UPPER_20_SB(channel)		(((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
188 					((channel) + CH_10MHZ_APART) : 0)
189 
190 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
191 #define UU_20_SB(channel) 	(((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
192 				((channel) + 3 * CH_10MHZ_APART) : 0)
193 #define LU_20_SB(channel) LOWER_20_SB(channel)
194 #define UL_20_SB(channel) UPPER_20_SB(channel)
195 
196 #define LOWER_40_SB(channel)		((channel) - CH_20MHZ_APART)
197 #define UPPER_40_SB(channel)		((channel) + CH_20MHZ_APART)
198 #define CHSPEC_WLCBANDUNIT(chspec)	(CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
199 #define CH20MHZ_CHSPEC(channel)		(chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
200 					(((channel) <= CH_MAX_2G_CHANNEL) ? \
201 					WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
202 #define NEXT_20MHZ_CHAN(channel)	(((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
203 					((channel) + CH_20MHZ_APART) : 0)
204 #define CH40MHZ_CHSPEC(channel, ctlsb)	(chanspec_t) \
205 					((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
206 					((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
207 					WL_CHANSPEC_BAND_5G))
208 #define CH80MHZ_CHSPEC(channel, ctlsb)	(chanspec_t) \
209 					((channel) | (ctlsb) | \
210 					 WL_CHANSPEC_BW_80 | WL_CHANSPEC_BAND_5G)
211 #define CH160MHZ_CHSPEC(channel, ctlsb)	(chanspec_t) \
212 					((channel) | (ctlsb) | \
213 					 WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
214 
215 /* simple MACROs to get different fields of chanspec */
216 #define CHSPEC_CHANNEL(chspec)		((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
217 #define CHSPEC_CHAN1(chspec)		((chspec) & WL_CHANSPEC_CHAN1_MASK)
218 #define CHSPEC_CHAN2(chspec)		((chspec) & WL_CHANSPEC_CHAN2_MASK)
219 #define CHSPEC_BAND(chspec)		((chspec) & WL_CHANSPEC_BAND_MASK)
220 #define CHSPEC_CTL_SB(chspec)		((chspec) & WL_CHANSPEC_CTL_SB_MASK)
221 #define CHSPEC_BW(chspec)		((chspec) & WL_CHANSPEC_BW_MASK)
222 
223 #ifdef WL11N_20MHZONLY
224 
225 #define CHSPEC_IS10(chspec)	0
226 #define CHSPEC_IS20(chspec)	1
227 #ifndef CHSPEC_IS40
228 #define CHSPEC_IS40(chspec)	0
229 #endif
230 #ifndef CHSPEC_IS80
231 #define CHSPEC_IS80(chspec)	0
232 #endif
233 #ifndef CHSPEC_IS160
234 #define CHSPEC_IS160(chspec)	0
235 #endif
236 #ifndef CHSPEC_IS8080
237 #define CHSPEC_IS8080(chspec)	0
238 #endif
239 
240 #else /* !WL11N_20MHZONLY */
241 
242 #define CHSPEC_IS10(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
243 #define CHSPEC_IS20(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
244 #ifndef CHSPEC_IS40
245 #define CHSPEC_IS40(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
246 #endif
247 #ifndef CHSPEC_IS80
248 #define CHSPEC_IS80(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
249 #endif
250 #ifndef CHSPEC_IS160
251 #define CHSPEC_IS160(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
252 #endif
253 #ifndef CHSPEC_IS8080
254 #define CHSPEC_IS8080(chspec)	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
255 #endif
256 
257 #endif /* !WL11N_20MHZONLY */
258 
259 #define CHSPEC_IS5G(chspec)	(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
260 #define CHSPEC_IS2G(chspec)	(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
261 #define CHSPEC_SB_UPPER(chspec)	\
262 	((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) && \
263 	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
264 #define CHSPEC_SB_LOWER(chspec)	\
265 	((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) && \
266 	(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
267 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
268 
269 /**
270  * Number of chars needed for wf_chspec_ntoa() destination character buffer.
271  */
272 #define CHANSPEC_STR_LEN    20
273 
274 
275 /* Legacy Chanspec defines
276  * These are the defines for the previous format of the chanspec_t
277  */
278 #define WL_LCHANSPEC_CHAN_MASK		0x00ff
279 #define WL_LCHANSPEC_CHAN_SHIFT		     0
280 
281 #define WL_LCHANSPEC_CTL_SB_MASK	0x0300
282 #define WL_LCHANSPEC_CTL_SB_SHIFT	     8
283 #define WL_LCHANSPEC_CTL_SB_LOWER	0x0100
284 #define WL_LCHANSPEC_CTL_SB_UPPER	0x0200
285 #define WL_LCHANSPEC_CTL_SB_NONE	0x0300
286 
287 #define WL_LCHANSPEC_BW_MASK		0x0C00
288 #define WL_LCHANSPEC_BW_SHIFT		    10
289 #define WL_LCHANSPEC_BW_10		0x0400
290 #define WL_LCHANSPEC_BW_20		0x0800
291 #define WL_LCHANSPEC_BW_40		0x0C00
292 
293 #define WL_LCHANSPEC_BAND_MASK		0xf000
294 #define WL_LCHANSPEC_BAND_SHIFT		    12
295 #define WL_LCHANSPEC_BAND_5G		0x1000
296 #define WL_LCHANSPEC_BAND_2G		0x2000
297 
298 #define LCHSPEC_CHANNEL(chspec)	((uint8)((chspec) & WL_LCHANSPEC_CHAN_MASK))
299 #define LCHSPEC_BAND(chspec)	((chspec) & WL_LCHANSPEC_BAND_MASK)
300 #define LCHSPEC_CTL_SB(chspec)	((chspec) & WL_LCHANSPEC_CTL_SB_MASK)
301 #define LCHSPEC_BW(chspec)	((chspec) & WL_LCHANSPEC_BW_MASK)
302 #define LCHSPEC_IS10(chspec)	(((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_10)
303 #define LCHSPEC_IS20(chspec)	(((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_20)
304 #define LCHSPEC_IS40(chspec)	(((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40)
305 #define LCHSPEC_IS5G(chspec)	(((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_5G)
306 #define LCHSPEC_IS2G(chspec)	(((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_2G)
307 
308 #define LCHSPEC_CREATE(chan, band, bw, sb)  ((uint16)((chan) | (sb) | (bw) | (band)))
309 
310 #endif /* D11AC_IOTYPES */
311 
312 /*
313  * WF_CHAN_FACTOR_* constants are used to calculate channel frequency
314  * given a channel number.
315  * chan_freq = chan_factor * 500Mhz + chan_number * 5
316  */
317 
318 /**
319  * Channel Factor for the starting frequence of 2.4 GHz channels.
320  * The value corresponds to 2407 MHz.
321  */
322 #define WF_CHAN_FACTOR_2_4_G		4814	/* 2.4 GHz band, 2407 MHz */
323 
324 /**
325  * Channel Factor for the starting frequence of 5 GHz channels.
326  * The value corresponds to 5000 MHz.
327  */
328 #define WF_CHAN_FACTOR_5_G		10000	/* 5   GHz band, 5000 MHz */
329 
330 /**
331  * Channel Factor for the starting frequence of 4.9 GHz channels.
332  * The value corresponds to 4000 MHz.
333  */
334 #define WF_CHAN_FACTOR_4_G		8000	/* 4.9 GHz band for Japan */
335 
336 #define WLC_2G_25MHZ_OFFSET		5	/* 2.4GHz band channel offset */
337 
338 /**
339  * Convert chanspec to ascii string
340  *
341  * @param	chspec		chanspec format
342  * @param	buf		ascii string of chanspec
343  *
344  * @return	pointer to buf with room for at least CHANSPEC_STR_LEN bytes
345  *
346  * @see		CHANSPEC_STR_LEN
347  */
348 extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf);
349 
350 /**
351  * Convert ascii string to chanspec
352  *
353  * @param	a     pointer to input string
354  *
355  * @return	>= 0 if successful or 0 otherwise
356  */
357 extern chanspec_t wf_chspec_aton(const char *a);
358 
359 /**
360  * Verify the chanspec fields are valid.
361  *
362  * Verify the chanspec is using a legal set field values, i.e. that the chanspec
363  * specified a band, bw, ctl_sb and channel and that the combination could be
364  * legal given some set of circumstances.
365  *
366  * @param	chanspec   input chanspec to verify
367  *
368  * @return TRUE if the chanspec is malformed, FALSE if it looks good.
369  */
370 extern bool wf_chspec_malformed(chanspec_t chanspec);
371 
372 /**
373  * Verify the chanspec specifies a valid channel according to 802.11.
374  *
375  * @param	chanspec   input chanspec to verify
376  *
377  * @return TRUE if the chanspec is a valid 802.11 channel
378  */
379 extern bool wf_chspec_valid(chanspec_t chanspec);
380 
381 /**
382  * Return the primary (control) channel.
383  *
384  * This function returns the channel number of the primary 20MHz channel. For
385  * 20MHz channels this is just the channel number. For 40MHz or wider channels
386  * it is the primary 20MHz channel specified by the chanspec.
387  *
388  * @param	chspec    input chanspec
389  *
390  * @return Returns the channel number of the primary 20MHz channel
391  */
392 extern uint8 wf_chspec_ctlchan(chanspec_t chspec);
393 
394 /**
395  * Return the primary (control) chanspec.
396  *
397  * This function returns the chanspec of the primary 20MHz channel. For 20MHz
398  * channels this is just the chanspec. For 40MHz or wider channels it is the
399  * chanspec of the primary 20MHZ channel specified by the chanspec.
400  *
401  * @param	chspec    input chanspec
402  *
403  * @return Returns the chanspec of the primary 20MHz channel
404  */
405 extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
406 
407 /**
408  * Return a channel number corresponding to a frequency.
409  *
410  * This function returns the chanspec for the primary 40MHz of an 80MHz channel.
411  * The control sideband specifies the same 20MHz channel that the 80MHz channel is using
412  * as the primary 20MHz channel.
413  */
414 extern chanspec_t wf_chspec_primary40_chspec(chanspec_t chspec);
415 
416 /*
417  * Return the channel number for a given frequency and base frequency.
418  * The returned channel number is relative to the given base frequency.
419  * If the given base frequency is zero, a base frequency of 5 GHz is assumed for
420  * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz.
421  *
422  * Frequency is specified in MHz.
423  * The base frequency is specified as (start_factor * 500 kHz).
424  * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
425  * 2.4 GHz and 5 GHz bands.
426  *
427  * The returned channel will be in the range [1, 14] in the 2.4 GHz band
428  * and [0, 200] otherwise.
429  * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the
430  * frequency is not a 2.4 GHz channel, or if the frequency is not and even
431  * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
432  *
433  * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
434  *
435  * @param	freq          frequency in MHz
436  * @param	start_factor  base frequency in 500 kHz units, e.g. 10000 for 5 GHz
437  *
438  * @return Returns a channel number
439  *
440  * @see  WF_CHAN_FACTOR_2_4_G
441  * @see  WF_CHAN_FACTOR_5_G
442  */
443 extern int wf_mhz2channel(uint freq, uint start_factor);
444 
445 /**
446  * Return the center frequency in MHz of the given channel and base frequency.
447  *
448  * Return the center frequency in MHz of the given channel and base frequency.
449  * The channel number is interpreted relative to the given base frequency.
450  *
451  * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise.
452  * The base frequency is specified as (start_factor * 500 kHz).
453  * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
454  * 2.4 GHz and 5 GHz bands.
455  * The channel range of [1, 14] is only checked for a start_factor of
456  * WF_CHAN_FACTOR_2_4_G (4814).
457  * Odd start_factors produce channels on .5 MHz boundaries, in which case
458  * the answer is rounded down to an integral MHz.
459  * -1 is returned for an out of range channel.
460  *
461  * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
462  *
463  * @param	channel       input channel number
464  * @param	start_factor  base frequency in 500 kHz units, e.g. 10000 for 5 GHz
465  *
466  * @return Returns a frequency in MHz
467  *
468  * @see  WF_CHAN_FACTOR_2_4_G
469  * @see  WF_CHAN_FACTOR_5_G
470  */
471 extern int wf_channel2mhz(uint channel, uint start_factor);
472 
473 /**
474  * Convert ctl chan and bw to chanspec
475  *
476  * @param	ctl_ch		channel
477  * @param	bw	        bandwidth
478  *
479  * @return	> 0 if successful or 0 otherwise
480  *
481  */
482 extern uint16 wf_channel2chspec(uint ctl_ch, uint bw);
483 
484 extern uint wf_channel2freq(uint channel);
485 extern uint wf_freq2channel(uint freq);
486 
487 
488 #endif	/* _bcmwifi_channels_h_ */
489