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