CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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