Linux 3.15-rc2
[firefly-linux-kernel-4.4.55.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 #define MGMT_QUEUE_NUM 5
31
32 #ifdef CONFIG_8723AU_AP_MODE
33
34 /* STA flags */
35 #define WLAN_STA_AUTH BIT(0)
36 #define WLAN_STA_ASSOC BIT(1)
37 #define WLAN_STA_PS BIT(2)
38 #define WLAN_STA_TIM BIT(3)
39 #define WLAN_STA_PERM BIT(4)
40 #define WLAN_STA_AUTHORIZED BIT(5)
41 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
42 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
43 #define WLAN_STA_PREAUTH BIT(8)
44 #define WLAN_STA_WME BIT(9)
45 #define WLAN_STA_MFP BIT(10)
46 #define WLAN_STA_HT BIT(11)
47 #define WLAN_STA_WPS BIT(12)
48 #define WLAN_STA_MAYBE_WPS BIT(13)
49 #define WLAN_STA_NONERP BIT(31)
50
51 #endif
52
53 #define IEEE_CMD_SET_WPA_PARAM                  1
54 #define IEEE_CMD_SET_WPA_IE                             2
55 #define IEEE_CMD_SET_ENCRYPTION                 3
56
57 #define IEEE_CRYPT_ALG_NAME_LEN                 16
58
59 #define WPA_CIPHER_NONE         BIT(0)
60 #define WPA_CIPHER_WEP40        BIT(1)
61 #define WPA_CIPHER_WEP104 BIT(2)
62 #define WPA_CIPHER_TKIP         BIT(3)
63 #define WPA_CIPHER_CCMP         BIT(4)
64
65
66
67 #define WPA_SELECTOR_LEN 4
68 extern u8 RTW_WPA_OUI23A_TYPE[] ;
69 extern u16 RTW_WPA_VERSION23A ;
70 extern u8 WPA_AUTH_KEY_MGMT_NONE23A[];
71 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
72 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
73 extern u8 WPA_CIPHER_SUITE_NONE23A[];
74 extern u8 WPA_CIPHER_SUITE_WEP4023A[];
75 extern u8 WPA_CIPHER_SUITE_TKIP23A[];
76 extern u8 WPA_CIPHER_SUITE_WRAP23A[];
77 extern u8 WPA_CIPHER_SUITE_CCMP23A[];
78 extern u8 WPA_CIPHER_SUITE_WEP10423A[];
79
80
81 #define RSN_HEADER_LEN 4
82 #define RSN_SELECTOR_LEN 4
83
84 extern u16 RSN_VERSION_BSD23A;
85 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
86 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
87 extern u8 RSN_CIPHER_SUITE_NONE23A[];
88 extern u8 RSN_CIPHER_SUITE_WEP4023A[];
89 extern u8 RSN_CIPHER_SUITE_TKIP23A[];
90 extern u8 RSN_CIPHER_SUITE_WRAP23A[];
91 extern u8 RSN_CIPHER_SUITE_CCMP23A[];
92 extern u8 RSN_CIPHER_SUITE_WEP10423A[];
93
94 enum ratr_table_mode {
95         RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
96         RATR_INX_WIRELESS_NG = 1,       /*  GN or N */
97         RATR_INX_WIRELESS_NB = 2,       /*  BGN 20 Mhz 2SS 1SS  or BN */
98         RATR_INX_WIRELESS_N = 3,
99         RATR_INX_WIRELESS_GB = 4,
100         RATR_INX_WIRELESS_G = 5,
101         RATR_INX_WIRELESS_B = 6,
102         RATR_INX_WIRELESS_MC = 7,
103         RATR_INX_WIRELESS_AC_N = 8,
104 };
105
106 enum NETWORK_TYPE
107 {
108     WIRELESS_INVALID = 0,
109     /* Sub-Element */
110     WIRELESS_11B = BIT(0), /*  tx: cck only , rx: cck only, hw: cck */
111     WIRELESS_11G = BIT(1), /*  tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */
112     WIRELESS_11A = BIT(2), /*  tx: ofdm only, rx: ofdm only, hw: ofdm only */
113     WIRELESS_11_24N = BIT(3), /*  tx: MCS only, rx: MCS & cck, hw: MCS & cck */
114     WIRELESS_11_5N = BIT(4), /*  tx: MCS only, rx: MCS & ofdm, hw: ofdm only */
115         /* WIRELESS_AUTO                = BIT(5), */
116         WIRELESS_AC             = BIT(6),
117
118     /* Combination */
119     WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
120     WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
121     WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
122     WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
123     WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
124     WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
125 };
126
127 #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
128 #define SUPPORTED_5G_NETTYPE_MSK (WIRELESS_11A | WIRELESS_11_5N)
129
130 #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
131 #define IsSupported5G(NetType) ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false)
132
133 #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
134 #define IsEnableHWOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? true : false)
135
136 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
137 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
138 #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
139
140 #define IsSupportedTxCCK(NetType) ((NetType) & (WIRELESS_11B) ? true : false)
141 #define IsSupportedTxOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false)
142 #define IsSupportedTxMCS(NetType) ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false)
143
144
145 struct ieee_param {
146         u32 cmd;
147         u8 sta_addr[ETH_ALEN];
148         union {
149                 struct {
150                         u8 name;
151                         u32 value;
152                 } wpa_param;
153                 struct {
154                         u32 len;
155                         u8 reserved[32];
156                         u8 data[0];
157                 } wpa_ie;
158                 struct{
159                         int command;
160                         int reason_code;
161                 } mlme;
162                 struct {
163                         u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
164                         u8 set_tx;
165                         u32 err;
166                         u8 idx;
167                         u8 seq[8]; /* sequence counter (set: RX, get: TX) */
168                         u16 key_len;
169                         u8 key[0];
170                 } crypt;
171 #ifdef CONFIG_8723AU_AP_MODE
172                 struct {
173                         u16 aid;
174                         u16 capability;
175                         int flags;
176                         u8 tx_supp_rates[16];
177                         struct ieee80211_ht_cap ht_cap;
178                 } add_sta;
179                 struct {
180                         u8      reserved[2];/* for set max_num_sta */
181                         u8      buf[0];
182                 } bcn_ie;
183 #endif
184
185         } u;
186 };
187
188
189 #define MIN_FRAG_THRESHOLD     256U
190 #define MAX_FRAG_THRESHOLD     2346U
191
192 /* QoS,QOS */
193 #define NORMAL_ACK                      0
194 #define NO_ACK                          1
195 #define NON_EXPLICIT_ACK        2
196 #define BLOCK_ACK                       3
197
198 /* IEEE 802.11 defines */
199
200 #define P80211_OUI_LEN 3
201
202 struct ieee80211_snap_hdr {
203
204         u8    dsap;   /* always 0xAA */
205         u8    ssap;   /* always 0xAA */
206         u8    ctrl;   /* always 0x03 */
207         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
208
209 } __attribute__ ((packed));
210
211
212 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
213
214 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
215 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
216
217 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
218
219 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
220 #define WLAN_GET_SEQ_SEQ(seq)  ((seq) & RTW_IEEE80211_SCTL_SEQ)
221
222
223 #define WLAN_REASON_JOIN_WRONG_CHANNEL       65534
224 #define WLAN_REASON_EXPIRATION_CHK 65535
225
226
227
228 #define IEEE80211_STATMASK_SIGNAL (1<<0)
229 #define IEEE80211_STATMASK_RSSI (1<<1)
230 #define IEEE80211_STATMASK_NOISE (1<<2)
231 #define IEEE80211_STATMASK_RATE (1<<3)
232 #define IEEE80211_STATMASK_WEMASK 0x7
233
234
235 #define IEEE80211_CCK_MODULATION    (1<<0)
236 #define IEEE80211_OFDM_MODULATION   (1<<1)
237
238 #define IEEE80211_24GHZ_BAND     (1<<0)
239 #define IEEE80211_52GHZ_BAND     (1<<1)
240
241 #define IEEE80211_CCK_RATE_LEN                  4
242 #define IEEE80211_NUM_OFDM_RATESLEN     8
243
244
245 #define IEEE80211_CCK_RATE_1MB                  0x02
246 #define IEEE80211_CCK_RATE_2MB                  0x04
247 #define IEEE80211_CCK_RATE_5MB                  0x0B
248 #define IEEE80211_CCK_RATE_11MB                 0x16
249 #define IEEE80211_OFDM_RATE_LEN                 8
250 #define IEEE80211_OFDM_RATE_6MB                 0x0C
251 #define IEEE80211_OFDM_RATE_9MB                 0x12
252 #define IEEE80211_OFDM_RATE_12MB                0x18
253 #define IEEE80211_OFDM_RATE_18MB                0x24
254 #define IEEE80211_OFDM_RATE_24MB                0x30
255 #define IEEE80211_OFDM_RATE_36MB                0x48
256 #define IEEE80211_OFDM_RATE_48MB                0x60
257 #define IEEE80211_OFDM_RATE_54MB                0x6C
258 #define IEEE80211_BASIC_RATE_MASK               0x80
259
260 #define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
261 #define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
262 #define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
263 #define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
264 #define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
265 #define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
266 #define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
267 #define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
268 #define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
269 #define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
270 #define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
271 #define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
272
273 #define IEEE80211_CCK_RATES_MASK                0x0000000F
274 #define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
275         IEEE80211_CCK_RATE_2MB_MASK)
276 #define IEEE80211_CCK_DEFAULT_RATES_MASK        (IEEE80211_CCK_BASIC_RATES_MASK | \
277         IEEE80211_CCK_RATE_5MB_MASK | \
278         IEEE80211_CCK_RATE_11MB_MASK)
279
280 #define IEEE80211_OFDM_RATES_MASK               0x00000FF0
281 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
282         IEEE80211_OFDM_RATE_12MB_MASK | \
283         IEEE80211_OFDM_RATE_24MB_MASK)
284 #define IEEE80211_OFDM_DEFAULT_RATES_MASK       (IEEE80211_OFDM_BASIC_RATES_MASK | \
285         IEEE80211_OFDM_RATE_9MB_MASK  | \
286         IEEE80211_OFDM_RATE_18MB_MASK | \
287         IEEE80211_OFDM_RATE_36MB_MASK | \
288         IEEE80211_OFDM_RATE_48MB_MASK | \
289         IEEE80211_OFDM_RATE_54MB_MASK)
290 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
291                                 IEEE80211_CCK_DEFAULT_RATES_MASK)
292
293 #define IEEE80211_NUM_OFDM_RATES            8
294 #define IEEE80211_NUM_CCK_RATES             4
295 #define IEEE80211_OFDM_SHIFT_MASK_A         4
296
297 #define WEP_KEYS 4
298 #define WEP_KEY_LEN 13
299
300
301
302 /*
303
304  802.11 data frame from AP
305
306       ,-------------------------------------------------------------------.
307 Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
308       |------|------|---------|---------|---------|------|---------|------|
309 Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
310       |      | tion | (BSSID) |         |         | ence |  data   |      |
311       `-------------------------------------------------------------------'
312
313 Total: 28-2340 bytes
314
315 */
316
317 struct ieee80211_header_data {
318         u16 frame_ctl;
319         u16 duration_id;
320         u8 addr1[6];
321         u8 addr2[6];
322         u8 addr3[6];
323         u16 seq_ctrl;
324 };
325
326 struct ieee80211_info_element_hdr {
327         u8 id;
328         u8 len;
329 } __attribute__ ((packed));
330
331 struct ieee80211_info_element {
332         u8 id;
333         u8 len;
334         u8 data[0];
335 } __attribute__ ((packed));
336
337
338 struct ieee80211_txb {
339         u8 nr_frags;
340         u8 encrypted;
341         u16 reserved;
342         u16 frag_size;
343         u16 payload_size;
344         struct sk_buff *fragments[0];
345 };
346
347
348 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
349  * only use 8, and then use extended rates for the remaining supported
350  * rates.  Other APs, however, stick all of their supported rates on the
351  * main rates information element... */
352 #define MAX_RATES_LENGTH                  ((u8)12)
353 #define MAX_RATES_EX_LENGTH               ((u8)16)
354 #define MAX_CHANNEL_NUMBER                 161
355
356 #define MAX_WPA_IE_LEN (256)
357 #define MAX_WPS_IE_LEN (512)
358 #define MAX_P2P_IE_LEN (256)
359 #define MAX_WFD_IE_LEN (128)
360
361 #define IW_ESSID_MAX_SIZE 32
362
363 /*
364 join_res:
365 -1: authentication fail
366 -2: association fail
367 > 0: TID
368 */
369
370 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
371 #define DEFAULT_FTS 2346
372 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
373 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
374
375 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
376 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
377
378 #define MAXTID  16
379
380 #define IEEE_A            (1<<0)
381 #define IEEE_B            (1<<1)
382 #define IEEE_G            (1<<2)
383 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
384
385 /* Baron move to ieee80211.c */
386 int ieee80211_is_empty_essid23a(const char *essid, int essid_len);
387
388 enum _PUBLIC_ACTION{
389         ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
390         ACT_PUBLIC_DSE_ENABLE = 1,
391         ACT_PUBLIC_DSE_DEENABLE = 2,
392         ACT_PUBLIC_DSE_REG_LOCATION = 3,
393         ACT_PUBLIC_EXT_CHL_SWITCH = 4,
394         ACT_PUBLIC_DSE_MSR_REQ = 5,
395         ACT_PUBLIC_DSE_MSR_RPRT = 6,
396         ACT_PUBLIC_MP = 7, /*  Measurement Pilot */
397         ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
398         ACT_PUBLIC_VENDOR = 9, /*  for WIFI_DIRECT */
399         ACT_PUBLIC_GAS_INITIAL_REQ = 10,
400         ACT_PUBLIC_GAS_INITIAL_RSP = 11,
401         ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
402         ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
403         ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
404         ACT_PUBLIC_LOCATION_TRACK = 15,
405         ACT_PUBLIC_MAX
406 };
407
408 #define WME_OUI_TYPE 2
409 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
410 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
411 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
412 #define WME_VERSION 1
413
414
415 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
416
417 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
418
419 /* Represent channel details, subset of ieee80211_channel */
420 struct rtw_ieee80211_channel {
421         /* enum ieee80211_band band; */
422         /* u16 center_freq; */
423         u16 hw_value;
424         u32 flags;
425         /* int max_antenna_gain; */
426         /* int max_power; */
427         /* int max_reg_power; */
428         /* bool beacon_found; */
429         /* u32 orig_flags; */
430         /* int orig_mag; */
431         /* int orig_mpwr; */
432 };
433
434 #define CHAN_FMT \
435         /*"band:%d, "*/ \
436         /*"center_freq:%u, "*/ \
437         "hw_value:%u, " \
438         "flags:0x%08x" \
439         /*"max_antenna_gain:%d\n"*/ \
440         /*"max_power:%d\n"*/ \
441         /*"max_reg_power:%d\n"*/ \
442         /*"beacon_found:%u\n"*/ \
443         /*"orig_flags:0x%08x\n"*/ \
444         /*"orig_mag:%d\n"*/ \
445         /*"orig_mpwr:%d\n"*/
446
447 #define CHAN_ARG(channel) \
448         /*(channel)->band*/ \
449         /*, (channel)->center_freq*/ \
450         (channel)->hw_value \
451         , (channel)->flags \
452         /*, (channel)->max_antenna_gain*/ \
453         /*, (channel)->max_power*/ \
454         /*, (channel)->max_reg_power*/ \
455         /*, (channel)->beacon_found*/ \
456         /*, (channel)->orig_flags*/ \
457         /*, (channel)->orig_mag*/ \
458         /*, (channel)->orig_mpwr*/ \
459
460 /* Parsed Information Elements */
461 struct rtw_ieee802_11_elems {
462         u8 *ssid;
463         u8 ssid_len;
464         u8 *supp_rates;
465         u8 supp_rates_len;
466         u8 *fh_params;
467         u8 fh_params_len;
468         u8 *ds_params;
469         u8 ds_params_len;
470         u8 *cf_params;
471         u8 cf_params_len;
472         u8 *tim;
473         u8 tim_len;
474         u8 *ibss_params;
475         u8 ibss_params_len;
476         u8 *challenge;
477         u8 challenge_len;
478         u8 *erp_info;
479         u8 erp_info_len;
480         u8 *ext_supp_rates;
481         u8 ext_supp_rates_len;
482         u8 *wpa_ie;
483         u8 wpa_ie_len;
484         u8 *rsn_ie;
485         u8 rsn_ie_len;
486         u8 *wme;
487         u8 wme_len;
488         u8 *wme_tspec;
489         u8 wme_tspec_len;
490         u8 *wps_ie;
491         u8 wps_ie_len;
492         u8 *power_cap;
493         u8 power_cap_len;
494         u8 *supp_channels;
495         u8 supp_channels_len;
496         u8 *mdie;
497         u8 mdie_len;
498         u8 *ftie;
499         u8 ftie_len;
500         u8 *timeout_int;
501         u8 timeout_int_len;
502         u8 *ht_capabilities;
503         u8 ht_capabilities_len;
504         u8 *ht_operation;
505         u8 ht_operation_len;
506         u8 *vendor_ht_cap;
507         u8 vendor_ht_cap_len;
508 };
509
510 enum parse_res {
511         ParseOK = 0,
512         ParseUnknown = 1,
513         ParseFailed = -1
514 };
515
516 enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len,
517                                 struct rtw_ieee802_11_elems *elems,
518                                 int show_errors);
519
520 u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
521 u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
522
523 enum secondary_ch_offset {
524         SCN = 0, /* no secondary channel */
525         SCA = 1, /* secondary channel above */
526         SCB = 3,  /* secondary channel below */
527 };
528 u8 secondary_ch_offset_to_hal_ch_offset23a(u8 ch_offset);
529 u8 hal_ch_offset_to_secondary_ch_offset23a(u8 ch_offset);
530 u8 *rtw_set_ie23a_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt);
531 u8 *rtw_set_ie23a_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset);
532 u8 *rtw_set_ie23a_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence);
533
534 u8 *rtw_get_ie23a(u8*pbuf, int index, int *len, int limit);
535 u8 *rtw_get_ie23a_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
536 int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
537
538 void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ;
539
540 unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit);
541 unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit);
542 int rtw_get_wpa_cipher_suite23a(u8 *s);
543 int rtw_get_wpa2_cipher_suite23a(u8 *s);
544 int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
545 int rtw_parse_wpa2_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
546
547 int rtw_get_sec_ie23a(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len);
548
549 u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen);
550 u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
551 u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr);
552 u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content);
553
554 /**
555  * for_each_ie - iterate over continuous IEs
556  * @ie:
557  * @buf:
558  * @buf_len:
559  */
560 #define for_each_ie(ie, buf, buf_len) \
561         for (ie = (void*)buf; (((u8*)ie) - ((u8*)buf) + 1) < buf_len; ie = (void*)(((u8*)ie) + *(((u8*)ie)+1) + 2))
562
563 void dump_ies23a(u8 *buf, u32 buf_len);
564 void dump_wps_ie23a(u8 *ie, u32 ie_len);
565
566 #ifdef CONFIG_8723AU_P2P
567 void dump_p2p_ie23a(u8 *ie, u32 ie_len);
568 u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen);
569 u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr, u32 *len_attr);
570 u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_content, uint *len_content);
571 u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr);
572 void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id);
573 #endif
574
575 #ifdef CONFIG_8723AU_P2P
576 int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen);
577 int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen);
578 #endif /*  CONFIG_8723AU_P2P */
579
580 uint    rtw_get_rateset_len23a(u8       *rateset);
581
582 struct registry_priv;
583 int rtw_generate_ie23a(struct registry_priv *pregistrypriv);
584
585
586 int rtw_get_bit_value_from_ieee_value23a(u8 val);
587
588 uint rtw_is_cckrates_included23a(u8 *rate);
589
590 uint rtw_is_cckratesonly_included23a(u8 *rate);
591
592 int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel);
593
594 void rtw_get_bcn_info23a(struct wlan_network *pnetwork);
595
596 void rtw_macaddr_cfg23a(u8 *mac_addr);
597
598 u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char * MCS_rate);
599
600 int rtw_action_frame_parse23a(const u8 *frame, u32 frame_len, u8* category, u8 *action);
601 const char *action_public_str23a(u8 action);
602
603 #endif /* IEEE80211_H */