staging: rtl8712: remove enum WIFI_FRAME_SUBTYPE
[linux-2.6-microblaze.git] / drivers / staging / rtl8712 / wifi.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  *
6  * Modifications for inclusion into the Linux staging tree are
7  * Copyright(c) 2010 Larry Finger. All rights reserved.
8  *
9  * Contact information:
10  * WLAN FAE <wlanfae@realtek.com>
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  ******************************************************************************/
14 #ifndef _WIFI_H_
15 #define _WIFI_H_
16
17 #include <linux/compiler.h>
18 #include <linux/ieee80211.h>
19
20 #define WLAN_HDR_A3_LEN         24
21 #define WLAN_HDR_A3_QOS_LEN     26
22
23 #define P80211CAPTURE_VERSION   0x80211001
24
25 enum WIFI_FRAME_TYPE {
26         WIFI_MGT_TYPE  =        (0),
27         WIFI_CTRL_TYPE =        (BIT(2)),
28         WIFI_DATA_TYPE =        (BIT(3)),
29         WIFI_QOS_DATA_TYPE      = (BIT(7) | BIT(3)),    /*!< QoS Data */
30 };
31
32 enum WIFI_REG_DOMAIN {
33         DOMAIN_FCC      = 1,
34         DOMAIN_IC       = 2,
35         DOMAIN_ETSI     = 3,
36         DOMAIN_SPAIN    = 4,
37         DOMAIN_FRANCE   = 5,
38         DOMAIN_MKK      = 6,
39         DOMAIN_ISRAEL   = 7,
40         DOMAIN_MKK1     = 8,
41         DOMAIN_MKK2     = 9,
42         DOMAIN_MKK3     = 10,
43         DOMAIN_MAX
44 };
45
46 #define SetToDs(pbuf) ({ \
47         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS); \
48 })
49
50 #define GetToDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0)
51
52 #define ClearToDs(pbuf) ({ \
53         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_TODS)); \
54 })
55
56 #define SetFrDs(pbuf) ({ \
57         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS); \
58 })
59
60 #define GetFrDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0)
61
62 #define ClearFrDs(pbuf) ({ \
63         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_FROMDS)); \
64 })
65
66 static inline unsigned char get_tofr_ds(unsigned char *pframe)
67 {
68         return ((GetToDs(pframe) << 1) | GetFrDs(pframe));
69 }
70
71 #define SetMFrag(pbuf) ({ \
72         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); \
73 })
74
75 #define GetMFrag(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0)
76
77 #define ClearMFrag(pbuf) ({ \
78         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)); \
79 })
80
81 #define SetRetry(pbuf) ({ \
82         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY); \
83 })
84
85 #define GetRetry(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0)
86
87 #define ClearRetry(pbuf) ({ \
88         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_RETRY)); \
89 })
90
91 #define SetPwrMgt(pbuf) ({ \
92         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM); \
93 })
94
95 #define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & \
96                         cpu_to_le16(IEEE80211_FCTL_PM)) != 0)
97
98 #define ClearPwrMgt(pbuf) ({ \
99         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_PM)); \
100 })
101
102 #define SetMData(pbuf) ({ \
103         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); \
104 })
105
106 #define GetMData(pbuf)  (((*(__le16 *)(pbuf)) & \
107                         cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0)
108
109 #define ClearMData(pbuf) ({ \
110         *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREDATA)); \
111 })
112
113 #define SetPrivacy(pbuf) ({ \
114         *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); \
115 })
116
117 #define GetPrivacy(pbuf)        (((*(__le16 *)(pbuf)) & \
118                                 cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0)
119
120 #define GetOrder(pbuf)  (((*(__le16 *)(pbuf)) & \
121                         cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0)
122
123 #define GetFrameType(pbuf)      (le16_to_cpu(*(__le16 *)(pbuf)) & \
124                                 (BIT(3) | BIT(2)))
125
126 #define SetFrameType(pbuf, type)        \
127         do {    \
128                 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(3) | \
129                 BIT(2))); \
130                 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
131         } while (0)
132
133 #define GetFrameSubType(pbuf)   (le16_to_cpu(*(__le16 *)(pbuf)) & \
134                                 (BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
135                                 BIT(2)))
136
137 #define SetFrameSubType(pbuf, type) \
138         do {    \
139                 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
140                 BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
141                 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
142         } while (0)
143
144 #define GetSequence(pbuf)       (le16_to_cpu(*(__le16 *)\
145                                 ((addr_t)(pbuf) + 22)) >> 4)
146
147 #define GetFragNum(pbuf)        (le16_to_cpu(*(__le16 *)((addr_t)\
148                                 (pbuf) + 22)) & 0x0f)
149
150 #define SetSeqNum(pbuf, num) ({ \
151         *(__le16 *)((addr_t)(pbuf) + 22) = \
152         cpu_to_le16((le16_to_cpu(*(__le16 *)((addr_t)(pbuf) + 22)) & \
153         0x000f) | (0xfff0 & (num << 4))); \
154 })
155
156 #define SetPriority(pbuf, tid) ({ \
157         *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf); \
158 })
159
160 #define GetPriority(pbuf)       ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
161
162 #define SetAckpolicy(pbuf, ack) ({ \
163         *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
164 })
165
166 #define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
167
168 #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
169
170 #define GetAddr1Ptr(pbuf)       ((unsigned char *)((addr_t)(pbuf) + 4))
171
172 #define GetAddr2Ptr(pbuf)       ((unsigned char *)((addr_t)(pbuf) + 10))
173
174 #define GetAddr3Ptr(pbuf)       ((unsigned char *)((addr_t)(pbuf) + 16))
175
176 #define GetAddr4Ptr(pbuf)       ((unsigned char *)((addr_t)(pbuf) + 24))
177
178 static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
179 {
180         unsigned char   *sa;
181         unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
182
183         switch (to_fr_ds) {
184         case 0x00:      /* ToDs=0, FromDs=0 */
185                 sa = GetAddr3Ptr(pframe);
186                 break;
187         case 0x01:      /* ToDs=0, FromDs=1 */
188                 sa = GetAddr2Ptr(pframe);
189                 break;
190         case 0x02:      /* ToDs=1, FromDs=0 */
191                 sa = GetAddr1Ptr(pframe);
192                 break;
193         default:        /* ToDs=1, FromDs=1 */
194                 sa = NULL;
195                 break;
196         }
197         return sa;
198 }
199
200 /*-----------------------------------------------------------------------------
201  *              Below is for the security related definition
202  *-----------------------------------------------------------------------------
203  */
204 #define _ASOCREQ_IE_OFFSET_     4       /* excluding wlan_hdr */
205 #define _ASOCRSP_IE_OFFSET_     6
206 #define _REASOCREQ_IE_OFFSET_   10
207 #define _REASOCRSP_IE_OFFSET_   6
208 #define _PROBEREQ_IE_OFFSET_    0
209 #define _PROBERSP_IE_OFFSET_    12
210 #define _AUTH_IE_OFFSET_        6
211 #define _DEAUTH_IE_OFFSET_      0
212 #define _BEACON_IE_OFFSET_      12
213
214 #define _FIXED_IE_LENGTH_       _BEACON_IE_OFFSET_
215
216 /* ---------------------------------------------------------------------------
217  *                      Below is the fixed elements...
218  * ---------------------------------------------------------------------------
219  */
220 #define _AUTH_ALGM_NUM_                 2
221 #define _AUTH_SEQ_NUM_                  2
222 #define _BEACON_ITERVAL_                2
223 #define _CAPABILITY_                    2
224 #define _CURRENT_APADDR_                6
225 #define _LISTEN_INTERVAL_               2
226 #define _RSON_CODE_                             2
227 #define _ASOC_ID_                               2
228 #define _STATUS_CODE_                   2
229 #define _TIMESTAMP_                             8
230
231 #define AUTH_ODD_TO                             0
232 #define AUTH_EVEN_TO                    1
233
234 /*-----------------------------------------------------------------------------
235  *                      Below is the definition for 802.11i / 802.1x
236  *------------------------------------------------------------------------------
237  */
238 #define _IEEE8021X_MGT_                 1       /*WPA */
239 #define _IEEE8021X_PSK_                 2       /* WPA with pre-shared key */
240
241 /*-----------------------------------------------------------------------------
242  *                      Below is the definition for WMM
243  *------------------------------------------------------------------------------
244  */
245 #define _WMM_IE_Length_                         7  /* for WMM STA */
246
247 #endif /* _WIFI_H_ */
248