Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
brcmu_wifi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
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.
7  *
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.
15  */
16 
17 #ifndef _BRCMU_WIFI_H_
18 #define _BRCMU_WIFI_H_
19 
20 #include <linux/if_ether.h> /* for ETH_ALEN */
21 #include <linux/ieee80211.h> /* for WLAN_PMKID_LEN */
22 
23 /*
24  * A chanspec (u16) holds the channel number, band, bandwidth and control
25  * sideband
26  */
27 
28 /* channel defines */
29 #define CH_UPPER_SB 0x01
30 #define CH_LOWER_SB 0x02
31 #define CH_EWA_VALID 0x04
32 #define CH_20MHZ_APART 4
33 #define CH_10MHZ_APART 2
34 #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
35 #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
36 #define BRCM_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */
37 
38 /* bandstate array indices */
39 #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */
40 #define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */
41 
42 /*
43  * max # supported channels. The max channel no is 216, this is that + 1
44  * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are
45  * u8's all over
46 */
47 #define MAXCHANNEL 224
48 
49 #define WL_CHANSPEC_CHAN_MASK 0x00ff
50 #define WL_CHANSPEC_CHAN_SHIFT 0
51 
52 #define WL_CHANSPEC_CTL_SB_MASK 0x0300
53 #define WL_CHANSPEC_CTL_SB_SHIFT 8
54 #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
55 #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
56 #define WL_CHANSPEC_CTL_SB_NONE 0x0300
57 
58 #define WL_CHANSPEC_BW_MASK 0x0C00
59 #define WL_CHANSPEC_BW_SHIFT 10
60 #define WL_CHANSPEC_BW_10 0x0400
61 #define WL_CHANSPEC_BW_20 0x0800
62 #define WL_CHANSPEC_BW_40 0x0C00
63 
64 #define WL_CHANSPEC_BAND_MASK 0xf000
65 #define WL_CHANSPEC_BAND_SHIFT 12
66 #define WL_CHANSPEC_BAND_5G 0x1000
67 #define WL_CHANSPEC_BAND_2G 0x2000
68 #define INVCHANSPEC 255
69 
70 #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
71 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
72 
73 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
74 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
75 
76 #define CHSPEC_IS10(chspec) \
77  (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
78 
79 #define CHSPEC_IS20(chspec) \
80  (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
81 
82 #ifndef CHSPEC_IS40
83 #define CHSPEC_IS40(chspec) \
84  (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
85 #endif
86 
87 #define CHSPEC_IS5G(chspec) \
88  (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
89 
90 #define CHSPEC_IS2G(chspec) \
91  (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
92 
93 #define CHSPEC_SB_NONE(chspec) \
94  (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
95 
96 #define CHSPEC_SB_UPPER(chspec) \
97  (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
98 
99 #define CHSPEC_SB_LOWER(chspec) \
100  (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
101 
102 #define CHSPEC_CTL_CHAN(chspec) \
103  ((CHSPEC_SB_LOWER(chspec)) ? \
104  (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
105  (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))
106 
107 #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)
108 
109 #define CHANSPEC_STR_LEN 8
110 
111 static inline int lower_20_sb(int channel)
112 {
113  return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;
114 }
115 
116 static inline int upper_20_sb(int channel)
117 {
118  return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?
119  channel + CH_10MHZ_APART : 0;
120 }
121 
122 static inline int chspec_bandunit(u16 chspec)
123 {
124  return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;
125 }
126 
127 static inline u16 ch20mhz_chspec(int channel)
128 {
129  u16 rc = channel <= CH_MAX_2G_CHANNEL ?
131 
132  return (u16)((u16)channel | WL_CHANSPEC_BW_20 |
134 }
135 
136 static inline int next_20mhz_chan(int channel)
137 {
138  return channel < (MAXCHANNEL - CH_20MHZ_APART) ?
139  channel + CH_20MHZ_APART : 0;
140 }
141 
142 /* defined rate in 500kbps */
143 #define BRCM_MAXRATE 108 /* in 500kbps units */
144 #define BRCM_RATE_1M 2 /* in 500kbps units */
145 #define BRCM_RATE_2M 4 /* in 500kbps units */
146 #define BRCM_RATE_5M5 11 /* in 500kbps units */
147 #define BRCM_RATE_11M 22 /* in 500kbps units */
148 #define BRCM_RATE_6M 12 /* in 500kbps units */
149 #define BRCM_RATE_9M 18 /* in 500kbps units */
150 #define BRCM_RATE_12M 24 /* in 500kbps units */
151 #define BRCM_RATE_18M 36 /* in 500kbps units */
152 #define BRCM_RATE_24M 48 /* in 500kbps units */
153 #define BRCM_RATE_36M 72 /* in 500kbps units */
154 #define BRCM_RATE_48M 96 /* in 500kbps units */
155 #define BRCM_RATE_54M 108 /* in 500kbps units */
156 
157 #define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
158 
159 #define MCSSET_LEN 16
160 
161 static inline bool ac_bitmap_tst(u8 bitmap, int prec)
162 {
163  return (bitmap & (1 << (prec))) != 0;
164 }
165 
166 /* Enumerate crypto algorithms */
167 #define CRYPTO_ALGO_OFF 0
168 #define CRYPTO_ALGO_WEP1 1
169 #define CRYPTO_ALGO_TKIP 2
170 #define CRYPTO_ALGO_WEP128 3
171 #define CRYPTO_ALGO_AES_CCM 4
172 #define CRYPTO_ALGO_AES_RESERVED1 5
173 #define CRYPTO_ALGO_AES_RESERVED2 6
174 #define CRYPTO_ALGO_NALG 7
175 
176 /* wireless security bitvec */
177 
178 #define WEP_ENABLED 0x0001
179 #define TKIP_ENABLED 0x0002
180 #define AES_ENABLED 0x0004
181 #define WSEC_SWFLAG 0x0008
182 /* to go into transition mode without setting wep */
183 #define SES_OW_ENABLED 0x0040
184 
185 /* WPA authentication mode bitvec */
186 #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
187 #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
188 #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
189 #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
190 #define WPA_AUTH_RESERVED1 0x0008
191 #define WPA_AUTH_RESERVED2 0x0010
192 
193 #define WPA2_AUTH_RESERVED1 0x0020
194 #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
195 #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
196 #define WPA2_AUTH_RESERVED3 0x0200
197 #define WPA2_AUTH_RESERVED4 0x0400
198 #define WPA2_AUTH_RESERVED5 0x0800
199 
200 /* pmkid */
201 #define MAXPMKID 16
202 
203 #define DOT11_DEFAULT_RTS_LEN 2347
204 #define DOT11_DEFAULT_FRAG_LEN 2346
205 
206 #define DOT11_ICV_AES_LEN 8
207 #define DOT11_QOS_LEN 2
208 #define DOT11_IV_MAX_LEN 8
209 #define DOT11_A4_HDR_LEN 30
210 
211 #define HT_CAP_RX_STBC_NO 0x0
212 #define HT_CAP_RX_STBC_ONE_STREAM 0x1
213 
214 struct pmkid {
217 };
218 
219 struct pmkid_list {
221  struct pmkid pmkid[1];
222 };
223 
224 struct pmkid_cand {
227 };
228 
232 };
233 
234 #endif /* _BRCMU_WIFI_H_ */