cfg80211: remove enum ieee80211_band
[cascardo/linux.git] / drivers / staging / rtl8723au / include / ieee80211.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  ******************************************************************************/
15 #ifndef __IEEE80211_H
16 #define __IEEE80211_H
17
18 #include <osdep_service.h>
19 #include <drv_types.h>
20 #include "linux/ieee80211.h"
21 #include "wifi.h"
22
23 #include <linux/wireless.h>
24
25 #if (WIRELESS_EXT < 22)
26 #error "Obsolete pre 2007 wireless extensions are not supported"
27 #endif
28
29
30 #ifdef CONFIG_8723AU_AP_MODE
31
32 /* STA flags */
33 #define WLAN_STA_AUTH BIT(0)
34 #define WLAN_STA_ASSOC BIT(1)
35 #define WLAN_STA_PS BIT(2)
36 #define WLAN_STA_TIM BIT(3)
37 #define WLAN_STA_PERM BIT(4)
38 #define WLAN_STA_AUTHORIZED BIT(5)
39 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
40 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
41 #define WLAN_STA_PREAUTH BIT(8)
42 #define WLAN_STA_WME BIT(9)
43 #define WLAN_STA_MFP BIT(10)
44 #define WLAN_STA_HT BIT(11)
45 #define WLAN_STA_WPS BIT(12)
46 #define WLAN_STA_MAYBE_WPS BIT(13)
47 #define WLAN_STA_NONERP BIT(31)
48
49 #endif
50
51 #define WPA_CIPHER_NONE         BIT(0)
52 #define WPA_CIPHER_WEP40        BIT(1)
53 #define WPA_CIPHER_WEP104       BIT(2)
54 #define WPA_CIPHER_TKIP         BIT(3)
55 #define WPA_CIPHER_CCMP         BIT(4)
56
57
58
59 #define WPA_SELECTOR_LEN 4
60 extern u8 RTW_WPA_OUI23A_TYPE[] ;
61 extern u16 RTW_WPA_VERSION23A ;
62 extern u8 WPA_AUTH_KEY_MGMT_NONE23A[];
63 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
64 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
65 extern u8 WPA_CIPHER_SUITE_NONE23A[];
66 extern u8 WPA_CIPHER_SUITE_WEP4023A[];
67 extern u8 WPA_CIPHER_SUITE_TKIP23A[];
68 extern u8 WPA_CIPHER_SUITE_WRAP23A[];
69 extern u8 WPA_CIPHER_SUITE_CCMP23A[];
70 extern u8 WPA_CIPHER_SUITE_WEP10423A[];
71
72
73 #define RSN_HEADER_LEN 4
74 #define RSN_SELECTOR_LEN 4
75
76 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
77 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
78 extern u8 RSN_CIPHER_SUITE_NONE23A[];
79 extern u8 RSN_CIPHER_SUITE_WEP4023A[];
80 extern u8 RSN_CIPHER_SUITE_TKIP23A[];
81 extern u8 RSN_CIPHER_SUITE_WRAP23A[];
82 extern u8 RSN_CIPHER_SUITE_CCMP23A[];
83 extern u8 RSN_CIPHER_SUITE_WEP10423A[];
84
85 enum ratr_table_mode {
86         RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
87         RATR_INX_WIRELESS_NG = 1,       /*  GN or N */
88         RATR_INX_WIRELESS_NB = 2,       /*  BGN 20 Mhz 2SS 1SS  or BN */
89         RATR_INX_WIRELESS_N = 3,
90         RATR_INX_WIRELESS_GB = 4,
91         RATR_INX_WIRELESS_G = 5,
92         RATR_INX_WIRELESS_B = 6,
93         RATR_INX_WIRELESS_MC = 7,
94         RATR_INX_WIRELESS_AC_N = 8,
95 };
96
97 enum NETWORK_TYPE
98 {
99         WIRELESS_INVALID = 0,
100         /* Sub-Element */
101         /*  tx: cck only , rx: cck only, hw: cck */
102         WIRELESS_11B = BIT(0),
103         /*  tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */
104         WIRELESS_11G = BIT(1),
105         /*  tx: ofdm only, rx: ofdm only, hw: ofdm only */
106         WIRELESS_11A = BIT(2),
107         /*  tx: MCS only, rx: MCS & cck, hw: MCS & cck */
108         WIRELESS_11_24N = BIT(3),
109         /*  tx: MCS only, rx: MCS & ofdm, hw: ofdm only */
110         WIRELESS_11_5N = BIT(4),
111         /* WIRELESS_AUTO                = BIT(5), */
112         WIRELESS_AC = BIT(6),
113
114         /* Combination */
115          /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
116         WIRELESS_11BG = WIRELESS_11B|WIRELESS_11G,
117         /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
118         WIRELESS_11G_24N = WIRELESS_11G | WIRELESS_11_24N,
119         /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
120         WIRELESS_11A_5N = WIRELESS_11A | WIRELESS_11_5N,
121         /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
122         WIRELESS_11BG_24N = WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N,
123         /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
124         WIRELESS_11AGN = WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N |
125                                 WIRELESS_11_5N,
126         WIRELESS_11ABGN = WIRELESS_11A | WIRELESS_11B | WIRELESS_11G |
127                                 WIRELESS_11_24N | WIRELESS_11_5N,
128 };
129
130 #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
131 #define SUPPORTED_5G_NETTYPE_MSK (WIRELESS_11A | WIRELESS_11_5N)
132
133 #define IsSupported24G(NetType) (NetType & SUPPORTED_24G_NETTYPE_MSK ? true : false)
134 #define IsSupported5G(NetType) (NetType & SUPPORTED_5G_NETTYPE_MSK ? true : false)
135
136 #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
137 #define IsEnableHWOFDM(NetType) (NetType & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? true : false)
138
139 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
140 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
141 #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
142
143 #define IsSupportedTxCCK(NetType) (NetType & (WIRELESS_11B) ? true : false)
144 #define IsSupportedTxOFDM(NetType) (NetType & (WIRELESS_11G|WIRELESS_11A) ? true : false)
145 #define IsSupportedTxMCS(NetType) (NetType & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false)
146
147
148 #define MIN_FRAG_THRESHOLD     256U
149 #define MAX_FRAG_THRESHOLD     2346U
150
151 /* QoS,QOS */
152 #define NORMAL_ACK                      0
153 #define NO_ACK                          1
154 #define NON_EXPLICIT_ACK                2
155 #define BLOCK_ACK                       3
156
157 /* IEEE 802.11 defines */
158
159 #define P80211_OUI_LEN 3
160
161 struct ieee80211_snap_hdr {
162         u8    dsap;   /* always 0xAA */
163         u8    ssap;   /* always 0xAA */
164         u8    ctrl;   /* always 0x03 */
165         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
166 } __attribute__ ((packed));
167
168
169 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
170
171 #define WLAN_REASON_JOIN_WRONG_CHANNEL       65534
172 #define WLAN_REASON_EXPIRATION_CHK 65535
173
174 #define IEEE80211_CCK_RATE_LEN                  4
175 #define IEEE80211_NUM_OFDM_RATESLEN     8
176
177
178 #define IEEE80211_CCK_RATE_1MB                  0x02
179 #define IEEE80211_CCK_RATE_2MB                  0x04
180 #define IEEE80211_CCK_RATE_5MB                  0x0B
181 #define IEEE80211_CCK_RATE_11MB                 0x16
182 #define IEEE80211_OFDM_RATE_LEN                 8
183 #define IEEE80211_OFDM_RATE_6MB                 0x0C
184 #define IEEE80211_OFDM_RATE_9MB                 0x12
185 #define IEEE80211_OFDM_RATE_12MB                0x18
186 #define IEEE80211_OFDM_RATE_18MB                0x24
187 #define IEEE80211_OFDM_RATE_24MB                0x30
188 #define IEEE80211_OFDM_RATE_36MB                0x48
189 #define IEEE80211_OFDM_RATE_48MB                0x60
190 #define IEEE80211_OFDM_RATE_54MB                0x6C
191 #define IEEE80211_BASIC_RATE_MASK               0x80
192
193 #define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
194 #define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
195 #define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
196 #define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
197 #define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
198 #define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
199 #define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
200 #define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
201 #define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
202 #define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
203 #define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
204 #define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
205
206 #define IEEE80211_CCK_RATES_MASK                0x0000000F
207 #define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
208         IEEE80211_CCK_RATE_2MB_MASK)
209 #define IEEE80211_CCK_DEFAULT_RATES_MASK        (IEEE80211_CCK_BASIC_RATES_MASK | \
210         IEEE80211_CCK_RATE_5MB_MASK | \
211         IEEE80211_CCK_RATE_11MB_MASK)
212
213 #define IEEE80211_OFDM_RATES_MASK               0x00000FF0
214 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
215         IEEE80211_OFDM_RATE_12MB_MASK | \
216         IEEE80211_OFDM_RATE_24MB_MASK)
217 #define IEEE80211_OFDM_DEFAULT_RATES_MASK       (IEEE80211_OFDM_BASIC_RATES_MASK | \
218         IEEE80211_OFDM_RATE_9MB_MASK  | \
219         IEEE80211_OFDM_RATE_18MB_MASK | \
220         IEEE80211_OFDM_RATE_36MB_MASK | \
221         IEEE80211_OFDM_RATE_48MB_MASK | \
222         IEEE80211_OFDM_RATE_54MB_MASK)
223 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
224                                       IEEE80211_CCK_DEFAULT_RATES_MASK)
225
226 #define IEEE80211_NUM_OFDM_RATES            8
227 #define IEEE80211_NUM_CCK_RATES             4
228 #define IEEE80211_OFDM_SHIFT_MASK_A         4
229
230 #define WEP_KEYS 4
231
232
233 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
234  * only use 8, and then use extended rates for the remaining supported
235  * rates.  Other APs, however, stick all of their supported rates on the
236  * main rates information element... */
237 #define MAX_RATES_LENGTH        12
238 #define MAX_RATES_EX_LENGTH     16
239 #define MAX_CHANNEL_NUMBER      161
240 #define RTW_CH_MAX_2G_CHANNEL   14      /* Max channel in 2G band */
241
242 #define MAX_WPA_IE_LEN          256
243 #define MAX_WPS_IE_LEN          256
244 #define MAX_P2P_IE_LEN          256
245 #define MAX_WFD_IE_LEN          128
246
247 /*
248 join_res:
249 -1: authentication fail
250 -2: association fail
251 > 0: TID
252 */
253
254 #define MAXTID  16
255
256 #define WME_OUI_TYPE 2
257 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
258 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
259 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
260 #define WME_VERSION 1
261
262
263 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
264
265 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
266
267 /* Represent channel details, subset of ieee80211_channel */
268 struct rtw_ieee80211_channel {
269         /* enum nl80211_band band; */
270         /* u16 center_freq; */
271         u16 hw_value;
272         u32 flags;
273         /* int max_antenna_gain; */
274         /* int max_power; */
275         /* int max_reg_power; */
276         /* bool beacon_found; */
277         /* u32 orig_flags; */
278         /* int orig_mag; */
279         /* int orig_mpwr; */
280 };
281
282 #define CHAN_FMT \
283         /*"band:%d, "*/ \
284         /*"center_freq:%u, "*/ \
285         "hw_value:%u, " \
286         "flags:0x%08x" \
287         /*"max_antenna_gain:%d\n"*/ \
288         /*"max_power:%d\n"*/ \
289         /*"max_reg_power:%d\n"*/ \
290         /*"beacon_found:%u\n"*/ \
291         /*"orig_flags:0x%08x\n"*/ \
292         /*"orig_mag:%d\n"*/ \
293         /*"orig_mpwr:%d\n"*/
294
295 #define CHAN_ARG(channel) \
296         /*(channel)->band*/ \
297         /*, (channel)->center_freq*/ \
298         (channel)->hw_value \
299         , (channel)->flags \
300         /*, (channel)->max_antenna_gain*/ \
301         /*, (channel)->max_power*/ \
302         /*, (channel)->max_reg_power*/ \
303         /*, (channel)->beacon_found*/ \
304         /*, (channel)->orig_flags*/ \
305         /*, (channel)->orig_mag*/ \
306         /*, (channel)->orig_mpwr*/ \
307
308 u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen);
309
310 u8 hal_ch_offset_to_secondary_ch_offset23a(u8 ch_offset);
311 u8 *rtw_set_ie23a_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt);
312 u8 *rtw_set_ie23a_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset);
313
314 u8 *rtw_get_ie23a(u8*pbuf, int index, int *len, int limit);
315 u8 *rtw_get_ie23a_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
316 int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
317
318 void rtw_set_supported_rate23a(u8 *SupportedRates, uint mode);
319
320 int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
321 int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
322
323 const u8 *rtw_get_wps_attr23a(const u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr);
324 const u8 *rtw_get_wps_attr_content23a(const u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content);
325
326 uint    rtw_get_rateset_len23a(u8       *rateset);
327
328 struct registry_priv;
329 int rtw_generate_ie23a(struct registry_priv *pregistrypriv);
330
331
332 int rtw_get_bit_value_from_ieee_value23a(u8 val);
333
334 int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel);
335
336 void rtw_get_bcn_info23a(struct wlan_network *pnetwork);
337
338 u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
339                     struct ieee80211_mcs_info *mcs);
340
341 #endif /* IEEE80211_H */