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 2007, Broadcom Corporation
9 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
20 /* A chanspec holds the channel number, band, bandwidth and control sideband */
21 typedef uint16 chanspec_t
;
24 #define CH_UPPER_SB 0x01
25 #define CH_LOWER_SB 0x02
26 #define CH_EWA_VALID 0x04
27 #define CH_20MHZ_APART 4
28 #define CH_10MHZ_APART 2
29 #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
30 #define WLC_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */
31 #define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216,
32 * this is that + 1 rounded up to a multiple of NBBY (8).
33 * DO NOT MAKE it > 255: channels are uint8's all over
36 #define WL_CHANSPEC_CHAN_MASK 0x00ff
37 #define WL_CHANSPEC_CHAN_SHIFT 0
39 #define WL_CHANSPEC_CTL_SB_MASK 0x0300
40 #define WL_CHANSPEC_CTL_SB_SHIFT 8
41 #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
42 #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
43 #define WL_CHANSPEC_CTL_SB_NONE 0x0300
45 #define WL_CHANSPEC_BW_MASK 0x0C00
46 #define WL_CHANSPEC_BW_SHIFT 10
47 #define WL_CHANSPEC_BW_10 0x0400
48 #define WL_CHANSPEC_BW_20 0x0800
49 #define WL_CHANSPEC_BW_40 0x0C00
51 #define WL_CHANSPEC_BAND_MASK 0xf000
52 #define WL_CHANSPEC_BAND_SHIFT 12
53 #define WL_CHANSPEC_BAND_5G 0x1000
54 #define WL_CHANSPEC_BAND_2G 0x2000
55 #define INVCHANSPEC 255
58 #define LOWER_20_SB(channel) ((channel > CH_10MHZ_APART) ? (channel - CH_10MHZ_APART) : 0)
59 #define UPPER_20_SB(channel) ((channel < (MAXCHANNEL - CH_10MHZ_APART)) ? \
60 (channel + CH_10MHZ_APART) : 0)
61 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
62 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
63 WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
64 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
65 #define NEXT_20MHZ_CHAN(channel) ((channel < (MAXCHANNEL - CH_20MHZ_APART)) ? \
66 (channel + CH_20MHZ_APART) : 0)
67 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
68 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
69 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
71 #define CHSPEC_CHANNEL(chspec) ((uint8)(chspec & WL_CHANSPEC_CHAN_MASK))
72 #define CHSPEC_CTL_SB(chspec) (chspec & WL_CHANSPEC_CTL_SB_MASK)
73 #define CHSPEC_BW(chspec) (chspec & WL_CHANSPEC_BW_MASK)
74 #define CHSPEC_BAND(chspec) (chspec & WL_CHANSPEC_BAND_MASK)
76 #define CHSPEC_IS10(chspec) ((chspec & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
77 #define CHSPEC_IS20(chspec) ((chspec & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
80 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
83 #define CHSPEC_IS5G(chspec) ((chspec & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
84 #define CHSPEC_IS2G(chspec) ((chspec & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
85 #define CHSPEC_SB_NONE(chspec) ((chspec & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
86 #define CHSPEC_SB_UPPER(chspec) ((chspec & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
87 #define CHSPEC_SB_LOWER(chspec) ((chspec & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
89 /* defined rate in 500kbps */
90 #define WLC_MAXRATE 108 /* in 500kbps units */
91 #define WLC_RATE_1M 2 /* in 500kbps units */
92 #define WLC_RATE_2M 4 /* in 500kbps units */
93 #define WLC_RATE_5M5 11 /* in 500kbps units */
94 #define WLC_RATE_11M 22 /* in 500kbps units */
95 #define WLC_RATE_6M 12 /* in 500kbps units */
96 #define WLC_RATE_9M 18 /* in 500kbps units */
97 #define WLC_RATE_12M 24 /* in 500kbps units */
98 #define WLC_RATE_18M 36 /* in 500kbps units */
99 #define WLC_RATE_24M 48 /* in 500kbps units */
100 #define WLC_RATE_36M 72 /* in 500kbps units */
101 #define WLC_RATE_48M 96 /* in 500kbps units */
102 #define WLC_RATE_54M 108 /* in 500kbps units */
105 * Convert chanspec to ascii string
106 * @param chspec chanspec format
107 * @param buf ascii string of chanspec
108 * @return pointer to buf
110 extern char * wf_chspec_ntoa(chanspec_t chspec
, char *buf
);
113 * Convert ascii string to chanspec
114 * @param a pointer to input string
115 * @return >= 0 if successful or 0 otherwise
117 extern chanspec_t
wf_chspec_aton(char *a
);
119 #ifdef CONFIG_NET_RADIO
120 /* wl functions used by the ndis wl. */
121 extern uint
freq2channel(uint freq
);
122 extern uint
channel2freq(uint channel
);
126 #endif /* _bcmwifi_h_ */