Merge branch 'next' into for-linus
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wlan-ng / p80211types.h
1 /* p80211types.h
2 *
3 * Macros, constants, types, and funcs for p80211 data types
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 * This file declares some of the constants and types used in various
48 * parts of the linux-wlan system.
49 *
50 * Notes:
51 *   - Constant values are always in HOST byte order.
52 *
53 * All functions and statics declared here are implemented in p80211types.c
54 *   --------------------------------------------------------------------
55 */
56
57 #ifndef _P80211TYPES_H
58 #define _P80211TYPES_H
59
60 /*================================================================*/
61 /* Project Includes */
62 /*================================================================*/
63
64 /*----------------------------------------------------------------*/
65 /* The following constants are indexes into the Mib Category List */
66 /* and the Message Category List */
67
68 /* Mib Category List */
69 #define P80211_MIB_CAT_DOT11SMT         1
70 #define P80211_MIB_CAT_DOT11MAC         2
71 #define P80211_MIB_CAT_DOT11PHY         3
72
73 #define P80211SEC_DOT11SMT              P80211_MIB_CAT_DOT11SMT
74 #define P80211SEC_DOT11MAC              P80211_MIB_CAT_DOT11MAC
75 #define P80211SEC_DOT11PHY              P80211_MIB_CAT_DOT11PHY
76
77 /* Message Category List */
78 #define P80211_MSG_CAT_DOT11REQ         1
79 #define P80211_MSG_CAT_DOT11IND         2
80
81 /*----------------------------------------------------------------*/
82 /* p80211 enumeration constants.  The value to text mappings for */
83 /*  these is in p80211types.c.  These defines were generated */
84 /*  from the mappings. */
85
86 /* error codes for lookups */
87
88 #define P80211ENUM_truth_false                  0
89 #define P80211ENUM_truth_true                   1
90 #define P80211ENUM_ifstate_disable              0
91 #define P80211ENUM_ifstate_fwload               1
92 #define P80211ENUM_ifstate_enable               2
93 #define P80211ENUM_bsstype_infrastructure       1
94 #define P80211ENUM_bsstype_independent          2
95 #define P80211ENUM_bsstype_any                  3
96 #define P80211ENUM_authalg_opensystem           1
97 #define P80211ENUM_authalg_sharedkey            2
98 #define P80211ENUM_scantype_active              1
99 #define P80211ENUM_resultcode_success           1
100 #define P80211ENUM_resultcode_invalid_parameters        2
101 #define P80211ENUM_resultcode_not_supported     3
102 #define P80211ENUM_resultcode_refused           6
103 #define P80211ENUM_resultcode_cant_set_readonly_mib     10
104 #define P80211ENUM_resultcode_implementation_failure    11
105 #define P80211ENUM_resultcode_cant_get_writeonly_mib    12
106 #define P80211ENUM_status_successful            0
107 #define P80211ENUM_status_unspec_failure        1
108 #define P80211ENUM_status_ap_full               17
109 #define P80211ENUM_msgitem_status_data_ok               0
110 #define P80211ENUM_msgitem_status_no_value              1
111
112 /*----------------------------------------------------------------*/
113 /* p80211 max length constants for the different pascal strings. */
114
115 #define MAXLEN_PSTR6            (6)     /* pascal array of 6 bytes */
116 #define MAXLEN_PSTR14           (14)    /* pascal array of 14 bytes */
117 #define MAXLEN_PSTR32           (32)    /* pascal array of 32 bytes */
118 #define MAXLEN_PSTR255          (255)   /* pascal array of 255 bytes */
119 #define MAXLEN_MIBATTRIBUTE     (392)   /* maximum mibattribute */
120                                         /* where the size of the DATA itself */
121                                         /* is a DID-LEN-DATA triple */
122                                         /* with a max size of 4+4+384 */
123
124 /*----------------------------------------------------------------*/
125 /* The following macro creates a name for an enum */
126
127 #define MKENUMNAME(name) p80211enum_ ## name
128
129 /*----------------------------------------------------------------
130 * The following constants and macros are used to construct and
131 * deconstruct the Data ID codes.  The coding is as follows:
132 *
133 *     ...rwtnnnnnnnniiiiiiggggggssssss      s - Section
134 *                                           g - Group
135 *                                           i - Item
136 *                                           n - Index
137 *                                           t - Table flag
138 *                                           w - Write flag
139 *                                           r - Read flag
140 *                                           . - Unused
141 */
142
143 #define P80211DID_LSB_SECTION           (0)
144 #define P80211DID_LSB_GROUP             (6)
145 #define P80211DID_LSB_ITEM              (12)
146 #define P80211DID_LSB_INDEX             (18)
147 #define P80211DID_LSB_ISTABLE           (26)
148 #define P80211DID_LSB_ACCESS            (27)
149
150 #define P80211DID_MASK_SECTION          (0x0000003fUL)
151 #define P80211DID_MASK_GROUP            (0x0000003fUL)
152 #define P80211DID_MASK_ITEM             (0x0000003fUL)
153 #define P80211DID_MASK_INDEX            (0x000000ffUL)
154 #define P80211DID_MASK_ISTABLE          (0x00000001UL)
155 #define P80211DID_MASK_ACCESS           (0x00000003UL)
156
157 #define P80211DID_MK(a, m, l)   ((((u32)(a)) & (m)) << (l))
158
159 #define P80211DID_MKSECTION(a)  P80211DID_MK(a, \
160                                         P80211DID_MASK_SECTION, \
161                                         P80211DID_LSB_SECTION)
162 #define P80211DID_MKGROUP(a)    P80211DID_MK(a, \
163                                         P80211DID_MASK_GROUP, \
164                                         P80211DID_LSB_GROUP)
165 #define P80211DID_MKITEM(a)     P80211DID_MK(a, \
166                                         P80211DID_MASK_ITEM, \
167                                         P80211DID_LSB_ITEM)
168 #define P80211DID_MKINDEX(a)    P80211DID_MK(a, \
169                                         P80211DID_MASK_INDEX, \
170                                         P80211DID_LSB_INDEX)
171 #define P80211DID_MKISTABLE(a)  P80211DID_MK(a, \
172                                         P80211DID_MASK_ISTABLE, \
173                                         P80211DID_LSB_ISTABLE)
174
175 #define P80211DID_MKID(s,g,i,n,t,a)     (P80211DID_MKSECTION(s) | \
176                                                 P80211DID_MKGROUP(g) | \
177                                                 P80211DID_MKITEM(i) | \
178                                                 P80211DID_MKINDEX(n) | \
179                                                 P80211DID_MKISTABLE(t) | \
180                                                 (a))
181
182 #define P80211DID_GET(a, m, l)  ((((u32)(a)) >> (l)) & (m))
183
184 #define P80211DID_SECTION(a)    P80211DID_GET(a, \
185                                         P80211DID_MASK_SECTION, \
186                                         P80211DID_LSB_SECTION)
187 #define P80211DID_GROUP(a)      P80211DID_GET(a, \
188                                         P80211DID_MASK_GROUP, \
189                                         P80211DID_LSB_GROUP)
190 #define P80211DID_ITEM(a)       P80211DID_GET(a, \
191                                         P80211DID_MASK_ITEM, \
192                                         P80211DID_LSB_ITEM)
193 #define P80211DID_INDEX(a)      P80211DID_GET(a, \
194                                         P80211DID_MASK_INDEX, \
195                                         P80211DID_LSB_INDEX)
196 #define P80211DID_ISTABLE(a)    P80211DID_GET(a, \
197                                         P80211DID_MASK_ISTABLE, \
198                                         P80211DID_LSB_ISTABLE)
199 #define P80211DID_ACCESS(a)     P80211DID_GET(a, \
200                                         P80211DID_MASK_ACCESS, \
201                                         P80211DID_LSB_ACCESS)
202
203 /*----------------------------------------------------------------*/
204 /* The following structure types are used for the represenation */
205 /*  of ENUMint type metadata. */
206
207 typedef struct p80211enumpair {
208         u32 val;
209         char *name;
210 } p80211enumpair_t;
211
212 typedef struct p80211enum {
213         int nitems;
214         p80211enumpair_t *list;
215 } p80211enum_t;
216
217 /*----------------------------------------------------------------*/
218 /* The following structure types are used to store data items in */
219 /*  messages. */
220
221 /* Template pascal string */
222 typedef struct p80211pstr {
223         u8 len;
224 } __attribute__ ((packed)) p80211pstr_t;
225
226 typedef struct p80211pstrd {
227         u8 len;
228         u8 data[0];
229 } __attribute__ ((packed)) p80211pstrd_t;
230
231 /* Maximum pascal string */
232 typedef struct p80211pstr255 {
233         u8 len;
234         u8 data[MAXLEN_PSTR255];
235 } __attribute__ ((packed)) p80211pstr255_t;
236
237 /* pascal string for macaddress and bssid */
238 typedef struct p80211pstr6 {
239         u8 len;
240         u8 data[MAXLEN_PSTR6];
241 } __attribute__ ((packed)) p80211pstr6_t;
242
243 /* pascal string for channel list */
244 typedef struct p80211pstr14 {
245         u8 len;
246         u8 data[MAXLEN_PSTR14];
247 } __attribute__ ((packed)) p80211pstr14_t;
248
249 /* pascal string for ssid */
250 typedef struct p80211pstr32 {
251         u8 len;
252         u8 data[MAXLEN_PSTR32];
253 } __attribute__ ((packed)) p80211pstr32_t;
254
255 /* MAC address array */
256 typedef struct p80211macarray {
257         u32 cnt;
258         u8 data[1][MAXLEN_PSTR6];
259 } __attribute__ ((packed)) p80211macarray_t;
260
261 /* prototype template */
262 typedef struct p80211item {
263         u32 did;
264         u16 status;
265         u16 len;
266 } __attribute__ ((packed)) p80211item_t;
267
268 /* prototype template w/ data item */
269 typedef struct p80211itemd {
270         u32 did;
271         u16 status;
272         u16 len;
273         u8 data[0];
274 } __attribute__ ((packed)) p80211itemd_t;
275
276 /* message data item for int, BOUNDEDINT, ENUMINT */
277 typedef struct p80211item_uint32 {
278         u32 did;
279         u16 status;
280         u16 len;
281         u32 data;
282 } __attribute__ ((packed)) p80211item_uint32_t;
283
284 /* message data item for OCTETSTR, DISPLAYSTR */
285 typedef struct p80211item_pstr6 {
286         u32 did;
287         u16 status;
288         u16 len;
289         p80211pstr6_t data;
290 } __attribute__ ((packed)) p80211item_pstr6_t;
291
292 /* message data item for OCTETSTR, DISPLAYSTR */
293 typedef struct p80211item_pstr14 {
294         u32 did;
295         u16 status;
296         u16 len;
297         p80211pstr14_t data;
298 } __attribute__ ((packed)) p80211item_pstr14_t;
299
300 /* message data item for OCTETSTR, DISPLAYSTR */
301 typedef struct p80211item_pstr32 {
302         u32 did;
303         u16 status;
304         u16 len;
305         p80211pstr32_t data;
306 } __attribute__ ((packed)) p80211item_pstr32_t;
307
308 /* message data item for OCTETSTR, DISPLAYSTR */
309 typedef struct p80211item_pstr255 {
310         u32 did;
311         u16 status;
312         u16 len;
313         p80211pstr255_t data;
314 } __attribute__ ((packed)) p80211item_pstr255_t;
315
316 /* message data item for UNK 392, namely mib items */
317 typedef struct p80211item_unk392 {
318         u32 did;
319         u16 status;
320         u16 len;
321         u8 data[MAXLEN_MIBATTRIBUTE];
322 } __attribute__ ((packed)) p80211item_unk392_t;
323
324 /* message data item for UNK 1025, namely p2 pdas */
325 typedef struct p80211item_unk1024 {
326         u32 did;
327         u16 status;
328         u16 len;
329         u8 data[1024];
330 } __attribute__ ((packed)) p80211item_unk1024_t;
331
332 /* message data item for UNK 4096, namely p2 download chunks */
333 typedef struct p80211item_unk4096 {
334         u32 did;
335         u16 status;
336         u16 len;
337         u8 data[4096];
338 } __attribute__ ((packed)) p80211item_unk4096_t;
339
340 struct catlistitem;
341
342 /*----------------------------------------------------------------*/
343 /* The following structure type is used to represent all of the */
344 /*  metadata items.  Some components may choose to use more, */
345 /*  less or different metadata items. */
346
347 typedef void (*p80211_totext_t) (struct catlistitem *, u32 did, u8 * itembuf,
348                                  char *textbuf);
349 typedef void (*p80211_fromtext_t) (struct catlistitem *, u32 did, u8 * itembuf,
350                                    char *textbuf);
351 typedef u32(*p80211_valid_t) (struct catlistitem *, u32 did, u8 * itembuf);
352
353 /*----------------------------------------------------------------*/
354 /* Enumeration Lists */
355 /*  The following are the external declarations */
356 /*  for all enumerations  */
357
358 extern p80211enum_t MKENUMNAME(truth);
359 extern p80211enum_t MKENUMNAME(ifstate);
360 extern p80211enum_t MKENUMNAME(powermgmt);
361 extern p80211enum_t MKENUMNAME(bsstype);
362 extern p80211enum_t MKENUMNAME(authalg);
363 extern p80211enum_t MKENUMNAME(phytype);
364 extern p80211enum_t MKENUMNAME(temptype);
365 extern p80211enum_t MKENUMNAME(regdomain);
366 extern p80211enum_t MKENUMNAME(ccamode);
367 extern p80211enum_t MKENUMNAME(diversity);
368 extern p80211enum_t MKENUMNAME(scantype);
369 extern p80211enum_t MKENUMNAME(resultcode);
370 extern p80211enum_t MKENUMNAME(reason);
371 extern p80211enum_t MKENUMNAME(status);
372 extern p80211enum_t MKENUMNAME(msgcode);
373 extern p80211enum_t MKENUMNAME(msgitem_status);
374
375 extern p80211enum_t MKENUMNAME(lnxroam_reason);
376
377 extern p80211enum_t MKENUMNAME(p2preamble);
378
379 #endif /* _P80211TYPES_H */