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