blob: 00a4302e9983f985a6355302b151f69efb7572ec [file] [log] [blame]
Ali Baharcf3e6882011-09-04 03:14:04 +08001/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2010 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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * Modifications for inclusion into the Linux staging tree are
19 * Copyright(c) 2010 Larry Finger. All rights reserved.
20 *
21 * Contact information:
22 * WLAN FAE <wlanfae@realtek.com>
23 * Larry Finger <Larry.Finger@lwfinger.net>
24 *
25 ******************************************************************************/
Larry Finger2865d42c2010-08-20 10:15:30 -050026#ifndef _WIFI_H_
27#define _WIFI_H_
28
Michael Fiedler40878362011-06-20 16:34:27 +020029#include <linux/compiler.h>
Larry Finger2865d42c2010-08-20 10:15:30 -050030
Larry Finger2865d42c2010-08-20 10:15:30 -050031#define WLAN_IEEE_OUI_LEN 3
Larry Finger2865d42c2010-08-20 10:15:30 -050032#define WLAN_CRC_LEN 4
33#define WLAN_BSSID_LEN 6
34#define WLAN_BSS_TS_LEN 8
35#define WLAN_HDR_A3_LEN 24
36#define WLAN_HDR_A4_LEN 30
37#define WLAN_HDR_A3_QOS_LEN 26
38#define WLAN_HDR_A4_QOS_LEN 32
39#define WLAN_SSID_MAXLEN 32
40#define WLAN_DATA_MAXLEN 2312
41
42#define WLAN_A3_PN_OFFSET 24
43#define WLAN_A4_PN_OFFSET 30
44
45#define WLAN_MIN_ETHFRM_LEN 60
46#define WLAN_MAX_ETHFRM_LEN 1514
Larry Finger2865d42c2010-08-20 10:15:30 -050047
48#define P80211CAPTURE_VERSION 0x80211001
49
50enum WIFI_FRAME_TYPE {
51 WIFI_MGT_TYPE = (0),
52 WIFI_CTRL_TYPE = (BIT(2)),
53 WIFI_DATA_TYPE = (BIT(3)),
54 WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /*!< QoS Data */
55};
56
57enum WIFI_FRAME_SUBTYPE {
Javier M. Mellid05937582011-04-02 03:01:49 +020058 /* below is for mgt frame */
59 WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
60 WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE),
61 WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE),
62 WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
63 WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE),
64 WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
65 WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE),
66 WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
67 WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
68 WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
69 WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
70 WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
71 /* below is for control frame */
72 WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
73 WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
74 WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
75 WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
76 WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
77 WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
78 /* below is for data frame */
79 WIFI_DATA = (0 | WIFI_DATA_TYPE),
80 WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
81 WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
82 WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
83 WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
84 WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
85 WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
86 WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
Larry Finger2865d42c2010-08-20 10:15:30 -050087};
88
89enum WIFI_REASON_CODE {
90 _RSON_RESERVED_ = 0,
91 _RSON_UNSPECIFIED_ = 1,
92 _RSON_AUTH_NO_LONGER_VALID_ = 2,
93 _RSON_DEAUTH_STA_LEAVING_ = 3,
94 _RSON_INACTIVITY_ = 4,
95 _RSON_UNABLE_HANDLE_ = 5,
96 _RSON_CLS2_ = 6,
97 _RSON_CLS3_ = 7,
98 _RSON_DISAOC_STA_LEAVING_ = 8,
99 _RSON_ASOC_NOT_AUTH_ = 9,
Larry Finger2865d42c2010-08-20 10:15:30 -0500100 /* WPA reason */
101 _RSON_INVALID_IE_ = 13,
102 _RSON_MIC_FAILURE_ = 14,
103 _RSON_4WAY_HNDSHK_TIMEOUT_ = 15,
104 _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
105 _RSON_DIFF_IE_ = 17,
106 _RSON_MLTCST_CIPHER_NOT_VALID_ = 18,
107 _RSON_UNICST_CIPHER_NOT_VALID_ = 19,
108 _RSON_AKMP_NOT_VALID_ = 20,
109 _RSON_UNSUPPORT_RSNE_VER_ = 21,
110 _RSON_INVALID_RSNE_CAP_ = 22,
111 _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23,
Larry Finger2865d42c2010-08-20 10:15:30 -0500112 /* below are Realtek definitions */
113 _RSON_PMK_NOT_AVAILABLE_ = 24,
114};
115
116enum WIFI_STATUS_CODE {
117 _STATS_SUCCESSFUL_ = 0,
118 _STATS_FAILURE_ = 1,
119 _STATS_CAP_FAIL_ = 10,
120 _STATS_NO_ASOC_ = 11,
121 _STATS_OTHER_ = 12,
122 _STATS_NO_SUPP_ALG_ = 13,
123 _STATS_OUT_OF_AUTH_SEQ_ = 14,
124 _STATS_CHALLENGE_FAIL_ = 15,
125 _STATS_AUTH_TIMEOUT_ = 16,
126 _STATS_UNABLE_HANDLE_STA_ = 17,
127 _STATS_RATE_FAIL_ = 18,
128};
129
130enum WIFI_REG_DOMAIN {
131 DOMAIN_FCC = 1,
132 DOMAIN_IC = 2,
133 DOMAIN_ETSI = 3,
134 DOMAIN_SPAIN = 4,
135 DOMAIN_FRANCE = 5,
136 DOMAIN_MKK = 6,
137 DOMAIN_ISRAEL = 7,
138 DOMAIN_MKK1 = 8,
139 DOMAIN_MKK2 = 9,
140 DOMAIN_MKK3 = 10,
141 DOMAIN_MAX
142};
143
144#define _TO_DS_ BIT(8)
145#define _FROM_DS_ BIT(9)
146#define _MORE_FRAG_ BIT(10)
147#define _RETRY_ BIT(11)
148#define _PWRMGT_ BIT(12)
149#define _MORE_DATA_ BIT(13)
150#define _PRIVACY_ BIT(14)
151#define _ORDER_ BIT(15)
152
Przemo Firsztc07f9722012-12-10 23:21:19 +0000153#define SetToDs(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600154 *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000155})
Larry Finger2865d42c2010-08-20 10:15:30 -0500156
Larry Fingerdc223652017-02-10 21:30:26 -0600157#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500158
Przemo Firsztc07f9722012-12-10 23:21:19 +0000159#define ClearToDs(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600160 *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000161})
Larry Finger2865d42c2010-08-20 10:15:30 -0500162
Przemo Firsztc07f9722012-12-10 23:21:19 +0000163#define SetFrDs(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600164 *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000165})
Larry Finger2865d42c2010-08-20 10:15:30 -0500166
Larry Fingerdc223652017-02-10 21:30:26 -0600167#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500168
Przemo Firsztc07f9722012-12-10 23:21:19 +0000169#define ClearFrDs(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600170 *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000171})
Larry Finger2865d42c2010-08-20 10:15:30 -0500172
Jaya Durgaeebdd3f2017-06-23 16:54:40 +0530173static inline unsigned char get_tofr_ds(unsigned char *pframe)
174{
175 return ((GetToDs(pframe) << 1) | GetFrDs(pframe));
176}
Larry Finger2865d42c2010-08-20 10:15:30 -0500177
Przemo Firsztc07f9722012-12-10 23:21:19 +0000178#define SetMFrag(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600179 *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000180})
Larry Finger2865d42c2010-08-20 10:15:30 -0500181
Larry Fingerdc223652017-02-10 21:30:26 -0600182#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500183
Przemo Firsztc07f9722012-12-10 23:21:19 +0000184#define ClearMFrag(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600185 *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000186})
Larry Finger2865d42c2010-08-20 10:15:30 -0500187
Przemo Firsztc07f9722012-12-10 23:21:19 +0000188#define SetRetry(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600189 *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000190})
Larry Finger2865d42c2010-08-20 10:15:30 -0500191
Larry Fingerdc223652017-02-10 21:30:26 -0600192#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500193
Przemo Firsztc07f9722012-12-10 23:21:19 +0000194#define ClearRetry(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600195 *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000196})
Larry Finger2865d42c2010-08-20 10:15:30 -0500197
Przemo Firsztc07f9722012-12-10 23:21:19 +0000198#define SetPwrMgt(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600199 *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000200})
Larry Finger2865d42c2010-08-20 10:15:30 -0500201
Larry Fingerdc223652017-02-10 21:30:26 -0600202#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & \
203 cpu_to_le16(_PWRMGT_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500204
Przemo Firsztc07f9722012-12-10 23:21:19 +0000205#define ClearPwrMgt(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600206 *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000207})
Larry Finger2865d42c2010-08-20 10:15:30 -0500208
Przemo Firsztc07f9722012-12-10 23:21:19 +0000209#define SetMData(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600210 *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000211})
Larry Finger2865d42c2010-08-20 10:15:30 -0500212
Larry Fingerdc223652017-02-10 21:30:26 -0600213#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & \
214 cpu_to_le16(_MORE_DATA_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500215
Przemo Firsztc07f9722012-12-10 23:21:19 +0000216#define ClearMData(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600217 *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000218})
Larry Finger2865d42c2010-08-20 10:15:30 -0500219
Przemo Firsztc07f9722012-12-10 23:21:19 +0000220#define SetPrivacy(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600221 *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000222})
Larry Finger2865d42c2010-08-20 10:15:30 -0500223
Larry Fingerdc223652017-02-10 21:30:26 -0600224#define GetPrivacy(pbuf) (((*(__le16 *)(pbuf)) & \
225 cpu_to_le16(_PRIVACY_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500226
Larry Fingerdc223652017-02-10 21:30:26 -0600227#define GetOrder(pbuf) (((*(__le16 *)(pbuf)) & \
228 cpu_to_le16(_ORDER_)) != 0)
Larry Finger2865d42c2010-08-20 10:15:30 -0500229
Jannik Becher3d7164c2016-12-20 18:59:42 +0100230#define GetFrameType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & \
Larry Finger2865d42c2010-08-20 10:15:30 -0500231 (BIT(3) | BIT(2)))
232
233#define SetFrameType(pbuf, type) \
234 do { \
Larry Fingerdc223652017-02-10 21:30:26 -0600235 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(3) | \
Larry Finger2865d42c2010-08-20 10:15:30 -0500236 BIT(2))); \
Larry Fingerdc223652017-02-10 21:30:26 -0600237 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
Larry Finger2865d42c2010-08-20 10:15:30 -0500238 } while (0)
239
Jannik Becher3d7164c2016-12-20 18:59:42 +0100240#define GetFrameSubType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & \
Larry Finger2865d42c2010-08-20 10:15:30 -0500241 (BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
242 BIT(2)))
243
244#define SetFrameSubType(pbuf, type) \
245 do { \
Larry Fingerdc223652017-02-10 21:30:26 -0600246 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
Larry Finger2865d42c2010-08-20 10:15:30 -0500247 BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
Larry Fingerdc223652017-02-10 21:30:26 -0600248 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
Larry Finger2865d42c2010-08-20 10:15:30 -0500249 } while (0)
250
Larry Fingerdc223652017-02-10 21:30:26 -0600251#define GetSequence(pbuf) (le16_to_cpu(*(__le16 *)\
Larry Finger2865d42c2010-08-20 10:15:30 -0500252 ((addr_t)(pbuf) + 22)) >> 4)
253
Larry Fingerdc223652017-02-10 21:30:26 -0600254#define GetFragNum(pbuf) (le16_to_cpu(*(__le16 *)((addr_t)\
Larry Finger2865d42c2010-08-20 10:15:30 -0500255 (pbuf) + 22)) & 0x0f)
256
Przemo Firsztc07f9722012-12-10 23:21:19 +0000257#define SetSeqNum(pbuf, num) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600258 *(__le16 *)((addr_t)(pbuf) + 22) = \
259 cpu_to_le16((le16_to_cpu(*(__le16 *)((addr_t)(pbuf) + 22)) & \
260 0x000f) | (0xfff0 & (num << 4))); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000261})
Larry Finger2865d42c2010-08-20 10:15:30 -0500262
Przemo Firsztc07f9722012-12-10 23:21:19 +0000263#define SetDuration(pbuf, dur) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600264 *(__le16 *)((addr_t)(pbuf) + 2) |= \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000265 cpu_to_le16(0xffff & (dur)); \
266})
Larry Finger2865d42c2010-08-20 10:15:30 -0500267
Przemo Firsztc07f9722012-12-10 23:21:19 +0000268#define SetPriority(pbuf, tid) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600269 *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000270})
Larry Finger2865d42c2010-08-20 10:15:30 -0500271
Larry Fingerdc223652017-02-10 21:30:26 -0600272#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
Larry Finger2865d42c2010-08-20 10:15:30 -0500273
Przemo Firsztc07f9722012-12-10 23:21:19 +0000274#define SetAckpolicy(pbuf, ack) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600275 *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000276})
Larry Finger2865d42c2010-08-20 10:15:30 -0500277
Larry Fingerdc223652017-02-10 21:30:26 -0600278#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
Larry Finger2865d42c2010-08-20 10:15:30 -0500279
Larry Fingerdc223652017-02-10 21:30:26 -0600280#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
Larry Finger2865d42c2010-08-20 10:15:30 -0500281
Larry Fingerdc223652017-02-10 21:30:26 -0600282#define GetAid(pbuf) (cpu_to_le16(*(__le16 *)((addr_t)(pbuf) + 2)) \
Larry Finger2865d42c2010-08-20 10:15:30 -0500283 & 0x3fff)
284
Larry Finger2865d42c2010-08-20 10:15:30 -0500285#define GetAddr1Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 4))
286
287#define GetAddr2Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 10))
288
289#define GetAddr3Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 16))
290
291#define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24))
292
293
294
295static inline int IS_MCAST(unsigned char *da)
296{
297 if ((*da) & 0x01)
298 return true;
299 else
300 return false;
301}
302
303
304static inline unsigned char *get_da(unsigned char *pframe)
305{
306 unsigned char *da;
307 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
308
309 switch (to_fr_ds) {
310 case 0x00: /* ToDs=0, FromDs=0 */
311 da = GetAddr1Ptr(pframe);
312 break;
313 case 0x01: /* ToDs=0, FromDs=1 */
314 da = GetAddr1Ptr(pframe);
315 break;
316 case 0x02: /* ToDs=1, FromDs=0 */
317 da = GetAddr3Ptr(pframe);
318 break;
319 default: /* ToDs=1, FromDs=1 */
320 da = GetAddr3Ptr(pframe);
321 break;
322 }
323 return da;
324}
325
326
327static inline unsigned char *get_sa(unsigned char *pframe)
328{
329 unsigned char *sa;
330 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
331
332 switch (to_fr_ds) {
333 case 0x00: /* ToDs=0, FromDs=0 */
334 sa = GetAddr2Ptr(pframe);
335 break;
336 case 0x01: /* ToDs=0, FromDs=1 */
337 sa = GetAddr3Ptr(pframe);
338 break;
339 case 0x02: /* ToDs=1, FromDs=0 */
340 sa = GetAddr2Ptr(pframe);
341 break;
342 default: /* ToDs=1, FromDs=1 */
343 sa = GetAddr4Ptr(pframe);
344 break;
345 }
346
347 return sa;
348}
349
350static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
351{
352 unsigned char *sa;
353 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
354
355 switch (to_fr_ds) {
356 case 0x00: /* ToDs=0, FromDs=0 */
357 sa = GetAddr3Ptr(pframe);
358 break;
359 case 0x01: /* ToDs=0, FromDs=1 */
360 sa = GetAddr2Ptr(pframe);
361 break;
362 case 0x02: /* ToDs=1, FromDs=0 */
363 sa = GetAddr1Ptr(pframe);
364 break;
365 default: /* ToDs=1, FromDs=1 */
366 sa = NULL;
367 break;
368 }
369 return sa;
370}
371
372
373
374/*-----------------------------------------------------------------------------
Derek Robsonde640ee2017-02-26 15:33:09 +1300375 * Below is for the security related definition
Raphaël Beamontebef611a2016-09-09 11:31:45 -0400376 *-----------------------------------------------------------------------------
377 */
Larry Finger2865d42c2010-08-20 10:15:30 -0500378#define _RESERVED_FRAME_TYPE_ 0
379#define _SKB_FRAME_TYPE_ 2
380#define _PRE_ALLOCMEM_ 1
381#define _PRE_ALLOCHDR_ 3
382#define _PRE_ALLOCLLCHDR_ 4
383#define _PRE_ALLOCICVHDR_ 5
384#define _PRE_ALLOCMICHDR_ 6
385
386#define _SIFSTIME_ ((priv->pmib->BssType.net_work_type & \
387 WIRELESS_11A) ? 16 : 10)
388#define _ACKCTSLNG_ 14 /*14 bytes long, including crclng */
389#define _CRCLNG_ 4
390
391#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
392#define _ASOCRSP_IE_OFFSET_ 6
393#define _REASOCREQ_IE_OFFSET_ 10
394#define _REASOCRSP_IE_OFFSET_ 6
395#define _PROBEREQ_IE_OFFSET_ 0
396#define _PROBERSP_IE_OFFSET_ 12
397#define _AUTH_IE_OFFSET_ 6
398#define _DEAUTH_IE_OFFSET_ 0
399#define _BEACON_IE_OFFSET_ 12
400
401#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
402
403#define _SSID_IE_ 0
404#define _SUPPORTEDRATES_IE_ 1
405#define _DSSET_IE_ 3
Larry Finger2865d42c2010-08-20 10:15:30 -0500406#define _IBSS_PARA_IE_ 6
Larry Finger2865d42c2010-08-20 10:15:30 -0500407#define _ERPINFO_IE_ 42
408#define _EXT_SUPPORTEDRATES_IE_ 50
409
410#define _HT_CAPABILITY_IE_ 45
411#define _HT_EXTRA_INFO_IE_ 61
412#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */
413
414#define _VENDOR_SPECIFIC_IE_ 221
415
416#define _RESERVED47_ 47
417
418
419/* ---------------------------------------------------------------------------
Derek Robsonde640ee2017-02-26 15:33:09 +1300420 * Below is the fixed elements...
Raphaël Beamontebef611a2016-09-09 11:31:45 -0400421 * ---------------------------------------------------------------------------
422 */
Larry Finger2865d42c2010-08-20 10:15:30 -0500423#define _AUTH_ALGM_NUM_ 2
424#define _AUTH_SEQ_NUM_ 2
425#define _BEACON_ITERVAL_ 2
426#define _CAPABILITY_ 2
427#define _CURRENT_APADDR_ 6
428#define _LISTEN_INTERVAL_ 2
429#define _RSON_CODE_ 2
430#define _ASOC_ID_ 2
431#define _STATUS_CODE_ 2
432#define _TIMESTAMP_ 8
433
434#define AUTH_ODD_TO 0
435#define AUTH_EVEN_TO 1
436
437#define WLAN_ETHCONV_ENCAP 1
438#define WLAN_ETHCONV_RFC1042 2
439#define WLAN_ETHCONV_8021h 3
440
441#define cap_ESS BIT(0)
442#define cap_IBSS BIT(1)
443#define cap_CFPollable BIT(2)
444#define cap_CFRequest BIT(3)
445#define cap_Privacy BIT(4)
446#define cap_ShortPremble BIT(5)
447
448/*-----------------------------------------------------------------------------
Derek Robsonde640ee2017-02-26 15:33:09 +1300449 * Below is the definition for 802.11i / 802.1x
Raphaël Beamontebef611a2016-09-09 11:31:45 -0400450 *------------------------------------------------------------------------------
451 */
Larry Finger2865d42c2010-08-20 10:15:30 -0500452#define _IEEE8021X_MGT_ 1 /*WPA */
453#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
454
455/*-----------------------------------------------------------------------------
Derek Robsonde640ee2017-02-26 15:33:09 +1300456 * Below is the definition for WMM
Raphaël Beamontebef611a2016-09-09 11:31:45 -0400457 *------------------------------------------------------------------------------
458 */
Larry Finger2865d42c2010-08-20 10:15:30 -0500459#define _WMM_IE_Length_ 7 /* for WMM STA */
460#define _WMM_Para_Element_Length_ 24
461
462
463/*-----------------------------------------------------------------------------
Derek Robsonde640ee2017-02-26 15:33:09 +1300464 * Below is the definition for 802.11n
Raphaël Beamontebef611a2016-09-09 11:31:45 -0400465 *------------------------------------------------------------------------------
466 */
Larry Finger2865d42c2010-08-20 10:15:30 -0500467
468/* block-ack parameters */
469#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
470#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
471#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
472#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
473#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
474
Przemo Firsztc07f9722012-12-10 23:21:19 +0000475#define SetOrderBit(pbuf) ({ \
Larry Fingerdc223652017-02-10 21:30:26 -0600476 *(__le16 *)(pbuf) |= cpu_to_le16(_ORDER_); \
Przemo Firsztc07f9722012-12-10 23:21:19 +0000477})
Larry Finger2865d42c2010-08-20 10:15:30 -0500478
Larry Fingerdc223652017-02-10 21:30:26 -0600479#define GetOrderBit(pbuf) (((*(__le16 *)(pbuf)) & \
Larry Finger2865d42c2010-08-20 10:15:30 -0500480 le16_to_cpu(_ORDER_)) != 0)
481
482
483/**
484 * struct ieee80211_bar - HT Block Ack Request
485 *
486 * This structure refers to "HT BlockAckReq" as
487 * described in 802.11n draft section 7.2.1.7.1
488 */
489struct ieee80211_bar {
Larry Fingerdc223652017-02-10 21:30:26 -0600490 __le16 frame_control;
491 __le16 duration;
Larry Finger2865d42c2010-08-20 10:15:30 -0500492 unsigned char ra[6];
493 unsigned char ta[6];
Larry Fingerdc223652017-02-10 21:30:26 -0600494 __le16 control;
495 __le16 start_seq_num;
Michael Fiedler40878362011-06-20 16:34:27 +0200496} __packed;
Larry Finger2865d42c2010-08-20 10:15:30 -0500497
498/* 802.11 BAR control masks */
499#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
500#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
501
502
Derek Robsonde640ee2017-02-26 15:33:09 +1300503/*
Larry Finger2865d42c2010-08-20 10:15:30 -0500504 * struct ieee80211_ht_cap - HT capabilities
505 *
506 * This structure refers to "HT capabilities element" as
507 * described in 802.11n draft section 7.3.2.52
508 */
509
510struct ieee80211_ht_cap {
Larry Fingerdc223652017-02-10 21:30:26 -0600511 __le16 cap_info;
Larry Finger2865d42c2010-08-20 10:15:30 -0500512 unsigned char ampdu_params_info;
513 unsigned char supp_mcs_set[16];
Larry Fingerdc223652017-02-10 21:30:26 -0600514 __le16 extended_ht_cap_info;
515 __le32 tx_BF_cap_info;
Larry Finger2865d42c2010-08-20 10:15:30 -0500516 unsigned char antenna_selection_info;
Michael Fiedler40878362011-06-20 16:34:27 +0200517} __packed;
Larry Finger2865d42c2010-08-20 10:15:30 -0500518
519/**
520 * struct ieee80211_ht_cap - HT additional information
521 *
522 * This structure refers to "HT information element" as
523 * described in 802.11n draft section 7.3.2.53
524 */
525struct ieee80211_ht_addt_info {
526 unsigned char control_chan;
527 unsigned char ht_param;
Larry Fingerdc223652017-02-10 21:30:26 -0600528 __le16 operation_mode;
529 __le16 stbc_param;
Larry Finger2865d42c2010-08-20 10:15:30 -0500530 unsigned char basic_set[16];
Michael Fiedler40878362011-06-20 16:34:27 +0200531} __packed;
Larry Finger2865d42c2010-08-20 10:15:30 -0500532
533/* 802.11n HT capabilities masks */
534#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
535#define IEEE80211_HT_CAP_SM_PS 0x000C
536#define IEEE80211_HT_CAP_GRN_FLD 0x0010
537#define IEEE80211_HT_CAP_SGI_20 0x0020
538#define IEEE80211_HT_CAP_SGI_40 0x0040
539#define IEEE80211_HT_CAP_TX_STBC 0x0080
540#define IEEE80211_HT_CAP_DELAY_BA 0x0400
541#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
542#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
543/* 802.11n HT capability AMPDU settings */
544#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
545#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
546/* 802.11n HT capability MSC set */
547#define IEEE80211_SUPP_MCS_SET_UEQM 4
548#define IEEE80211_HT_CAP_MAX_STREAMS 4
549#define IEEE80211_SUPP_MCS_SET_LEN 10
550/* maximum streams the spec allows */
551#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
552#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
553#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
554#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
555/* 802.11n HT IE masks */
556#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
557#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
558#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
559#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
560#define IEEE80211_HT_IE_CHA_WIDTH 0x04
561#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
562#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
563#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
564
565/* block-ack parameters */
566#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
567#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
568#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
569#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
570#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
571
572/*
573 * A-PMDU buffer sizes
574 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
575 */
576#define IEEE80211_MIN_AMPDU_BUF 0x8
Larry Finger2865d42c2010-08-20 10:15:30 -0500577
578
579/* Spatial Multiplexing Power Save Modes */
580#define WLAN_HT_CAP_SM_PS_STATIC 0
581#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
582#define WLAN_HT_CAP_SM_PS_INVALID 2
583#define WLAN_HT_CAP_SM_PS_DISABLED 3
584
585#endif /* _WIFI_H_ */
586