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 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
87 #define SetFrDs(pbuf) \
88 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
90 #define get_tofr_ds(pframe) ((ieee80211_has_tods(pframe) << 1) | \
91 ieee80211_has_fromds(pframe))
93 #define SetMFrag(pbuf) \
94 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))
96 #define ClearMFrag(pbuf) \
97 (*(unsigned short *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)))
99 #define SetRetry(pbuf) \
100 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY))
102 #define SetPwrMgt(pbuf) \
103 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
105 #define SetMData(pbuf) \
106 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
108 #define SetPrivacy(pbuf) \
109 (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
111 #define SetFrameType(pbuf, type) \
113 *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
114 *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
117 #define SetFrameSubType(pbuf, type) \
119 *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
120 *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
123 #define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 22)))
125 #define SetFragNum(pbuf, num) \
127 *(unsigned short *)((unsigned long)(pbuf) + 22) = \
128 ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu(~(0x000f))) | \
129 cpu_to_le16(0x0f & (num)); \
132 #define SetSeqNum(pbuf, num) \
134 *(unsigned short *)((unsigned long)(pbuf) + 22) = \
135 ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu((unsigned short)0x000f)) | \
136 le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
139 #define SetDuration(pbuf, dur) \
140 (*(unsigned short *)((unsigned long)(pbuf) + 2) = \
141 cpu_to_le16(0xffff & (dur)))
143 #define SetPriority(pbuf, tid) \
144 (*(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf))
146 #define SetEOSP(pbuf, eosp) \
147 (*(unsigned short *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
149 #define SetAckpolicy(pbuf, ack) \
150 (*(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
152 #define SetAMsdu(pbuf, amsdu) \
153 (*(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7))
155 #define GetAid(pbuf) \
156 (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 2)) & \
159 #define GetTid(pbuf) \
160 (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + \
161 (((ieee80211_has_tods(pbuf)<<1) | \
162 ieee80211_has_fromds(pbuf)) == 3 ? 30 : 24))) & 0x000f)
164 static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
167 unsigned int to_fr_ds;
168 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe;
170 to_fr_ds = (ieee80211_has_tods(hdr->frame_control) << 1) |
171 ieee80211_has_fromds(hdr->frame_control);
174 case 0x00: /* ToDs=0, FromDs=0 */
177 case 0x01: /* ToDs=0, FromDs=1 */
180 case 0x02: /* ToDs=1, FromDs=0 */
183 case 0x03: /* ToDs=1, FromDs=1 */
193 /*-----------------------------------------------------------------------------
194 Below is for the security related definition
195 ------------------------------------------------------------------------------*/
196 #define _RESERVED_FRAME_TYPE_ 0
197 #define _SKB_FRAME_TYPE_ 2
198 #define _PRE_ALLOCMEM_ 1
199 #define _PRE_ALLOCHDR_ 3
200 #define _PRE_ALLOCLLCHDR_ 4
201 #define _PRE_ALLOCICVHDR_ 5
202 #define _PRE_ALLOCMICHDR_ 6
205 ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10)
206 #define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */
209 #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
210 #define _ASOCRSP_IE_OFFSET_ 6
211 #define _REASOCREQ_IE_OFFSET_ 10
212 #define _REASOCRSP_IE_OFFSET_ 6
213 #define _PROBEREQ_IE_OFFSET_ 0
214 #define _PROBERSP_IE_OFFSET_ 12
215 #define _AUTH_IE_OFFSET_ 6
216 #define _DEAUTH_IE_OFFSET_ 0
217 #define _BEACON_IE_OFFSET_ 12
218 #define _PUBLIC_ACTION_IE_OFFSET_ 8
220 #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
223 #define EID_BSSIntolerantChlReport 73
225 /* ---------------------------------------------------------------------------
226 Below is the fixed elements...
227 -----------------------------------------------------------------------------*/
228 #define _AUTH_ALGM_NUM_ 2
229 #define _AUTH_SEQ_NUM_ 2
230 #define _BEACON_ITERVAL_ 2
231 #define _CAPABILITY_ 2
232 #define _CURRENT_APADDR_ 6
233 #define _LISTEN_INTERVAL_ 2
235 #define _STATUS_CODE_ 2
236 #define _TIMESTAMP_ 8
238 #define AUTH_ODD_TO 0
239 #define AUTH_EVEN_TO 1
241 #define WLAN_ETHCONV_ENCAP 1
242 #define WLAN_ETHCONV_RFC1042 2
243 #define WLAN_ETHCONV_8021h 3
245 #define cap_ESS BIT(0)
246 #define cap_IBSS BIT(1)
247 #define cap_CFPollable BIT(2)
248 #define cap_CFRequest BIT(3)
249 #define cap_Privacy BIT(4)
250 #define cap_ShortPremble BIT(5)
251 #define cap_PBCC BIT(6)
252 #define cap_ChAgility BIT(7)
253 #define cap_SpecMgmt BIT(8)
254 #define cap_QoS BIT(9)
255 #define cap_ShortSlot BIT(10)
257 /*-----------------------------------------------------------------------------
258 Below is the definition for 802.11i / 802.1x
259 ------------------------------------------------------------------------------*/
260 #define _IEEE8021X_MGT_ 1 /* WPA */
261 #define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
264 #define _NO_PRIVACY_ 0
265 #define _WEP_40_PRIVACY_ 1
266 #define _TKIP_PRIVACY_ 2
267 #define _WRAP_PRIVACY_ 3
268 #define _CCMP_PRIVACY_ 4
269 #define _WEP_104_PRIVACY_ 5
270 #define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA
273 /*-----------------------------------------------------------------------------
274 Below is the definition for WMM
275 ------------------------------------------------------------------------------*/
276 #define _WMM_IE_Length_ 7 /* for WMM STA */
277 #define _WMM_Para_Element_Length_ 24
280 /*-----------------------------------------------------------------------------
281 Below is the definition for 802.11n
282 ------------------------------------------------------------------------------*/
284 #define SetOrderBit(pbuf) \
285 (*(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_))
287 #define GetOrderBit(pbuf) \
288 (((*(unsigned short *)(pbuf)) & le16_to_cpu(_ORDER_)) != 0)
291 /* struct rtw_ieee80211_ht_cap - HT additional information
293 * This structure refers to "HT information element" as
294 * described in 802.11n draft section 7.3.2.53
296 struct ieee80211_ht_addt_info {
297 unsigned char control_chan;
298 unsigned char ht_param;
299 unsigned short operation_mode;
300 unsigned short stbc_param;
301 unsigned char basic_set[16];
304 struct HT_caps_element {
307 unsigned short HT_caps_info;
308 unsigned char AMPDU_para;
309 unsigned char MCS_rate[16];
310 unsigned short HT_ext_caps;
311 unsigned int Beamforming_caps;
312 unsigned char ASEL_caps;
314 unsigned char HT_cap[26];
318 struct HT_info_element {
319 unsigned char primary_channel;
320 unsigned char infos[5];
321 unsigned char MCS_rate[16];
325 unsigned char ACI_AIFSN;
327 unsigned short TXOP_limit;
330 struct WMM_para_element {
331 unsigned char QoS_info;
332 unsigned char reserved;
333 struct AC_param ac_param[4];
336 struct ADDBA_request {
337 unsigned char dialog_token;
338 unsigned short BA_para_set;
339 unsigned short BA_timeout_value;
340 unsigned short BA_starting_seqctrl;
344 #define OP_MODE_PURE 0
345 #define OP_MODE_MAY_BE_LEGACY_STAS 1
346 #define OP_MODE_20MHZ_HT_STA_ASSOCED 2
347 #define OP_MODE_MIXED 3
349 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1))
350 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0))
351 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1))
352 #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2))
353 #define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3))
354 #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4))
355 #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5))
357 #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \
358 ((u16) (0x0001 | 0x0002))
359 #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0
360 #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2))
361 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3))
362 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4))
364 #define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6))
365 #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7))
366 #define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8))
367 #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9))
368 #define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10))
369 #define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11))
373 /* ===============WPS Section=============== */
375 #define WPSOUI 0x0050f204
376 /* WPS attribute ID */
377 #define WPS_ATTR_VER1 0x104A
378 #define WPS_ATTR_SIMPLE_CONF_STATE 0x1044
379 #define WPS_ATTR_RESP_TYPE 0x103B
380 #define WPS_ATTR_UUID_E 0x1047
381 #define WPS_ATTR_MANUFACTURER 0x1021
382 #define WPS_ATTR_MODEL_NAME 0x1023
383 #define WPS_ATTR_MODEL_NUMBER 0x1024
384 #define WPS_ATTR_SERIAL_NUMBER 0x1042
385 #define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054
386 #define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055
387 #define WPS_ATTR_DEVICE_NAME 0x1011
388 #define WPS_ATTR_CONF_METHOD 0x1008
389 #define WPS_ATTR_RF_BANDS 0x103C
390 #define WPS_ATTR_DEVICE_PWID 0x1012
391 #define WPS_ATTR_REQUEST_TYPE 0x103A
392 #define WPS_ATTR_ASSOCIATION_STATE 0x1002
393 #define WPS_ATTR_CONFIG_ERROR 0x1009
394 #define WPS_ATTR_VENDOR_EXT 0x1049
395 #define WPS_ATTR_SELECTED_REGISTRAR 0x1041
397 /* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */
398 #define WPS_MAX_DEVICE_NAME_LEN 32
400 /* Value of WPS Request Type Attribute */
401 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00
402 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01
403 #define WPS_REQ_TYPE_REGISTRAR 0x02
404 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03
406 /* Value of WPS Response Type Attribute */
407 #define WPS_RESPONSE_TYPE_INFO_ONLY 0x00
408 #define WPS_RESPONSE_TYPE_8021X 0x01
409 #define WPS_RESPONSE_TYPE_REGISTRAR 0x02
410 #define WPS_RESPONSE_TYPE_AP 0x03
412 /* Value of WPS WiFi Simple Configuration State Attribute */
413 #define WPS_WSC_STATE_NOT_CONFIG 0x01
414 #define WPS_WSC_STATE_CONFIG 0x02
416 /* Value of WPS Version Attribute */
417 #define WPS_VERSION_1 0x10
419 /* Value of WPS Configuration Method Attribute */
420 #define WPS_CONFIG_METHOD_FLASH 0x0001
421 #define WPS_CONFIG_METHOD_ETHERNET 0x0002
422 #define WPS_CONFIG_METHOD_LABEL 0x0004
423 #define WPS_CONFIG_METHOD_DISPLAY 0x0008
424 #define WPS_CONFIG_METHOD_E_NFC 0x0010
425 #define WPS_CONFIG_METHOD_I_NFC 0x0020
426 #define WPS_CONFIG_METHOD_NFC 0x0040
427 #define WPS_CONFIG_METHOD_PBC 0x0080
428 #define WPS_CONFIG_METHOD_KEYPAD 0x0100
429 #define WPS_CONFIG_METHOD_VPBC 0x0280
430 #define WPS_CONFIG_METHOD_PPBC 0x0480
431 #define WPS_CONFIG_METHOD_VDISPLAY 0x2008
432 #define WPS_CONFIG_METHOD_PDISPLAY 0x4008
434 /* Value of Category ID of WPS Primary Device Type Attribute */
435 #define WPS_PDT_CID_DISPLAYS 0x0007
436 #define WPS_PDT_CID_MULIT_MEDIA 0x0008
437 #define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA
439 /* Value of Sub Category ID of WPS Primary Device Type Attribute */
440 #define WPS_PDT_SCID_MEDIA_SERVER 0x0005
441 #define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER
443 /* Value of Device Password ID */
444 #define WPS_DPID_PIN 0x0000
445 #define WPS_DPID_USER_SPEC 0x0001
446 #define WPS_DPID_MACHINE_SPEC 0x0002
447 #define WPS_DPID_REKEY 0x0003
448 #define WPS_DPID_PBC 0x0004
449 #define WPS_DPID_REGISTRAR_SPEC 0x0005
451 /* Value of WPS RF Bands Attribute */
452 #define WPS_RF_BANDS_2_4_GHZ 0x01
453 #define WPS_RF_BANDS_5_GHZ 0x02
455 /* Value of WPS Association State Attribute */
456 #define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00
457 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01
458 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02
459 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03
460 #define WPS_ASSOC_STATE_IP_FAILURE 0x04
462 /* P2P Public Action Frame ( Management Frame ) */
463 #define P2P_PUB_ACTION_ACTION 0x09
465 /* P2P Public Action Frame Type */
466 #define P2P_GO_NEGO_REQ 0
467 #define P2P_GO_NEGO_RESP 1
468 #define P2P_GO_NEGO_CONF 2
469 #define P2P_INVIT_REQ 3
470 #define P2P_INVIT_RESP 4
471 #define P2P_DEVDISC_REQ 5
472 #define P2P_DEVDISC_RESP 6
473 #define P2P_PROVISION_DISC_REQ 7
474 #define P2P_PROVISION_DISC_RESP 8
476 /* WPS Configuration Method */
477 #define WPS_CM_NONE 0x0000
478 #define WPS_CM_LABEL 0x0004
479 #define WPS_CM_DISPLYA 0x0008
480 #define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010
481 #define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020
482 #define WPS_CM_NFC_INTERFACE 0x0040
483 #define WPS_CM_PUSH_BUTTON 0x0080
484 #define WPS_CM_KEYPAD 0x0100
485 #define WPS_CM_SW_PUHS_BUTTON 0x0280
486 #define WPS_CM_HW_PUHS_BUTTON 0x0480
487 #define WPS_CM_SW_DISPLAY_PIN 0x2008
488 #define WPS_CM_LCD_DISPLAY_PIN 0x4008
490 #endif /* _WIFI_H_ */