wifi.h revision c38992872dcc01dabcf912e5ac390b355f6bae7e
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
26enum 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
33enum 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#define SetToDs(pbuf)	\
70	(*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
71
72#define SetFrDs(pbuf)	\
73	(*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
74
75#define SetPwrMgt(pbuf)	\
76	(*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
77
78#define SetMData(pbuf)	\
79	(*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
80
81#define SetPrivacy(pbuf)	\
82	(*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
83
84#define SetFrameType(pbuf, type)	\
85	do {	\
86		*(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
87		*(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \
88	} while (0)
89
90#define SetFrameSubType(pbuf, type) \
91	do {    \
92		*(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
93		*(__le16 *)(pbuf) |= cpu_to_le16(type); \
94	} while (0)
95
96#define SetFragNum(pbuf, num) \
97	do {    \
98		*(unsigned short *)((unsigned long)(pbuf) + 22) = \
99			((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu(~(0x000f))) | \
100			cpu_to_le16(0x0f & (num));     \
101	} while (0)
102
103#define SetSeqNum(pbuf, num) \
104	do {    \
105		*(__le16 *)((size_t)(pbuf) + 22) = \
106			((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
107			cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
108	} while (0)
109
110#define SetDuration(pbuf, dur) \
111	(*(__le16 *)((unsigned long)(pbuf) + 2) =		\
112	 cpu_to_le16(0xffff & (dur)))
113
114#define SetPriority(pbuf, tid)	\
115	(*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
116
117#define SetEOSP(pbuf, eosp)	\
118	(*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
119
120#define SetAckpolicy(pbuf, ack)	\
121	(*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
122
123#define _ASOCREQ_IE_OFFSET_		4	/*  excluding wlan_hdr */
124#define	_ASOCRSP_IE_OFFSET_		6
125#define _REASOCREQ_IE_OFFSET_		10
126#define _REASOCRSP_IE_OFFSET_		6
127#define _PROBEREQ_IE_OFFSET_		0
128#define	_PROBERSP_IE_OFFSET_		12
129#define _AUTH_IE_OFFSET_		6
130#define _DEAUTH_IE_OFFSET_		0
131#define _BEACON_IE_OFFSET_		12
132#define _PUBLIC_ACTION_IE_OFFSET_	8
133
134#define _FIXED_IE_LENGTH_		_BEACON_IE_OFFSET_
135
136
137#define	EID_BSSIntolerantChlReport	73
138
139/* ---------------------------------------------------------------------------
140					Below is the fixed elements...
141-----------------------------------------------------------------------------*/
142#define _AUTH_ALGM_NUM_		2
143#define _AUTH_SEQ_NUM_		2
144#define _BEACON_ITERVAL_	2
145#define _CAPABILITY_		2
146#define _CURRENT_APADDR_	6
147#define _LISTEN_INTERVAL_	2
148#define _ASOC_ID_		2
149#define _STATUS_CODE_		2
150#define _TIMESTAMP_		8
151
152/*-----------------------------------------------------------------------------
153				Below is the definition for WMM
154------------------------------------------------------------------------------*/
155#define _WMM_IE_Length_				7  /*  for WMM STA */
156#define _WMM_Para_Element_Length_		24
157
158
159/*-----------------------------------------------------------------------------
160				Below is the definition for 802.11n
161------------------------------------------------------------------------------*/
162
163/* struct rtw_ieee80211_ht_cap - HT additional information
164 *
165 * This structure refers to "HT information element" as
166 * described in 802.11n draft section 7.3.2.53
167 */
168struct ieee80211_ht_addt_info {
169	unsigned char	control_chan;
170	unsigned char	ht_param;
171	unsigned short	operation_mode;
172	unsigned short	stbc_param;
173	unsigned char	basic_set[16];
174} __packed;
175
176struct HT_caps_element {
177	union {
178		struct {
179			unsigned short	HT_caps_info;
180			unsigned char	AMPDU_para;
181			unsigned char	MCS_rate[16];
182			unsigned short	HT_ext_caps;
183			unsigned int	Beamforming_caps;
184			unsigned char	ASEL_caps;
185		} HT_cap_element;
186		unsigned char HT_cap[26];
187	} u;
188} __packed;
189
190struct HT_info_element {
191	unsigned char	primary_channel;
192	unsigned char	infos[5];
193	unsigned char	MCS_rate[16];
194}  __packed;
195
196struct AC_param {
197	unsigned char		ACI_AIFSN;
198	unsigned char		CW;
199	unsigned short	TXOP_limit;
200}  __packed;
201
202struct WMM_para_element {
203	unsigned char		QoS_info;
204	unsigned char		reserved;
205	struct AC_param	ac_param[4];
206}  __packed;
207
208struct ADDBA_request {
209	unsigned char		dialog_token;
210	unsigned short	BA_para_set;
211	unsigned short	BA_timeout_value;
212	unsigned short	BA_starting_seqctrl;
213}  __packed;
214
215
216/*	===============WPS Section=============== */
217/*	WPS attribute ID */
218#define WPS_ATTR_VER1				0x104A
219#define WPS_ATTR_SIMPLE_CONF_STATE		0x1044
220#define WPS_ATTR_RESP_TYPE			0x103B
221#define WPS_ATTR_UUID_E				0x1047
222#define WPS_ATTR_MANUFACTURER			0x1021
223#define WPS_ATTR_MODEL_NAME			0x1023
224#define WPS_ATTR_MODEL_NUMBER			0x1024
225#define WPS_ATTR_SERIAL_NUMBER			0x1042
226#define WPS_ATTR_PRIMARY_DEV_TYPE		0x1054
227#define WPS_ATTR_SEC_DEV_TYPE_LIST		0x1055
228#define WPS_ATTR_DEVICE_NAME			0x1011
229#define WPS_ATTR_CONF_METHOD			0x1008
230#define WPS_ATTR_RF_BANDS			0x103C
231#define WPS_ATTR_DEVICE_PWID			0x1012
232#define WPS_ATTR_REQUEST_TYPE			0x103A
233#define WPS_ATTR_ASSOCIATION_STATE		0x1002
234#define WPS_ATTR_CONFIG_ERROR			0x1009
235#define WPS_ATTR_VENDOR_EXT			0x1049
236#define WPS_ATTR_SELECTED_REGISTRAR		0x1041
237
238/*	P2P Public Action Frame ( Management Frame ) */
239#define	P2P_PUB_ACTION_ACTION			0x09
240
241/*	P2P Public Action Frame Type */
242#define	P2P_GO_NEGO_REQ				0
243#define	P2P_GO_NEGO_RESP			1
244#define	P2P_GO_NEGO_CONF			2
245#define	P2P_INVIT_REQ				3
246#define	P2P_INVIT_RESP				4
247#define	P2P_DEVDISC_REQ				5
248#define	P2P_DEVDISC_RESP			6
249#define	P2P_PROVISION_DISC_REQ			7
250#define	P2P_PROVISION_DISC_RESP			8
251
252/*	WPS Configuration Method */
253#define	WPS_CM_NONE					0x0000
254#define	WPS_CM_LABEL					0x0004
255#define	WPS_CM_DISPLYA					0x0008
256#define	WPS_CM_EXTERNAL_NFC_TOKEN			0x0010
257#define	WPS_CM_INTEGRATED_NFC_TOKEN			0x0020
258#define	WPS_CM_NFC_INTERFACE				0x0040
259#define	WPS_CM_PUSH_BUTTON				0x0080
260#define	WPS_CM_KEYPAD					0x0100
261#define	WPS_CM_SW_PUHS_BUTTON				0x0280
262#define	WPS_CM_HW_PUHS_BUTTON				0x0480
263#define	WPS_CM_SW_DISPLAY_PIN				0x2008
264#define	WPS_CM_LCD_DISPLAY_PIN				0x4008
265
266#endif /*  _WIFI_H_ */
267