blob: 3aa40a32555ed88904837710545c47c5e59217c8 [file] [log] [blame]
Larry Finger364e30e2014-03-28 21:37:41 -05001/******************************************************************************
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
Larry Finger364e30e2014-03-28 21:37:41 -050030#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
Larry Finger364e30e2014-03-28 21:37:41 -050051#define WPA_CIPHER_NONE BIT(0)
52#define WPA_CIPHER_WEP40 BIT(1)
Jes Sorensenaf1853d2014-05-16 10:05:03 +020053#define WPA_CIPHER_WEP104 BIT(2)
Larry Finger364e30e2014-03-28 21:37:41 -050054#define WPA_CIPHER_TKIP BIT(3)
55#define WPA_CIPHER_CCMP BIT(4)
56
57
58
59#define WPA_SELECTOR_LEN 4
60extern u8 RTW_WPA_OUI23A_TYPE[] ;
61extern u16 RTW_WPA_VERSION23A ;
62extern u8 WPA_AUTH_KEY_MGMT_NONE23A[];
63extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
64extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
65extern u8 WPA_CIPHER_SUITE_NONE23A[];
66extern u8 WPA_CIPHER_SUITE_WEP4023A[];
67extern u8 WPA_CIPHER_SUITE_TKIP23A[];
68extern u8 WPA_CIPHER_SUITE_WRAP23A[];
69extern u8 WPA_CIPHER_SUITE_CCMP23A[];
70extern u8 WPA_CIPHER_SUITE_WEP10423A[];
71
72
73#define RSN_HEADER_LEN 4
74#define RSN_SELECTOR_LEN 4
75
Larry Finger364e30e2014-03-28 21:37:41 -050076extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X23A[];
77extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X23A[];
78extern u8 RSN_CIPHER_SUITE_NONE23A[];
79extern u8 RSN_CIPHER_SUITE_WEP4023A[];
80extern u8 RSN_CIPHER_SUITE_TKIP23A[];
81extern u8 RSN_CIPHER_SUITE_WRAP23A[];
82extern u8 RSN_CIPHER_SUITE_CCMP23A[];
83extern u8 RSN_CIPHER_SUITE_WEP10423A[];
84
85enum 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
97enum NETWORK_TYPE
98{
Jes Sorensenaf1853d2014-05-16 10:05:03 +020099 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),
Larry Finger364e30e2014-03-28 21:37:41 -0500111 /* WIRELESS_AUTO = BIT(5), */
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200112 WIRELESS_AC = BIT(6),
Larry Finger364e30e2014-03-28 21:37:41 -0500113
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200114 /* 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,
Larry Finger364e30e2014-03-28 21:37:41 -0500128};
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
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200133#define IsSupported24G(NetType) (NetType & SUPPORTED_24G_NETTYPE_MSK ? true : false)
134#define IsSupported5G(NetType) (NetType & SUPPORTED_5G_NETTYPE_MSK ? true : false)
Larry Finger364e30e2014-03-28 21:37:41 -0500135
136#define IsEnableHWCCK(NetType) IsSupported24G(NetType)
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200137#define IsEnableHWOFDM(NetType) (NetType & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? true : false)
Larry Finger364e30e2014-03-28 21:37:41 -0500138
139#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
140#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
141#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
142
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200143#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)
Larry Finger364e30e2014-03-28 21:37:41 -0500146
147
Larry Finger364e30e2014-03-28 21:37:41 -0500148#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
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200154#define NON_EXPLICIT_ACK 2
Larry Finger364e30e2014-03-28 21:37:41 -0500155#define BLOCK_ACK 3
156
157/* IEEE 802.11 defines */
158
159#define P80211_OUI_LEN 3
160
161struct ieee80211_snap_hdr {
Greg Donalda82b4b02014-09-08 20:50:23 -0500162 u8 dsap; /* always 0xAA */
163 u8 ssap; /* always 0xAA */
164 u8 ctrl; /* always 0x03 */
165 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
Larry Finger364e30e2014-03-28 21:37:41 -0500166} __attribute__ ((packed));
167
168
169#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
170
Larry Finger364e30e2014-03-28 21:37:41 -0500171#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
172#define WLAN_REASON_EXPIRATION_CHK 65535
173
Larry Finger364e30e2014-03-28 21:37:41 -0500174#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 | \
Greg Donalda82b4b02014-09-08 20:50:23 -0500210 IEEE80211_CCK_RATE_5MB_MASK | \
211 IEEE80211_CCK_RATE_11MB_MASK)
Larry Finger364e30e2014-03-28 21:37:41 -0500212
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 | \
Greg Donalda82b4b02014-09-08 20:50:23 -0500224 IEEE80211_CCK_DEFAULT_RATES_MASK)
Larry Finger364e30e2014-03-28 21:37:41 -0500225
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
Larry Finger364e30e2014-03-28 21:37:41 -0500231
232
Larry Finger364e30e2014-03-28 21:37:41 -0500233/* 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... */
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200237#define MAX_RATES_LENGTH 12
238#define MAX_RATES_EX_LENGTH 16
239#define MAX_CHANNEL_NUMBER 161
Jes Sorensen2e74d332014-06-09 15:16:17 +0200240#define RTW_CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
Larry Finger364e30e2014-03-28 21:37:41 -0500241
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200242#define MAX_WPA_IE_LEN 256
Jes Sorensend3797af2014-06-09 15:15:56 +0200243#define MAX_WPS_IE_LEN 256
Jes Sorensenaf1853d2014-05-16 10:05:03 +0200244#define MAX_P2P_IE_LEN 256
245#define MAX_WFD_IE_LEN 128
Larry Finger364e30e2014-03-28 21:37:41 -0500246
Larry Finger364e30e2014-03-28 21:37:41 -0500247/*
248join_res:
249-1: authentication fail
250-2: association fail
251> 0: TID
252*/
253
Larry Finger364e30e2014-03-28 21:37:41 -0500254#define MAXTID 16
255
Larry Finger364e30e2014-03-28 21:37:41 -0500256#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 */
268struct rtw_ieee80211_channel {
269 /* enum ieee80211_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
Jes Sorensen7a653822014-04-15 19:43:23 +0200308u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen);
Larry Finger364e30e2014-03-28 21:37:41 -0500309
Larry Finger364e30e2014-03-28 21:37:41 -0500310u8 hal_ch_offset_to_secondary_ch_offset23a(u8 ch_offset);
311u8 *rtw_set_ie23a_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt);
312u8 *rtw_set_ie23a_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset);
Larry Finger364e30e2014-03-28 21:37:41 -0500313
314u8 *rtw_get_ie23a(u8*pbuf, int index, int *len, int limit);
315u8 *rtw_get_ie23a_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
316int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
317
Greg Donald4e66cf02014-08-22 10:57:49 -0500318void rtw_set_supported_rate23a(u8 *SupportedRates, uint mode);
Larry Finger364e30e2014-03-28 21:37:41 -0500319
Jes Sorensen95c4345a2014-04-15 19:44:03 +0200320int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
321int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
Larry Finger364e30e2014-03-28 21:37:41 -0500322
Jes Sorensen6e5e4182014-06-09 15:15:54 +0200323const u8 *rtw_get_wps_attr23a(const u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr);
Jes Sorensenc250e072014-06-24 15:03:33 +0200324const u8 *rtw_get_wps_attr_content23a(const u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content);
Larry Finger364e30e2014-03-28 21:37:41 -0500325
Larry Finger364e30e2014-03-28 21:37:41 -0500326uint rtw_get_rateset_len23a(u8 *rateset);
327
328struct registry_priv;
329int rtw_generate_ie23a(struct registry_priv *pregistrypriv);
330
331
332int rtw_get_bit_value_from_ieee_value23a(u8 val);
333
Larry Finger364e30e2014-03-28 21:37:41 -0500334int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel);
335
336void rtw_get_bcn_info23a(struct wlan_network *pnetwork);
337
Jes Sorensen198e95d2014-05-31 18:05:10 +0200338u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
339 struct ieee80211_mcs_info *mcs);
Larry Finger364e30e2014-03-28 21:37:41 -0500340
Larry Finger364e30e2014-03-28 21:37:41 -0500341#endif /* IEEE80211_H */