These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / rtl8188eu / 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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __IEEE80211_H
21 #define __IEEE80211_H
22
23 #include <osdep_service.h>
24 #include <drv_types.h>
25 #include "wifi.h"
26 #include <linux/wireless.h>
27
28 #define MGMT_QUEUE_NUM 5
29
30 #define ETH_ALEN        6
31 #define ETH_TYPE_LEN            2
32 #define PAYLOAD_TYPE_LEN        1
33
34 #ifdef CONFIG_88EU_AP_MODE
35
36 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
37
38 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
39 enum {
40         RTL871X_HOSTAPD_FLUSH = 1,
41         RTL871X_HOSTAPD_ADD_STA = 2,
42         RTL871X_HOSTAPD_REMOVE_STA = 3,
43         RTL871X_HOSTAPD_GET_INFO_STA = 4,
44         /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
45         RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
46         RTL871X_SET_ENCRYPTION = 6,
47         RTL871X_GET_ENCRYPTION = 7,
48         RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
49         RTL871X_HOSTAPD_GET_RID = 9,
50         RTL871X_HOSTAPD_SET_RID = 10,
51         RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
52         RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
53         RTL871X_HOSTAPD_MLME = 13,
54         RTL871X_HOSTAPD_SCAN_REQ = 14,
55         RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
56         RTL871X_HOSTAPD_SET_BEACON = 16,
57         RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
58         RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
59         RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
60         RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
61         RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
62         RTL871X_HOSTAPD_ACL_ADD_STA = 22,
63         RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
64 };
65
66 /* STA flags */
67 #define WLAN_STA_AUTH BIT(0)
68 #define WLAN_STA_ASSOC BIT(1)
69 #define WLAN_STA_PS BIT(2)
70 #define WLAN_STA_TIM BIT(3)
71 #define WLAN_STA_PERM BIT(4)
72 #define WLAN_STA_AUTHORIZED BIT(5)
73 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
74 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
75 #define WLAN_STA_PREAUTH BIT(8)
76 #define WLAN_STA_WME BIT(9)
77 #define WLAN_STA_MFP BIT(10)
78 #define WLAN_STA_HT BIT(11)
79 #define WLAN_STA_WPS BIT(12)
80 #define WLAN_STA_MAYBE_WPS BIT(13)
81 #define WLAN_STA_NONERP BIT(31)
82
83 #endif
84
85 #define IEEE_CMD_SET_WPA_PARAM                  1
86 #define IEEE_CMD_SET_WPA_IE                             2
87 #define IEEE_CMD_SET_ENCRYPTION                 3
88 #define IEEE_CMD_MLME                                           4
89
90 #define IEEE_PARAM_WPA_ENABLED                          1
91 #define IEEE_PARAM_TKIP_COUNTERMEASURES         2
92 #define IEEE_PARAM_DROP_UNENCRYPTED                     3
93 #define IEEE_PARAM_PRIVACY_INVOKED                      4
94 #define IEEE_PARAM_AUTH_ALGS                                    5
95 #define IEEE_PARAM_IEEE_802_1X                          6
96 #define IEEE_PARAM_WPAX_SELECT                          7
97
98 #define AUTH_ALG_OPEN_SYSTEM                    0x1
99 #define AUTH_ALG_SHARED_KEY                     0x2
100 #define AUTH_ALG_LEAP                           0x00000004
101
102 #define IEEE_MLME_STA_DEAUTH                            1
103 #define IEEE_MLME_STA_DISASSOC                  2
104
105 #define IEEE_CRYPT_ERR_UNKNOWN_ALG                      2
106 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR                     3
107 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED                4
108 #define IEEE_CRYPT_ERR_KEY_SET_FAILED                   5
109 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED                6
110 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED         7
111
112
113 #define IEEE_CRYPT_ALG_NAME_LEN                 16
114
115 #define WPA_CIPHER_NONE         BIT(0)
116 #define WPA_CIPHER_WEP40        BIT(1)
117 #define WPA_CIPHER_WEP104 BIT(2)
118 #define WPA_CIPHER_TKIP         BIT(3)
119 #define WPA_CIPHER_CCMP         BIT(4)
120
121
122
123 #define WPA_SELECTOR_LEN 4
124 extern u8 RTW_WPA_OUI_TYPE[];
125 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
126 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
127 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
128 extern u8 WPA_CIPHER_SUITE_NONE[];
129 extern u8 WPA_CIPHER_SUITE_WEP40[];
130 extern u8 WPA_CIPHER_SUITE_TKIP[];
131 extern u8 WPA_CIPHER_SUITE_WRAP[];
132 extern u8 WPA_CIPHER_SUITE_CCMP[];
133 extern u8 WPA_CIPHER_SUITE_WEP104[];
134
135
136 #define RSN_HEADER_LEN 4
137 #define RSN_SELECTOR_LEN 4
138
139 extern u16 RSN_VERSION_BSD;
140 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
141 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
142 extern u8 RSN_CIPHER_SUITE_NONE[];
143 extern u8 RSN_CIPHER_SUITE_WEP40[];
144 extern u8 RSN_CIPHER_SUITE_TKIP[];
145 extern u8 RSN_CIPHER_SUITE_WRAP[];
146 extern u8 RSN_CIPHER_SUITE_CCMP[];
147 extern u8 RSN_CIPHER_SUITE_WEP104[];
148
149 enum ratr_table_mode {
150         RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
151         RATR_INX_WIRELESS_NG = 1,       /*  GN or N */
152         RATR_INX_WIRELESS_NB = 2,       /*  BGN 20 Mhz 2SS 1SS  or BN */
153         RATR_INX_WIRELESS_N = 3,
154         RATR_INX_WIRELESS_GB = 4,
155         RATR_INX_WIRELESS_G = 5,
156         RATR_INX_WIRELESS_B = 6,
157         RATR_INX_WIRELESS_MC = 7,
158         RATR_INX_WIRELESS_AC_N = 8,
159 };
160
161 enum NETWORK_TYPE {
162         WIRELESS_INVALID = 0,
163         /* Sub-Element */
164         WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */
165         WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/
166         WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */
167         WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */
168         WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */
169         WIRELESS_AC             = BIT(6),
170
171         /* Combination */
172         /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
173         WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
174         /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
175         WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N),
176         /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
177         WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N),
178         /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
179         WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
180         /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
181         WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N |
182                           WIRELESS_11_5N),
183         WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G |
184                            WIRELESS_11_24N | WIRELESS_11_5N),
185 };
186
187 #define SUPPORTED_24G_NETTYPE_MSK                               \
188          (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
189 #define SUPPORTED_5G_NETTYPE_MSK                                \
190          (WIRELESS_11A | WIRELESS_11_5N)
191
192 #define IsSupported24G(NetType)                                 \
193         ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
194 #define IsSupported5G(NetType)                                  \
195         ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false)
196
197 #define IsEnableHWCCK(NetType)                                  \
198         IsSupported24G(NetType)
199 #define IsEnableHWOFDM(NetType)                                 \
200         ((NetType) & (WIRELESS_11G | WIRELESS_11_24N |          \
201          SUPPORTED_5G_NETTYPE_MSK) ? true : false)
202
203 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
204 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
205 #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
206
207 #define IsSupportedTxCCK(NetType)                               \
208         ((NetType) & (WIRELESS_11B) ? true : false)
209 #define IsSupportedTxOFDM(NetType)                              \
210         ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false)
211 #define IsSupportedTxMCS(NetType)                               \
212         ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false)
213
214
215 struct ieee_param {
216         u32 cmd;
217         u8 sta_addr[ETH_ALEN];
218         union {
219                 struct {
220                         u8 name;
221                         u32 value;
222                 } wpa_param;
223                 struct {
224                         u32 len;
225                         u8 reserved[32];
226                         u8 data[0];
227                 } wpa_ie;
228                 struct {
229                         int command;
230                         int reason_code;
231                 } mlme;
232                 struct {
233                         u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
234                         u8 set_tx;
235                         u32 err;
236                         u8 idx;
237                         u8 seq[8]; /* sequence counter (set: RX, get: TX) */
238                         u16 key_len;
239                         u8 key[0];
240                 } crypt;
241 #ifdef CONFIG_88EU_AP_MODE
242                 struct {
243                         u16 aid;
244                         u16 capability;
245                         int flags;
246                         u8 tx_supp_rates[16];
247                         struct rtw_ieee80211_ht_cap ht_cap;
248                 } add_sta;
249                 struct {
250                         u8      reserved[2];/* for set max_num_sta */
251                         u8      buf[0];
252                 } bcn_ie;
253 #endif
254
255         } u;
256 };
257
258 #ifdef CONFIG_88EU_AP_MODE
259 struct ieee_param_ex {
260         u32 cmd;
261         u8 sta_addr[ETH_ALEN];
262         u8 data[0];
263 };
264
265 struct sta_data {
266         u16 aid;
267         u16 capability;
268         int flags;
269         u32 sta_set;
270         u8 tx_supp_rates[16];
271         u32 tx_supp_rates_len;
272         struct rtw_ieee80211_ht_cap ht_cap;
273         u64     rx_pkts;
274         u64     rx_bytes;
275         u64     rx_drops;
276         u64     tx_pkts;
277         u64     tx_bytes;
278         u64     tx_drops;
279 };
280 #endif
281
282 #define IEEE80211_DATA_LEN              2304
283 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
284    6.2.1.1.2.
285
286    The figure in section 7.1.2 suggests a body size of up to 2312
287    bytes is allowed, which is a bit confusing, I suspect this
288    represents the 2304 bytes of real data, plus a possible 8 bytes of
289    WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
290
291
292 #define IEEE80211_HLEN                  30
293 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
294
295
296 /* this is stolen from ipw2200 driver */
297 #define IEEE_IBSS_MAC_HASH_SIZE 31
298
299 struct ieee_ibss_seq {
300         u8 mac[ETH_ALEN];
301         u16 seq_num;
302         u16 frag_num;
303         unsigned long packet_time;
304         struct list_head list;
305 };
306
307 struct rtw_ieee80211_hdr {
308         __le16 frame_ctl;
309         __le16 duration_id;
310         u8 addr1[ETH_ALEN];
311         u8 addr2[ETH_ALEN];
312         u8 addr3[ETH_ALEN];
313         u16 seq_ctl;
314         u8 addr4[ETH_ALEN];
315 } __packed;
316
317 struct rtw_ieee80211_hdr_3addr {
318         __le16 frame_ctl;
319         __le16 duration_id;
320         u8 addr1[ETH_ALEN];
321         u8 addr2[ETH_ALEN];
322         u8 addr3[ETH_ALEN];
323         u16 seq_ctl;
324 } __packed;
325
326 struct rtw_ieee80211_hdr_qos {
327         __le16 frame_ctl;
328         __le16 duration_id;
329         u8 addr1[ETH_ALEN];
330         u8 addr2[ETH_ALEN];
331         u8 addr3[ETH_ALEN];
332         u16 seq_ctl;
333         u8 addr4[ETH_ALEN];
334         u16     qc;
335 }  __packed;
336
337 struct rtw_ieee80211_hdr_3addr_qos {
338         __le16 frame_ctl;
339         __le16 duration_id;
340         u8 addr1[ETH_ALEN];
341         u8 addr2[ETH_ALEN];
342         u8 addr3[ETH_ALEN];
343         u16 seq_ctl;
344         u16     qc;
345 }  __packed;
346
347 struct eapol {
348         u8 snap[6];
349         u16 ethertype;
350         u8 version;
351         u8 type;
352         u16 length;
353 } __packed;
354
355 enum eap_type {
356         EAP_PACKET = 0,
357         EAPOL_START,
358         EAPOL_LOGOFF,
359         EAPOL_KEY,
360         EAPOL_ENCAP_ASF_ALERT
361 };
362
363 #define IEEE80211_3ADDR_LEN 24
364 #define IEEE80211_4ADDR_LEN 30
365 #define IEEE80211_FCS_LEN    4
366
367 #define MIN_FRAG_THRESHOLD     256U
368 #define MAX_FRAG_THRESHOLD     2346U
369
370 /* Frame control field constants */
371 #define RTW_IEEE80211_FCTL_VERS         0x0003
372 #define RTW_IEEE80211_FCTL_FTYPE        0x000c
373 #define RTW_IEEE80211_FCTL_STYPE        0x00f0
374 #define RTW_IEEE80211_FCTL_TODS         0x0100
375 #define RTW_IEEE80211_FCTL_FROMDS       0x0200
376 #define RTW_IEEE80211_FCTL_MOREFRAGS    0x0400
377 #define RTW_IEEE80211_FCTL_RETRY        0x0800
378 #define RTW_IEEE80211_FCTL_PM           0x1000
379 #define RTW_IEEE80211_FCTL_MOREDATA     0x2000
380 #define RTW_IEEE80211_FCTL_PROTECTED    0x4000
381 #define RTW_IEEE80211_FCTL_ORDER        0x8000
382 #define RTW_IEEE80211_FCTL_CTL_EXT      0x0f00
383
384 #define RTW_IEEE80211_FTYPE_MGMT        0x0000
385 #define RTW_IEEE80211_FTYPE_CTL         0x0004
386 #define RTW_IEEE80211_FTYPE_DATA        0x0008
387 #define RTW_IEEE80211_FTYPE_EXT         0x000c
388
389 /* management */
390 #define RTW_IEEE80211_STYPE_ASSOC_REQ   0x0000
391 #define RTW_IEEE80211_STYPE_ASSOC_RESP  0x0010
392 #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
393 #define RTW_IEEE80211_STYPE_REASSOC_RESP        0x0030
394 #define RTW_IEEE80211_STYPE_PROBE_REQ   0x0040
395 #define RTW_IEEE80211_STYPE_PROBE_RESP  0x0050
396 #define RTW_IEEE80211_STYPE_BEACON      0x0080
397 #define RTW_IEEE80211_STYPE_ATIM        0x0090
398 #define RTW_IEEE80211_STYPE_DISASSOC    0x00A0
399 #define RTW_IEEE80211_STYPE_AUTH        0x00B0
400 #define RTW_IEEE80211_STYPE_DEAUTH      0x00C0
401 #define RTW_IEEE80211_STYPE_ACTION      0x00D0
402
403 /* control */
404 #define RTW_IEEE80211_STYPE_CTL_EXT     0x0060
405 #define RTW_IEEE80211_STYPE_BACK_REQ    0x0080
406 #define RTW_IEEE80211_STYPE_BACK        0x0090
407 #define RTW_IEEE80211_STYPE_PSPOLL      0x00A0
408 #define RTW_IEEE80211_STYPE_RTS         0x00B0
409 #define RTW_IEEE80211_STYPE_CTS         0x00C0
410 #define RTW_IEEE80211_STYPE_ACK         0x00D0
411 #define RTW_IEEE80211_STYPE_CFEND       0x00E0
412 #define RTW_IEEE80211_STYPE_CFENDACK    0x00F0
413
414 /* data */
415 #define RTW_IEEE80211_STYPE_DATA        0x0000
416 #define RTW_IEEE80211_STYPE_DATA_CFACK  0x0010
417 #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
418 #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL      0x0030
419 #define RTW_IEEE80211_STYPE_NULLFUNC    0x0040
420 #define RTW_IEEE80211_STYPE_CFACK       0x0050
421 #define RTW_IEEE80211_STYPE_CFPOLL      0x0060
422 #define RTW_IEEE80211_STYPE_CFACKPOLL   0x0070
423 #define RTW_IEEE80211_STYPE_QOS_DATA    0x0080
424 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK      0x0090
425 #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL     0x00A0
426 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL  0x00B0
427 #define RTW_IEEE80211_STYPE_QOS_NULLFUNC        0x00C0
428 #define RTW_IEEE80211_STYPE_QOS_CFACK           0x00D0
429 #define RTW_IEEE80211_STYPE_QOS_CFPOLL          0x00E0
430 #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL       0x00F0
431
432 /* sequence control field */
433 #define RTW_IEEE80211_SCTL_FRAG 0x000F
434 #define RTW_IEEE80211_SCTL_SEQ  0xFFF0
435
436
437 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
438 #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
439 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
440
441 /* QoS, QOS */
442 #define NORMAL_ACK                      0
443 #define NO_ACK                          1
444 #define NON_EXPLICIT_ACK                2
445 #define BLOCK_ACK                       3
446
447 #ifndef ETH_P_PAE
448 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
449 #endif /* ETH_P_PAE */
450
451 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
452
453 #define ETH_P_ECONET    0x0018
454
455 #ifndef ETH_P_80211_RAW
456 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
457 #endif
458
459 /* IEEE 802.11 defines */
460
461 #define P80211_OUI_LEN 3
462
463 struct ieee80211_snap_hdr {
464         u8    dsap;   /* always 0xAA */
465         u8    ssap;   /* always 0xAA */
466         u8    ctrl;   /* always 0x03 */
467         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
468 } __packed;
469
470 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
471
472 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
473 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
474
475 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
476
477 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
478 #define WLAN_GET_SEQ_SEQ(seq)  ((seq) & RTW_IEEE80211_SCTL_SEQ)
479
480 /* Non standard?  Not in <linux/ieee80211.h> */
481 #define WLAN_REASON_EXPIRATION_CHK 65535
482
483 #define IEEE80211_MGMT_HDR_LEN 24
484 #define IEEE80211_DATA_HDR3_LEN 24
485 #define IEEE80211_DATA_HDR4_LEN 30
486
487
488 #define IEEE80211_STATMASK_SIGNAL (1<<0)
489 #define IEEE80211_STATMASK_RSSI (1<<1)
490 #define IEEE80211_STATMASK_NOISE (1<<2)
491 #define IEEE80211_STATMASK_RATE (1<<3)
492 #define IEEE80211_STATMASK_WEMASK 0x7
493
494
495 #define IEEE80211_CCK_MODULATION    (1<<0)
496 #define IEEE80211_OFDM_MODULATION   (1<<1)
497
498 #define IEEE80211_24GHZ_BAND     (1<<0)
499 #define IEEE80211_52GHZ_BAND     (1<<1)
500
501 #define IEEE80211_CCK_RATE_LEN                  4
502 #define IEEE80211_NUM_OFDM_RATESLEN     8
503
504
505 #define IEEE80211_CCK_RATE_1MB                  0x02
506 #define IEEE80211_CCK_RATE_2MB                  0x04
507 #define IEEE80211_CCK_RATE_5MB                  0x0B
508 #define IEEE80211_CCK_RATE_11MB                 0x16
509 #define IEEE80211_OFDM_RATE_LEN                 8
510 #define IEEE80211_OFDM_RATE_6MB                 0x0C
511 #define IEEE80211_OFDM_RATE_9MB                 0x12
512 #define IEEE80211_OFDM_RATE_12MB                0x18
513 #define IEEE80211_OFDM_RATE_18MB                0x24
514 #define IEEE80211_OFDM_RATE_24MB                0x30
515 #define IEEE80211_OFDM_RATE_36MB                0x48
516 #define IEEE80211_OFDM_RATE_48MB                0x60
517 #define IEEE80211_OFDM_RATE_54MB                0x6C
518 #define IEEE80211_BASIC_RATE_MASK               0x80
519
520 #define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
521 #define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
522 #define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
523 #define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
524 #define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
525 #define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
526 #define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
527 #define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
528 #define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
529 #define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
530 #define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
531 #define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
532
533 #define IEEE80211_CCK_RATES_MASK                0x0000000F
534 #define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
535         IEEE80211_CCK_RATE_2MB_MASK)
536 #define IEEE80211_CCK_DEFAULT_RATES_MASK                                \
537         (IEEE80211_CCK_BASIC_RATES_MASK |                               \
538         IEEE80211_CCK_RATE_5MB_MASK |                                   \
539         IEEE80211_CCK_RATE_11MB_MASK)
540
541 #define IEEE80211_OFDM_RATES_MASK               0x00000FF0
542 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
543         IEEE80211_OFDM_RATE_12MB_MASK |                                 \
544         IEEE80211_OFDM_RATE_24MB_MASK)
545 #define IEEE80211_OFDM_DEFAULT_RATES_MASK                               \
546         (IEEE80211_OFDM_BASIC_RATES_MASK |                              \
547         IEEE80211_OFDM_RATE_9MB_MASK  |                                 \
548         IEEE80211_OFDM_RATE_18MB_MASK |                                 \
549         IEEE80211_OFDM_RATE_36MB_MASK |                                 \
550         IEEE80211_OFDM_RATE_48MB_MASK |                                 \
551         IEEE80211_OFDM_RATE_54MB_MASK)
552 #define IEEE80211_DEFAULT_RATES_MASK                                    \
553         (IEEE80211_OFDM_DEFAULT_RATES_MASK |                            \
554          IEEE80211_CCK_DEFAULT_RATES_MASK)
555
556 #define IEEE80211_NUM_OFDM_RATES        8
557 #define IEEE80211_NUM_CCK_RATES         4
558 #define IEEE80211_OFDM_SHIFT_MASK_A     4
559
560 /* NOTE: This data is for statistical purposes; not all hardware provides this
561  *       information for frames received.  Not setting these will not cause
562  *       any adverse affects. */
563 struct ieee80211_rx_stats {
564         /* u32 mac_time[2]; */
565         s8 rssi;
566         u8 signal;
567         u8 noise;
568         u8 received_channel;
569         u16 rate; /* in 100 kbps */
570         /* u8 control; */
571         u8 mask;
572         u8 freq;
573         u16 len;
574 };
575
576 /* IEEE 802.11 requires that STA supports concurrent reception of at least
577  * three fragmented frames. This define can be increased to support more
578  * concurrent frames, but it should be noted that each entry can consume about
579  * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
580 #define IEEE80211_FRAG_CACHE_LEN 4
581
582 struct ieee80211_frag_entry {
583         u32 first_frag_time;
584         uint seq;
585         uint last_frag;
586         uint qos;   /* jackson */
587         uint tid;       /* jackson */
588         struct sk_buff *skb;
589         u8 src_addr[ETH_ALEN];
590         u8 dst_addr[ETH_ALEN];
591 };
592
593 struct ieee80211_stats {
594         uint tx_unicast_frames;
595         uint tx_multicast_frames;
596         uint tx_fragments;
597         uint tx_unicast_octets;
598         uint tx_multicast_octets;
599         uint tx_deferred_transmissions;
600         uint tx_single_retry_frames;
601         uint tx_multiple_retry_frames;
602         uint tx_retry_limit_exceeded;
603         uint tx_discards;
604         uint rx_unicast_frames;
605         uint rx_multicast_frames;
606         uint rx_fragments;
607         uint rx_unicast_octets;
608         uint rx_multicast_octets;
609         uint rx_fcs_errors;
610         uint rx_discards_no_buffer;
611         uint tx_discards_wrong_sa;
612         uint rx_discards_undecryptable;
613         uint rx_message_in_msg_fragments;
614         uint rx_message_in_bad_msg_fragments;
615 };
616
617 struct ieee80211_softmac_stats {
618         uint rx_ass_ok;
619         uint rx_ass_err;
620         uint rx_probe_rq;
621         uint tx_probe_rs;
622         uint tx_beacons;
623         uint rx_auth_rq;
624         uint rx_auth_rs_ok;
625         uint rx_auth_rs_err;
626         uint tx_auth_rq;
627         uint no_auth_rs;
628         uint no_ass_rs;
629         uint tx_ass_rq;
630         uint rx_ass_rq;
631         uint tx_probe_rq;
632         uint reassoc;
633         uint swtxstop;
634         uint swtxawake;
635 };
636
637 #define SEC_KEY_1       (1<<0)
638 #define SEC_KEY_2       (1<<1)
639 #define SEC_KEY_3       (1<<2)
640 #define SEC_KEY_4       (1<<3)
641 #define SEC_ACTIVE_KEY  (1<<4)
642 #define SEC_AUTH_MODE   (1<<5)
643 #define SEC_UNICAST_GROUP (1<<6)
644 #define SEC_LEVEL       (1<<7)
645 #define SEC_ENABLED     (1<<8)
646
647 #define SEC_LEVEL_0      0 /* None */
648 #define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
649 #define SEC_LEVEL_2      2 /* Level 1 + TKIP */
650 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
651 #define SEC_LEVEL_3      4 /* Level 2 + CCMP */
652
653 #define WEP_KEYS 4
654 #define WEP_KEY_LEN 13
655
656 struct ieee80211_security {
657         u16 active_key:2,
658         enabled:1,
659         auth_mode:2,
660         auth_algo:4,
661         unicast_uses_group:1;
662         u8 key_sizes[WEP_KEYS];
663         u8 keys[WEP_KEYS][WEP_KEY_LEN];
664         u8 level;
665         u16 flags;
666 } __packed;
667
668 /*
669
670  802.11 data frame from AP
671
672       ,-------------------------------------------------------------------.
673 Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
674       |------|------|---------|---------|---------|------|---------|------|
675 Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
676       |      | tion | (BSSID) |  |       | ence |  data   |      |
677       `-------------------------------------------------------------------'
678
679 Total: 28-2340 bytes
680
681 */
682
683 struct ieee80211_header_data {
684         u16 frame_ctl;
685         u16 duration_id;
686         u8 addr1[6];
687         u8 addr2[6];
688         u8 addr3[6];
689         u16 seq_ctrl;
690 };
691
692 #define BEACON_PROBE_SSID_ID_POSITION 12
693
694 /* Management Frame Information Element Types */
695 #define MFIE_TYPE_SSID          0
696 #define MFIE_TYPE_RATES         1
697 #define MFIE_TYPE_FH_SET        2
698 #define MFIE_TYPE_DS_SET        3
699 #define MFIE_TYPE_CF_SET        4
700 #define MFIE_TYPE_TIM           5
701 #define MFIE_TYPE_IBSS_SET      6
702 #define MFIE_TYPE_CHALLENGE     16
703 #define MFIE_TYPE_ERP           42
704 #define MFIE_TYPE_RSN           48
705 #define MFIE_TYPE_RATES_EX      50
706 #define MFIE_TYPE_GENERIC       221
707
708 struct ieee80211_info_element_hdr {
709         u8 id;
710         u8 len;
711 } __packed;
712
713 struct ieee80211_info_element {
714         u8 id;
715         u8 len;
716         u8 data[0];
717 } __packed;
718
719 /*
720  * These are the data types that can make up management packets
721  *
722         u16 auth_algorithm;
723         u16 auth_sequence;
724         u16 beacon_interval;
725         u16 capability;
726         u8 current_ap[ETH_ALEN];
727         u16 listen_interval;
728         struct {
729                 u16 association_id:14, reserved:2;
730         } __packed;
731         u32 time_stamp[2];
732         u16 reason;
733         u16 status;
734 */
735
736 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
737 #define IEEE80211_DEFAULT_BASIC_RATE 10
738
739 struct ieee80211_authentication {
740         struct ieee80211_header_data header;
741         u16 algorithm;
742         u16 transaction;
743         u16 status;
744         /* struct ieee80211_info_element_hdr info_element; */
745 } __packed;
746
747 struct ieee80211_probe_response {
748         struct ieee80211_header_data header;
749         u32 time_stamp[2];
750         u16 beacon_interval;
751         u16 capability;
752         struct ieee80211_info_element info_element;
753 } __packed;
754
755 struct ieee80211_probe_request {
756         struct ieee80211_header_data header;
757 } __packed;
758
759 struct ieee80211_assoc_request_frame {
760         struct rtw_ieee80211_hdr_3addr header;
761         u16 capability;
762         u16 listen_interval;
763         struct ieee80211_info_element_hdr info_element;
764 } __packed;
765
766 struct ieee80211_assoc_response_frame {
767         struct rtw_ieee80211_hdr_3addr header;
768         u16 capability;
769         u16 status;
770         u16 aid;
771 } __packed;
772
773 struct ieee80211_txb {
774         u8 nr_frags;
775         u8 encrypted;
776         u16 reserved;
777         u16 frag_size;
778         u16 payload_size;
779         struct sk_buff *fragments[0];
780 };
781
782
783 /* SWEEP TABLE ENTRIES NUMBER*/
784 #define MAX_SWEEP_TAB_ENTRIES             42
785 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
786 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
787  * only use 8, and then use extended rates for the remaining supported
788  * rates.  Other APs, however, stick all of their supported rates on the
789  * main rates information element... */
790 #define MAX_RATES_LENGTH                ((u8)12)
791 #define MAX_RATES_EX_LENGTH             ((u8)16)
792 #define MAX_NETWORK_COUNT               128
793 #define MAX_CHANNEL_NUMBER              161
794 #define IEEE80211_SOFTMAC_SCAN_TIME     400
795 /* HZ / 2) */
796 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
797
798 #define CRC_LENGTH               4U
799
800 #define MAX_WPA_IE_LEN (256)
801 #define MAX_WPS_IE_LEN (512)
802 #define MAX_P2P_IE_LEN (256)
803 #define MAX_WFD_IE_LEN (128)
804
805 #define NETWORK_EMPTY_ESSID (1<<0)
806 #define NETWORK_HAS_OFDM    (1<<1)
807 #define NETWORK_HAS_CCK     (1<<2)
808
809 #define IEEE80211_DTIM_MBCAST 4
810 #define IEEE80211_DTIM_UCAST 2
811 #define IEEE80211_DTIM_VALID 1
812 #define IEEE80211_DTIM_INVALID 0
813
814 #define IEEE80211_PS_DISABLED 0
815 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
816 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
817 #define IW_ESSID_MAX_SIZE 32
818 /*
819 join_res:
820 -1: authentication fail
821 -2: association fail
822 > 0: TID
823 */
824
825 enum ieee80211_state {
826         /* the card is not linked at all */
827         IEEE80211_NOLINK = 0,
828
829         /* IEEE80211_ASSOCIATING* are for BSS client mode
830          * the driver shall not perform RX filtering unless
831          * the state is LINKED.
832          * The driver shall just check for the state LINKED and
833          * defaults to NOLINK for ALL the other states (including
834          * LINKED_SCANNING)
835          */
836
837         /* the association procedure will start (wq scheduling)*/
838         IEEE80211_ASSOCIATING,
839         IEEE80211_ASSOCIATING_RETRY,
840
841         /* the association procedure is sending AUTH request*/
842         IEEE80211_ASSOCIATING_AUTHENTICATING,
843
844         /* the association procedure has successfully authentcated
845          * and is sending association request
846          */
847         IEEE80211_ASSOCIATING_AUTHENTICATED,
848
849         /* the link is ok. the card associated to a BSS or linked
850          * to a ibss cell or acting as an AP and creating the bss
851          */
852         IEEE80211_LINKED,
853
854         /* same as LINKED, but the driver shall apply RX filter
855          * rules as we are in NO_LINK mode. As the card is still
856          * logically linked, but it is doing a syncro site survey
857          * then it will be back to LINKED state.
858          */
859         IEEE80211_LINKED_SCANNING,
860
861 };
862
863 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
864 #define DEFAULT_FTS 2346
865
866 static inline int is_multicast_mac_addr(const u8 *addr)
867 {
868         return ((addr[0] != 0xff) && (0x01 & addr[0]));
869 }
870
871 static inline int is_broadcast_mac_addr(const u8 *addr)
872 {
873         return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
874                (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff);
875 }
876
877 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
878 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
879
880 struct tx_pending {
881         int frag;
882         struct ieee80211_txb *txb;
883 };
884
885 #define MAXTID  16
886
887 #define IEEE_A      (1<<0)
888 #define IEEE_B      (1<<1)
889 #define IEEE_G      (1<<2)
890 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
891
892 /* Baron move to ieee80211.c */
893 int ieee80211_is_empty_essid(const char *essid, int essid_len);
894 int ieee80211_get_hdrlen(u16 fc);
895
896 /* Action category code */
897 enum rtw_ieee80211_category {
898         RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
899         RTW_WLAN_CATEGORY_QOS = 1,
900         RTW_WLAN_CATEGORY_DLS = 2,
901         RTW_WLAN_CATEGORY_BACK = 3,
902         RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
903         RTW_WLAN_CATEGORY_RADIO_MEASUREMENT  = 5,
904         RTW_WLAN_CATEGORY_FT = 6,
905         RTW_WLAN_CATEGORY_HT = 7,
906         RTW_WLAN_CATEGORY_SA_QUERY = 8,
907         RTW_WLAN_CATEGORY_TDLS = 12,
908         RTW_WLAN_CATEGORY_WMM = 17,
909         RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
910 };
911
912 /* SPECTRUM_MGMT action code */
913 enum rtw_ieee80211_spectrum_mgmt_actioncode {
914         RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
915         RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
916         RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
917         RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
918         RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
919         RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
920 };
921
922 enum _PUBLIC_ACTION {
923         ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
924         ACT_PUBLIC_DSE_ENABLE = 1,
925         ACT_PUBLIC_DSE_DEENABLE = 2,
926         ACT_PUBLIC_DSE_REG_LOCATION = 3,
927         ACT_PUBLIC_EXT_CHL_SWITCH = 4,
928         ACT_PUBLIC_DSE_MSR_REQ = 5,
929         ACT_PUBLIC_DSE_MSR_RPRT = 6,
930         ACT_PUBLIC_MP = 7, /*  Measurement Pilot */
931         ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
932         ACT_PUBLIC_VENDOR = 9, /*  for WIFI_DIRECT */
933         ACT_PUBLIC_GAS_INITIAL_REQ = 10,
934         ACT_PUBLIC_GAS_INITIAL_RSP = 11,
935         ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
936         ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
937         ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
938         ACT_PUBLIC_LOCATION_TRACK = 15,
939         ACT_PUBLIC_MAX
940 };
941
942 /* BACK action code */
943 enum rtw_ieee80211_back_actioncode {
944         RTW_WLAN_ACTION_ADDBA_REQ = 0,
945         RTW_WLAN_ACTION_ADDBA_RESP = 1,
946         RTW_WLAN_ACTION_DELBA = 2,
947 };
948
949 /* HT features action code */
950 enum rtw_ieee80211_ht_actioncode {
951         RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
952         RTW_WLAN_ACTION_SM_PS = 1,
953         RTW_WLAN_ACTION_PSPM = 2,
954         RTW_WLAN_ACTION_PCO_PHASE = 3,
955         RTW_WLAN_ACTION_MIMO_CSI_MX = 4,
956         RTW_WLAN_ACTION_MIMO_NONCP_BF = 5,
957         RTW_WLAN_ACTION_MIMP_CP_BF = 6,
958         RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7,
959         RTW_WLAN_ACTION_HI_INFO_EXCHG = 8,
960 };
961
962 /* BACK (block-ack) parties */
963 enum rtw_ieee80211_back_parties {
964         RTW_WLAN_BACK_RECIPIENT = 0,
965         RTW_WLAN_BACK_INITIATOR = 1,
966         RTW_WLAN_BACK_TIMER = 2,
967 };
968
969 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
970                                 * 00:50:F2 */
971 #define WME_OUI_TYPE 2
972 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
973 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
974 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
975 #define WME_VERSION 1
976
977 #define WME_ACTION_CODE_SETUP_REQUEST 0
978 #define WME_ACTION_CODE_SETUP_RESPONSE 1
979 #define WME_ACTION_CODE_TEARDOWN 2
980
981 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
982 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
983 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
984
985 #define WME_TSPEC_DIRECTION_UPLINK 0
986 #define WME_TSPEC_DIRECTION_DOWNLINK 1
987 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
988
989
990 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
991
992 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
993
994 /**
995  * enum rtw_ieee80211_channel_flags - channel flags
996  *
997  * Channel flags set by the regulatory control code.
998  *
999  * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
1000  * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
1001  *      on this channel.
1002  * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
1003  * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
1004  * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
1005  *      is not permitted.
1006  * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
1007  *      is not permitted.
1008  */
1009 enum rtw_ieee80211_channel_flags {
1010         RTW_IEEE80211_CHAN_DISABLED      = 1<<0,
1011         RTW_IEEE80211_CHAN_PASSIVE_SCAN     = 1<<1,
1012         RTW_IEEE80211_CHAN_NO_IBSS        = 1<<2,
1013         RTW_IEEE80211_CHAN_RADAR            = 1<<3,
1014         RTW_IEEE80211_CHAN_NO_HT40PLUS      = 1<<4,
1015         RTW_IEEE80211_CHAN_NO_HT40MINUS     = 1<<5,
1016 };
1017
1018 #define RTW_IEEE80211_CHAN_NO_HT40 \
1019           (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
1020
1021 /* Represent channel details, subset of ieee80211_channel */
1022 struct rtw_ieee80211_channel {
1023         u16 hw_value;
1024         u32 flags;
1025 };
1026
1027 #define CHAN_FMT \
1028         "hw_value:%u, " \
1029         "flags:0x%08x" \
1030
1031 #define CHAN_ARG(channel) \
1032         (channel)->hw_value \
1033         , (channel)->flags \
1034
1035 /* Parsed Information Elements */
1036 struct rtw_ieee802_11_elems {
1037         u8 *ssid;
1038         u8 ssid_len;
1039         u8 *supp_rates;
1040         u8 supp_rates_len;
1041         u8 *fh_params;
1042         u8 fh_params_len;
1043         u8 *ds_params;
1044         u8 ds_params_len;
1045         u8 *cf_params;
1046         u8 cf_params_len;
1047         u8 *tim;
1048         u8 tim_len;
1049         u8 *ibss_params;
1050         u8 ibss_params_len;
1051         u8 *challenge;
1052         u8 challenge_len;
1053         u8 *erp_info;
1054         u8 erp_info_len;
1055         u8 *ext_supp_rates;
1056         u8 ext_supp_rates_len;
1057         u8 *wpa_ie;
1058         u8 wpa_ie_len;
1059         u8 *rsn_ie;
1060         u8 rsn_ie_len;
1061         u8 *wme;
1062         u8 wme_len;
1063         u8 *wme_tspec;
1064         u8 wme_tspec_len;
1065         u8 *wps_ie;
1066         u8 wps_ie_len;
1067         u8 *power_cap;
1068         u8 power_cap_len;
1069         u8 *supp_channels;
1070         u8 supp_channels_len;
1071         u8 *mdie;
1072         u8 mdie_len;
1073         u8 *ftie;
1074         u8 ftie_len;
1075         u8 *timeout_int;
1076         u8 timeout_int_len;
1077         u8 *ht_capabilities;
1078         u8 ht_capabilities_len;
1079         u8 *ht_operation;
1080         u8 ht_operation_len;
1081         u8 *vendor_ht_cap;
1082         u8 vendor_ht_cap_len;
1083 };
1084
1085 enum parse_res {
1086         ParseOK = 0,
1087         ParseUnknown = 1,
1088         ParseFailed = -1
1089 };
1090
1091 enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
1092                                           struct rtw_ieee802_11_elems *elems,
1093                                           int show_errors);
1094
1095 u8 *rtw_set_fixed_ie(void *pbuf, unsigned int len,
1096                      void *source, unsigned int *frlen);
1097 u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
1098
1099 enum secondary_ch_offset {
1100         SCN = 0, /* no secondary channel */
1101         SCA = 1, /* secondary channel above */
1102         SCB = 3,  /* secondary channel below */
1103 };
1104 u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset);
1105 u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset);
1106 u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode,
1107                          u8 new_ch, u8 ch_switch_cnt);
1108 u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len,
1109                                    u8 secondary_ch_offset);
1110 u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl,
1111                                    u8 flags, u16 reason, u16 precedence);
1112
1113 u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit);
1114 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui,
1115                   u8 oui_len, u8 *ie, uint *ielen);
1116 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset,
1117                       u8 eid, u8 *oui, u8 oui_len);
1118
1119 void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
1120
1121 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1122 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1123 int rtw_get_wpa_cipher_suite(u8 *s);
1124 int rtw_get_wpa2_cipher_suite(u8 *s);
1125 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1126 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1127                      int *pairwise_cipher, int *is_8021x);
1128 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1129                       int *pairwise_cipher, int *is_8021x);
1130
1131 int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
1132                    u8 *wpa_ie, u16 *wpa_len);
1133
1134 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1135 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1136 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1137                      u8 *buf_attr, u32 *len_attr);
1138 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1139                              u8 *buf_content, uint *len_content);
1140
1141 /**
1142  * for_each_ie - iterate over continuous IEs
1143  * @ie:
1144  * @buf:
1145  * @buf_len:
1146  */
1147 #define for_each_ie(ie, buf, buf_len) \
1148         for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len;        \
1149                 ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1150
1151 void dump_ies(u8 *buf, u32 buf_len);
1152 void dump_wps_ie(u8 *ie, u32 ie_len);
1153
1154 uint    rtw_get_rateset_len(u8  *rateset);
1155
1156 struct registry_priv;
1157 int rtw_generate_ie(struct registry_priv *pregistrypriv);
1158
1159
1160 int rtw_get_bit_value_from_ieee_value(u8 val);
1161
1162 uint    rtw_is_cckrates_included(u8 *rate);
1163
1164 uint    rtw_is_cckratesonly_included(u8 *rate);
1165
1166 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1167
1168 void rtw_get_bcn_info(struct wlan_network *pnetwork);
1169
1170 void rtw_macaddr_cfg(u8 *mac_addr);
1171
1172 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
1173                  unsigned char *MCS_rate);
1174
1175 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category,
1176                            u8 *action);
1177 const char *action_public_str(u8 action);
1178
1179 #endif /* IEEE80211_H */