]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/rtl8723au/include/wifi.h
staging: rtl8723au: Use kernel provided IEEE80211_HT_PARAM_* defines
[karo-tx-linux.git] / drivers / staging / rtl8723au / include / wifi.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 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 _WIFI_H_
16 #define _WIFI_H_
17
18 #define P80211CAPTURE_VERSION   0x80211001
19
20 /*  This value is tested by WiFi 11n Test Plan 5.2.3.
21  *  This test verifies the WLAN NIC can update the NAV through sending
22  *  the CTS with large duration.
23  */
24 #define WiFiNavUpperUs          30000   /*  30 ms */
25
26 enum WIFI_FRAME_TYPE {
27         WIFI_MGT_TYPE  =        (0),
28         WIFI_CTRL_TYPE =        (BIT(2)),
29         WIFI_DATA_TYPE =        (BIT(3)),
30         WIFI_QOS_DATA_TYPE      = (BIT(7)|BIT(3)),      /*  QoS Data */
31 };
32
33 enum WIFI_FRAME_SUBTYPE {
34         /*  below is for mgt frame */
35         WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
36         WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE),
37         WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE),
38         WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
39         WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE),
40         WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
41         WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE),
42         WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
43         WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
44         WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
45         WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
46         WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
47
48         /*  below is for control frame */
49         WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
50         WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
51         WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
52         WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
53         WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
54         WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
55
56         /*  below is for data frame */
57         WIFI_DATA = (0 | WIFI_DATA_TYPE),
58         WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
59         WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
60         WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
61         WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
62         WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
63         WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
64         WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
65         WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE),
66 };
67
68
69 enum WIFI_REG_DOMAIN {
70         DOMAIN_FCC              = 1,
71         DOMAIN_IC               = 2,
72         DOMAIN_ETSI             = 3,
73         DOMAIN_SPAIN            = 4,
74         DOMAIN_FRANCE           = 5,
75         DOMAIN_MKK              = 6,
76         DOMAIN_ISRAEL           = 7,
77         DOMAIN_MKK1             = 8,
78         DOMAIN_MKK2             = 9,
79         DOMAIN_MKK3             = 10,
80         DOMAIN_MAX
81 };
82
83
84 #define SetToDs(pbuf)   \
85         (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
86
87 #define SetFrDs(pbuf)   \
88         (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
89
90 #define SetPwrMgt(pbuf) \
91         (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
92
93 #define SetMData(pbuf)  \
94         (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
95
96 #define SetPrivacy(pbuf)        \
97         (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
98
99 #define SetFrameType(pbuf, type)        \
100         do {    \
101                 *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
102                 *(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \
103         } while (0)
104
105 #define SetFrameSubType(pbuf, type) \
106         do {    \
107                 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
108                 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
109         } while (0)
110
111 #define SetFragNum(pbuf, num) \
112         do {    \
113                 *(unsigned short *)((unsigned long)(pbuf) + 22) = \
114                         ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu(~(0x000f))) | \
115                         cpu_to_le16(0x0f & (num));     \
116         } while (0)
117
118 #define SetSeqNum(pbuf, num) \
119         do {    \
120                 *(__le16 *)((size_t)(pbuf) + 22) = \
121                         ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
122                         cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
123         } while (0)
124
125 #define SetDuration(pbuf, dur) \
126         (*(__le16 *)((unsigned long)(pbuf) + 2) =               \
127          cpu_to_le16(0xffff & (dur)))
128
129 #define SetPriority(pbuf, tid)  \
130         (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
131
132 #define SetEOSP(pbuf, eosp)     \
133         (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
134
135 #define SetAckpolicy(pbuf, ack) \
136         (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
137
138 #define _ASOCREQ_IE_OFFSET_             4       /*  excluding wlan_hdr */
139 #define _ASOCRSP_IE_OFFSET_             6
140 #define _REASOCREQ_IE_OFFSET_           10
141 #define _REASOCRSP_IE_OFFSET_           6
142 #define _PROBEREQ_IE_OFFSET_            0
143 #define _PROBERSP_IE_OFFSET_            12
144 #define _AUTH_IE_OFFSET_                6
145 #define _DEAUTH_IE_OFFSET_              0
146 #define _BEACON_IE_OFFSET_              12
147 #define _PUBLIC_ACTION_IE_OFFSET_       8
148
149 #define _FIXED_IE_LENGTH_               _BEACON_IE_OFFSET_
150
151
152 #define EID_BSSIntolerantChlReport      73
153
154 /* ---------------------------------------------------------------------------
155                                         Below is the fixed elements...
156 -----------------------------------------------------------------------------*/
157 #define _AUTH_ALGM_NUM_         2
158 #define _AUTH_SEQ_NUM_          2
159 #define _BEACON_ITERVAL_        2
160 #define _CAPABILITY_            2
161 #define _CURRENT_APADDR_        6
162 #define _LISTEN_INTERVAL_       2
163 #define _ASOC_ID_               2
164 #define _STATUS_CODE_           2
165 #define _TIMESTAMP_             8
166
167 /*-----------------------------------------------------------------------------
168                                 Below is the definition for WMM
169 ------------------------------------------------------------------------------*/
170 #define _WMM_IE_Length_                         7  /*  for WMM STA */
171 #define _WMM_Para_Element_Length_               24
172
173
174 /*-----------------------------------------------------------------------------
175                                 Below is the definition for 802.11n
176 ------------------------------------------------------------------------------*/
177
178 /* struct rtw_ieee80211_ht_cap - HT additional information
179  *
180  * This structure refers to "HT information element" as
181  * described in 802.11n draft section 7.3.2.53
182  */
183 struct ieee80211_ht_addt_info {
184         unsigned char   control_chan;
185         unsigned char   ht_param;
186         unsigned short  operation_mode;
187         unsigned short  stbc_param;
188         unsigned char   basic_set[16];
189 } __packed;
190
191 struct HT_caps_element {
192         union {
193                 struct {
194                         unsigned short  HT_caps_info;
195                         unsigned char   AMPDU_para;
196                         unsigned char   MCS_rate[16];
197                         unsigned short  HT_ext_caps;
198                         unsigned int    Beamforming_caps;
199                         unsigned char   ASEL_caps;
200                 } HT_cap_element;
201                 unsigned char HT_cap[26];
202         } u;
203 } __packed;
204
205 struct HT_info_element {
206         unsigned char   primary_channel;
207         unsigned char   infos[5];
208         unsigned char   MCS_rate[16];
209 }  __packed;
210
211 struct AC_param {
212         unsigned char           ACI_AIFSN;
213         unsigned char           CW;
214         unsigned short  TXOP_limit;
215 }  __packed;
216
217 struct WMM_para_element {
218         unsigned char           QoS_info;
219         unsigned char           reserved;
220         struct AC_param ac_param[4];
221 }  __packed;
222
223 struct ADDBA_request {
224         unsigned char           dialog_token;
225         unsigned short  BA_para_set;
226         unsigned short  BA_timeout_value;
227         unsigned short  BA_starting_seqctrl;
228 }  __packed;
229
230
231 #define OP_MODE_PURE                    0
232 #define OP_MODE_MAY_BE_LEGACY_STAS      1
233 #define OP_MODE_20MHZ_HT_STA_ASSOCED    2
234 #define OP_MODE_MIXED                   3
235
236 /*      ===============WPS Section=============== */
237 /*      For WPSv1.0 */
238 #define WPSOUI                                  0x0050f204
239 /*      WPS attribute ID */
240 #define WPS_ATTR_VER1                           0x104A
241 #define WPS_ATTR_SIMPLE_CONF_STATE              0x1044
242 #define WPS_ATTR_RESP_TYPE                      0x103B
243 #define WPS_ATTR_UUID_E                         0x1047
244 #define WPS_ATTR_MANUFACTURER                   0x1021
245 #define WPS_ATTR_MODEL_NAME                     0x1023
246 #define WPS_ATTR_MODEL_NUMBER                   0x1024
247 #define WPS_ATTR_SERIAL_NUMBER                  0x1042
248 #define WPS_ATTR_PRIMARY_DEV_TYPE               0x1054
249 #define WPS_ATTR_SEC_DEV_TYPE_LIST              0x1055
250 #define WPS_ATTR_DEVICE_NAME                    0x1011
251 #define WPS_ATTR_CONF_METHOD                    0x1008
252 #define WPS_ATTR_RF_BANDS                       0x103C
253 #define WPS_ATTR_DEVICE_PWID                    0x1012
254 #define WPS_ATTR_REQUEST_TYPE                   0x103A
255 #define WPS_ATTR_ASSOCIATION_STATE              0x1002
256 #define WPS_ATTR_CONFIG_ERROR                   0x1009
257 #define WPS_ATTR_VENDOR_EXT                     0x1049
258 #define WPS_ATTR_SELECTED_REGISTRAR             0x1041
259
260 /*      Value of WPS attribute "WPS_ATTR_DEVICE_NAME */
261 #define WPS_MAX_DEVICE_NAME_LEN                 32
262
263 /*      Value of WPS Request Type Attribute */
264 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY         0x00
265 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X        0x01
266 #define WPS_REQ_TYPE_REGISTRAR                  0x02
267 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR     0x03
268
269 /*      Value of WPS Response Type Attribute */
270 #define WPS_RESPONSE_TYPE_INFO_ONLY             0x00
271 #define WPS_RESPONSE_TYPE_8021X                 0x01
272 #define WPS_RESPONSE_TYPE_REGISTRAR             0x02
273 #define WPS_RESPONSE_TYPE_AP                    0x03
274
275 /*      Value of WPS WiFi Simple Configuration State Attribute */
276 #define WPS_WSC_STATE_NOT_CONFIG                0x01
277 #define WPS_WSC_STATE_CONFIG                    0x02
278
279 /*      Value of WPS Version Attribute */
280 #define WPS_VERSION_1                           0x10
281
282 /*      Value of WPS Configuration Method Attribute */
283 #define WPS_CONFIG_METHOD_FLASH                 0x0001
284 #define WPS_CONFIG_METHOD_ETHERNET              0x0002
285 #define WPS_CONFIG_METHOD_LABEL                 0x0004
286 #define WPS_CONFIG_METHOD_DISPLAY               0x0008
287 #define WPS_CONFIG_METHOD_E_NFC                 0x0010
288 #define WPS_CONFIG_METHOD_I_NFC                 0x0020
289 #define WPS_CONFIG_METHOD_NFC                   0x0040
290 #define WPS_CONFIG_METHOD_PBC                   0x0080
291 #define WPS_CONFIG_METHOD_KEYPAD                0x0100
292 #define WPS_CONFIG_METHOD_VPBC                  0x0280
293 #define WPS_CONFIG_METHOD_PPBC                  0x0480
294 #define WPS_CONFIG_METHOD_VDISPLAY              0x2008
295 #define WPS_CONFIG_METHOD_PDISPLAY              0x4008
296
297 /*      Value of Category ID of WPS Primary Device Type Attribute */
298 #define WPS_PDT_CID_DISPLAYS                    0x0007
299 #define WPS_PDT_CID_MULIT_MEDIA                 0x0008
300 #define WPS_PDT_CID_RTK_WIDI                    WPS_PDT_CID_MULIT_MEDIA
301
302 /*      Value of Sub Category ID of WPS Primary Device Type Attribute */
303 #define WPS_PDT_SCID_MEDIA_SERVER               0x0005
304 #define WPS_PDT_SCID_RTK_DMP                    WPS_PDT_SCID_MEDIA_SERVER
305
306 /*      Value of Device Password ID */
307 #define WPS_DPID_PIN                            0x0000
308 #define WPS_DPID_USER_SPEC                      0x0001
309 #define WPS_DPID_MACHINE_SPEC                   0x0002
310 #define WPS_DPID_REKEY                          0x0003
311 #define WPS_DPID_PBC                            0x0004
312 #define WPS_DPID_REGISTRAR_SPEC                 0x0005
313
314 /*      Value of WPS RF Bands Attribute */
315 #define WPS_RF_BANDS_2_4_GHZ                    0x01
316 #define WPS_RF_BANDS_5_GHZ                      0x02
317
318 /*      Value of WPS Association State Attribute */
319 #define WPS_ASSOC_STATE_NOT_ASSOCIATED          0x00
320 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS      0x01
321 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE   0x02
322 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE     0x03
323 #define WPS_ASSOC_STATE_IP_FAILURE              0x04
324
325 /*      P2P Public Action Frame ( Management Frame ) */
326 #define P2P_PUB_ACTION_ACTION                   0x09
327
328 /*      P2P Public Action Frame Type */
329 #define P2P_GO_NEGO_REQ                         0
330 #define P2P_GO_NEGO_RESP                        1
331 #define P2P_GO_NEGO_CONF                        2
332 #define P2P_INVIT_REQ                           3
333 #define P2P_INVIT_RESP                          4
334 #define P2P_DEVDISC_REQ                         5
335 #define P2P_DEVDISC_RESP                        6
336 #define P2P_PROVISION_DISC_REQ                  7
337 #define P2P_PROVISION_DISC_RESP                 8
338
339 /*      WPS Configuration Method */
340 #define WPS_CM_NONE                                     0x0000
341 #define WPS_CM_LABEL                                    0x0004
342 #define WPS_CM_DISPLYA                                  0x0008
343 #define WPS_CM_EXTERNAL_NFC_TOKEN                       0x0010
344 #define WPS_CM_INTEGRATED_NFC_TOKEN                     0x0020
345 #define WPS_CM_NFC_INTERFACE                            0x0040
346 #define WPS_CM_PUSH_BUTTON                              0x0080
347 #define WPS_CM_KEYPAD                                   0x0100
348 #define WPS_CM_SW_PUHS_BUTTON                           0x0280
349 #define WPS_CM_HW_PUHS_BUTTON                           0x0480
350 #define WPS_CM_SW_DISPLAY_PIN                           0x2008
351 #define WPS_CM_LCD_DISPLAY_PIN                          0x4008
352
353 #endif /*  _WIFI_H_ */