1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
18 #define P80211CAPTURE_VERSION 0x80211001
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.
24 #define WiFiNavUpperUs 30000 /* 30 ms */
26 enum WIFI_FRAME_TYPE {
28 WIFI_CTRL_TYPE = (BIT(2)),
29 WIFI_DATA_TYPE = (BIT(3)),
30 WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */
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),
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),
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),
69 enum WIFI_REG_DOMAIN {
84 #define SetToDs(pbuf) \
85 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
87 #define SetFrDs(pbuf) \
88 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
90 #define SetMFrag(pbuf) \
91 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))
93 #define ClearMFrag(pbuf) \
94 (*(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)))
96 #define SetRetry(pbuf) \
97 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY))
99 #define SetPwrMgt(pbuf) \
100 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
102 #define SetMData(pbuf) \
103 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
105 #define SetPrivacy(pbuf) \
106 (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
108 #define SetFrameType(pbuf, type) \
110 *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
111 *(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \
114 #define SetFrameSubType(pbuf, type) \
116 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
117 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
120 #define SetFragNum(pbuf, num) \
122 *(unsigned short *)((unsigned long)(pbuf) + 22) = \
123 ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu(~(0x000f))) | \
124 cpu_to_le16(0x0f & (num)); \
127 #define SetSeqNum(pbuf, num) \
129 *(__le16 *)((size_t)(pbuf) + 22) = \
130 ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
131 cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
134 #define SetDuration(pbuf, dur) \
135 (*(__le16 *)((unsigned long)(pbuf) + 2) = \
136 cpu_to_le16(0xffff & (dur)))
138 #define SetPriority(pbuf, tid) \
139 (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
141 #define SetEOSP(pbuf, eosp) \
142 (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
144 #define SetAckpolicy(pbuf, ack) \
145 (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
147 #define SetAMsdu(pbuf, amsdu) \
148 (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7))
150 #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
151 #define _ASOCRSP_IE_OFFSET_ 6
152 #define _REASOCREQ_IE_OFFSET_ 10
153 #define _REASOCRSP_IE_OFFSET_ 6
154 #define _PROBEREQ_IE_OFFSET_ 0
155 #define _PROBERSP_IE_OFFSET_ 12
156 #define _AUTH_IE_OFFSET_ 6
157 #define _DEAUTH_IE_OFFSET_ 0
158 #define _BEACON_IE_OFFSET_ 12
159 #define _PUBLIC_ACTION_IE_OFFSET_ 8
161 #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
164 #define EID_BSSIntolerantChlReport 73
166 /* ---------------------------------------------------------------------------
167 Below is the fixed elements...
168 -----------------------------------------------------------------------------*/
169 #define _AUTH_ALGM_NUM_ 2
170 #define _AUTH_SEQ_NUM_ 2
171 #define _BEACON_ITERVAL_ 2
172 #define _CAPABILITY_ 2
173 #define _CURRENT_APADDR_ 6
174 #define _LISTEN_INTERVAL_ 2
176 #define _STATUS_CODE_ 2
177 #define _TIMESTAMP_ 8
179 #define cap_ESS BIT(0)
180 #define cap_IBSS BIT(1)
181 #define cap_CFPollable BIT(2)
182 #define cap_CFRequest BIT(3)
183 #define cap_Privacy BIT(4)
184 #define cap_ShortPremble BIT(5)
185 #define cap_PBCC BIT(6)
186 #define cap_ChAgility BIT(7)
187 #define cap_SpecMgmt BIT(8)
188 #define cap_QoS BIT(9)
189 #define cap_ShortSlot BIT(10)
191 /*-----------------------------------------------------------------------------
192 Below is the definition for WMM
193 ------------------------------------------------------------------------------*/
194 #define _WMM_IE_Length_ 7 /* for WMM STA */
195 #define _WMM_Para_Element_Length_ 24
198 /*-----------------------------------------------------------------------------
199 Below is the definition for 802.11n
200 ------------------------------------------------------------------------------*/
202 /* struct rtw_ieee80211_ht_cap - HT additional information
204 * This structure refers to "HT information element" as
205 * described in 802.11n draft section 7.3.2.53
207 struct ieee80211_ht_addt_info {
208 unsigned char control_chan;
209 unsigned char ht_param;
210 unsigned short operation_mode;
211 unsigned short stbc_param;
212 unsigned char basic_set[16];
215 struct HT_caps_element {
218 unsigned short HT_caps_info;
219 unsigned char AMPDU_para;
220 unsigned char MCS_rate[16];
221 unsigned short HT_ext_caps;
222 unsigned int Beamforming_caps;
223 unsigned char ASEL_caps;
225 unsigned char HT_cap[26];
229 struct HT_info_element {
230 unsigned char primary_channel;
231 unsigned char infos[5];
232 unsigned char MCS_rate[16];
236 unsigned char ACI_AIFSN;
238 unsigned short TXOP_limit;
241 struct WMM_para_element {
242 unsigned char QoS_info;
243 unsigned char reserved;
244 struct AC_param ac_param[4];
247 struct ADDBA_request {
248 unsigned char dialog_token;
249 unsigned short BA_para_set;
250 unsigned short BA_timeout_value;
251 unsigned short BA_starting_seqctrl;
255 #define OP_MODE_PURE 0
256 #define OP_MODE_MAY_BE_LEGACY_STAS 1
257 #define OP_MODE_20MHZ_HT_STA_ASSOCED 2
258 #define OP_MODE_MIXED 3
260 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1))
261 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0))
262 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1))
263 #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2))
264 #define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3))
265 #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4))
266 #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5))
268 #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \
269 ((u16) (0x0001 | 0x0002))
270 #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0
271 #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2))
272 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3))
273 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4))
275 #define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6))
276 #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7))
277 #define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8))
278 #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9))
279 #define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10))
280 #define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11))
284 /* ===============WPS Section=============== */
286 #define WPSOUI 0x0050f204
287 /* WPS attribute ID */
288 #define WPS_ATTR_VER1 0x104A
289 #define WPS_ATTR_SIMPLE_CONF_STATE 0x1044
290 #define WPS_ATTR_RESP_TYPE 0x103B
291 #define WPS_ATTR_UUID_E 0x1047
292 #define WPS_ATTR_MANUFACTURER 0x1021
293 #define WPS_ATTR_MODEL_NAME 0x1023
294 #define WPS_ATTR_MODEL_NUMBER 0x1024
295 #define WPS_ATTR_SERIAL_NUMBER 0x1042
296 #define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054
297 #define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055
298 #define WPS_ATTR_DEVICE_NAME 0x1011
299 #define WPS_ATTR_CONF_METHOD 0x1008
300 #define WPS_ATTR_RF_BANDS 0x103C
301 #define WPS_ATTR_DEVICE_PWID 0x1012
302 #define WPS_ATTR_REQUEST_TYPE 0x103A
303 #define WPS_ATTR_ASSOCIATION_STATE 0x1002
304 #define WPS_ATTR_CONFIG_ERROR 0x1009
305 #define WPS_ATTR_VENDOR_EXT 0x1049
306 #define WPS_ATTR_SELECTED_REGISTRAR 0x1041
308 /* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */
309 #define WPS_MAX_DEVICE_NAME_LEN 32
311 /* Value of WPS Request Type Attribute */
312 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00
313 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01
314 #define WPS_REQ_TYPE_REGISTRAR 0x02
315 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03
317 /* Value of WPS Response Type Attribute */
318 #define WPS_RESPONSE_TYPE_INFO_ONLY 0x00
319 #define WPS_RESPONSE_TYPE_8021X 0x01
320 #define WPS_RESPONSE_TYPE_REGISTRAR 0x02
321 #define WPS_RESPONSE_TYPE_AP 0x03
323 /* Value of WPS WiFi Simple Configuration State Attribute */
324 #define WPS_WSC_STATE_NOT_CONFIG 0x01
325 #define WPS_WSC_STATE_CONFIG 0x02
327 /* Value of WPS Version Attribute */
328 #define WPS_VERSION_1 0x10
330 /* Value of WPS Configuration Method Attribute */
331 #define WPS_CONFIG_METHOD_FLASH 0x0001
332 #define WPS_CONFIG_METHOD_ETHERNET 0x0002
333 #define WPS_CONFIG_METHOD_LABEL 0x0004
334 #define WPS_CONFIG_METHOD_DISPLAY 0x0008
335 #define WPS_CONFIG_METHOD_E_NFC 0x0010
336 #define WPS_CONFIG_METHOD_I_NFC 0x0020
337 #define WPS_CONFIG_METHOD_NFC 0x0040
338 #define WPS_CONFIG_METHOD_PBC 0x0080
339 #define WPS_CONFIG_METHOD_KEYPAD 0x0100
340 #define WPS_CONFIG_METHOD_VPBC 0x0280
341 #define WPS_CONFIG_METHOD_PPBC 0x0480
342 #define WPS_CONFIG_METHOD_VDISPLAY 0x2008
343 #define WPS_CONFIG_METHOD_PDISPLAY 0x4008
345 /* Value of Category ID of WPS Primary Device Type Attribute */
346 #define WPS_PDT_CID_DISPLAYS 0x0007
347 #define WPS_PDT_CID_MULIT_MEDIA 0x0008
348 #define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA
350 /* Value of Sub Category ID of WPS Primary Device Type Attribute */
351 #define WPS_PDT_SCID_MEDIA_SERVER 0x0005
352 #define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER
354 /* Value of Device Password ID */
355 #define WPS_DPID_PIN 0x0000
356 #define WPS_DPID_USER_SPEC 0x0001
357 #define WPS_DPID_MACHINE_SPEC 0x0002
358 #define WPS_DPID_REKEY 0x0003
359 #define WPS_DPID_PBC 0x0004
360 #define WPS_DPID_REGISTRAR_SPEC 0x0005
362 /* Value of WPS RF Bands Attribute */
363 #define WPS_RF_BANDS_2_4_GHZ 0x01
364 #define WPS_RF_BANDS_5_GHZ 0x02
366 /* Value of WPS Association State Attribute */
367 #define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00
368 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01
369 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02
370 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03
371 #define WPS_ASSOC_STATE_IP_FAILURE 0x04
373 /* P2P Public Action Frame ( Management Frame ) */
374 #define P2P_PUB_ACTION_ACTION 0x09
376 /* P2P Public Action Frame Type */
377 #define P2P_GO_NEGO_REQ 0
378 #define P2P_GO_NEGO_RESP 1
379 #define P2P_GO_NEGO_CONF 2
380 #define P2P_INVIT_REQ 3
381 #define P2P_INVIT_RESP 4
382 #define P2P_DEVDISC_REQ 5
383 #define P2P_DEVDISC_RESP 6
384 #define P2P_PROVISION_DISC_REQ 7
385 #define P2P_PROVISION_DISC_RESP 8
387 /* WPS Configuration Method */
388 #define WPS_CM_NONE 0x0000
389 #define WPS_CM_LABEL 0x0004
390 #define WPS_CM_DISPLYA 0x0008
391 #define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010
392 #define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020
393 #define WPS_CM_NFC_INTERFACE 0x0040
394 #define WPS_CM_PUSH_BUTTON 0x0080
395 #define WPS_CM_KEYPAD 0x0100
396 #define WPS_CM_SW_PUHS_BUTTON 0x0280
397 #define WPS_CM_HW_PUHS_BUTTON 0x0480
398 #define WPS_CM_SW_DISPLAY_PIN 0x2008
399 #define WPS_CM_LCD_DISPLAY_PIN 0x4008
401 #endif /* _WIFI_H_ */