2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <linux/if_ether.h> /* for ETH_ALEN */
21 #include <linux/ieee80211.h> /* for WLAN_PMKID_LEN */
23 /* A chanspec holds the channel number, band, bandwidth and control sideband */
24 typedef u16 chanspec_t;
27 #define CH_UPPER_SB 0x01
28 #define CH_LOWER_SB 0x02
29 #define CH_EWA_VALID 0x04
30 #define CH_20MHZ_APART 4
31 #define CH_10MHZ_APART 2
32 #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
33 #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
34 #define WLC_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */
35 #define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216,
36 * this is that + 1 rounded up to a multiple of NBBY (8).
37 * DO NOT MAKE it > 255: channels are u8's all over
40 #define WL_CHANSPEC_CHAN_MASK 0x00ff
41 #define WL_CHANSPEC_CHAN_SHIFT 0
43 #define WL_CHANSPEC_CTL_SB_MASK 0x0300
44 #define WL_CHANSPEC_CTL_SB_SHIFT 8
45 #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
46 #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
47 #define WL_CHANSPEC_CTL_SB_NONE 0x0300
49 #define WL_CHANSPEC_BW_MASK 0x0C00
50 #define WL_CHANSPEC_BW_SHIFT 10
51 #define WL_CHANSPEC_BW_10 0x0400
52 #define WL_CHANSPEC_BW_20 0x0800
53 #define WL_CHANSPEC_BW_40 0x0C00
55 #define WL_CHANSPEC_BAND_MASK 0xf000
56 #define WL_CHANSPEC_BAND_SHIFT 12
57 #define WL_CHANSPEC_BAND_5G 0x1000
58 #define WL_CHANSPEC_BAND_2G 0x2000
59 #define INVCHANSPEC 255
61 /* used to calculate the chan_freq = chan_factor * 500Mhz + 5 * chan_number */
62 #define WF_CHAN_FACTOR_2_4_G 4814 /* 2.4 GHz band, 2407 MHz */
63 #define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */
64 #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */
67 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0)
68 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
69 ((channel) + CH_10MHZ_APART) : 0)
70 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
71 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
72 WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
73 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
74 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
75 ((channel) + CH_20MHZ_APART) : 0)
76 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
77 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
78 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
80 #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
81 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
83 #ifdef WL11N_20MHZONLY
85 #define CHSPEC_CTL_SB(chspec) WL_CHANSPEC_CTL_SB_NONE
86 #define CHSPEC_BW(chspec) WL_CHANSPEC_BW_20
87 #define CHSPEC_IS10(chspec) 0
88 #define CHSPEC_IS20(chspec) 1
90 #define CHSPEC_IS40(chspec) 0
93 #else /* !WL11N_20MHZONLY */
95 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
96 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
97 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
98 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
100 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
103 #endif /* !WL11N_20MHZONLY */
105 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
106 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
107 #define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
108 #define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
109 #define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
110 #define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \
111 (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
112 (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))))
113 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
115 #define CHANSPEC_STR_LEN 8
117 /* defined rate in 500kbps */
118 #define WLC_MAXRATE 108 /* in 500kbps units */
119 #define WLC_RATE_1M 2 /* in 500kbps units */
120 #define WLC_RATE_2M 4 /* in 500kbps units */
121 #define WLC_RATE_5M5 11 /* in 500kbps units */
122 #define WLC_RATE_11M 22 /* in 500kbps units */
123 #define WLC_RATE_6M 12 /* in 500kbps units */
124 #define WLC_RATE_9M 18 /* in 500kbps units */
125 #define WLC_RATE_12M 24 /* in 500kbps units */
126 #define WLC_RATE_18M 36 /* in 500kbps units */
127 #define WLC_RATE_24M 48 /* in 500kbps units */
128 #define WLC_RATE_36M 72 /* in 500kbps units */
129 #define WLC_RATE_48M 96 /* in 500kbps units */
130 #define WLC_RATE_54M 108 /* in 500kbps units */
132 #define WLC_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
135 * Verify the chanspec is using a legal set of parameters, i.e. that the
136 * chanspec specified a band, bw, ctl_sb and channel and that the
137 * combination could be legal given any set of circumstances.
138 * RETURNS: true is the chanspec is malformed, false if it looks good.
140 extern bool bcm_chspec_malformed(chanspec_t chanspec);
143 * This function returns the channel number that control traffic is being sent on, for legacy
144 * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
145 * sideband depending on the chanspec selected
147 extern u8 bcm_chspec_ctlchan(chanspec_t chspec);
150 * Return the channel number for a given frequency and base frequency.
151 * The returned channel number is relative to the given base frequency.
152 * If the given base frequency is zero, a base frequency of 5 GHz is assumed for
153 * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz.
155 * Frequency is specified in MHz.
156 * The base frequency is specified as (start_factor * 500 kHz).
157 * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
158 * 2.4 GHz and 5 GHz bands.
160 * The returned channel will be in the range [1, 14] in the 2.4 GHz band
161 * and [0, 200] otherwise.
162 * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the
163 * frequency is not a 2.4 GHz channel, or if the frequency is not and even
164 * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
166 * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
168 extern int bcm_mhz2channel(uint freq, uint start_factor);
170 /* Enumerate crypto algorithms */
171 #define CRYPTO_ALGO_OFF 0
172 #define CRYPTO_ALGO_WEP1 1
173 #define CRYPTO_ALGO_TKIP 2
174 #define CRYPTO_ALGO_WEP128 3
175 #define CRYPTO_ALGO_AES_CCM 4
176 #define CRYPTO_ALGO_AES_RESERVED1 5
177 #define CRYPTO_ALGO_AES_RESERVED2 6
178 #define CRYPTO_ALGO_NALG 7
180 /* wireless security bitvec */
181 #define WEP_ENABLED 0x0001
182 #define TKIP_ENABLED 0x0002
183 #define AES_ENABLED 0x0004
184 #define WSEC_SWFLAG 0x0008
185 #define SES_OW_ENABLED 0x0040 /* to go into transition mode without setting wep */
187 /* WPA authentication mode bitvec */
188 #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
189 #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
190 #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
191 #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
192 #define WPA_AUTH_RESERVED1 0x0008
193 #define WPA_AUTH_RESERVED2 0x0010
194 /* #define WPA_AUTH_8021X 0x0020 *//* 802.1x, reserved */
195 #define WPA2_AUTH_RESERVED1 0x0020
196 #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
197 #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
198 #define WPA2_AUTH_RESERVED3 0x0200
199 #define WPA2_AUTH_RESERVED4 0x0400
200 #define WPA2_AUTH_RESERVED5 0x0800
205 typedef struct _pmkid {
207 u8 PMKID[WLAN_PMKID_LEN];
210 typedef struct _pmkid_list {
215 typedef struct _pmkid_cand {
220 typedef struct _pmkid_cand_list {
222 pmkid_cand_t pmkid_cand[1];
225 #endif /* _bcmwifi_h_ */