91c550e94d87e9441da9f643d98c0b6138f678cc
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / winbond / mac_structures.h
1 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // MAC_Structures.h
3 //
4 // This file contains the definitions and data structures used by SW-MAC.
5 //
6 // Revision Histoy
7 //=================
8 // 0.1      2002        UN00
9 // 0.2      20021004    PD43 CCLiu6
10 //          20021018    PD43 CCLiu6
11 //                      Add enum_TxRate type
12 //                      Modify enum_STAState type
13 // 0.3      20021023    PE23 CYLiu update MAC session struct
14 //          20021108
15 //          20021122    PD43 Austin
16 //                      Deleted some unused.
17 //          20021129    PD43 Austin
18 //                      20030617        increase the 802.11g definition
19 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
20
21 #ifndef _MAC_Structures_H_
22 #define _MAC_Structures_H_
23
24 #include <linux/skbuff.h>
25
26 /*=========================================================
27 // Some miscellaneous definitions
28 //-----*/
29 #define MAX_CHANNELS                        30
30 #define MAC_ADDR_LENGTH                     6
31 #define MAX_WEP_KEY_SIZE                    16  /* 128 bits */
32 #define MAX_802_11_FRAGMENT_NUMBER              10 /* By spec */
33
34 /* ========================================================
35 // 802.11 Frame define
36 //----- */
37 #define MASK_PROTOCOL_VERSION_TYPE      0x0F
38 #define MASK_FRAGMENT_NUMBER            0x000F
39 #define SEQUENCE_NUMBER_SHIFT           4
40 #define DIFFER_11_TO_3                          18
41 #define DOT_11_MAC_HEADER_SIZE          24
42 #define DOT_11_SNAP_SIZE                        6
43 #define DOT_11_DURATION_OFFSET          2
44 /* Sequence control offset */
45 #define DOT_11_SEQUENCE_OFFSET          22
46 /* The start offset of 802.11 Frame// */
47 #define DOT_11_TYPE_OFFSET                      30
48 #define DOT_11_DATA_OFFSET          24
49 #define DOT_11_DA_OFFSET                        4
50 #define DOT_3_TYPE_ARP                          0x80F3
51 #define DOT_3_TYPE_IPX                          0x8137
52 #define DOT_3_TYPE_OFFSET                       12
53
54
55 #define ETHERNET_HEADER_SIZE                    14
56 #define MAX_ETHERNET_PACKET_SIZE                1514
57
58
59 /* -----  management : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
60 #define MAC_SUBTYPE_MNGMNT_ASSOC_REQUEST    0x00
61 #define MAC_SUBTYPE_MNGMNT_ASSOC_RESPONSE   0x10
62 #define MAC_SUBTYPE_MNGMNT_REASSOC_REQUEST  0x20
63 #define MAC_SUBTYPE_MNGMNT_REASSOC_RESPONSE 0x30
64 #define MAC_SUBTYPE_MNGMNT_PROBE_REQUEST    0x40
65 #define MAC_SUBTYPE_MNGMNT_PROBE_RESPONSE   0x50
66 #define MAC_SUBTYPE_MNGMNT_BEACON           0x80
67 #define MAC_SUBTYPE_MNGMNT_ATIM             0x90
68 #define MAC_SUBTYPE_MNGMNT_DISASSOCIATION   0xA0
69 #define MAC_SUBTYPE_MNGMNT_AUTHENTICATION   0xB0
70 #define MAC_SUBTYPE_MNGMNT_DEAUTHENTICATION 0xC0
71
72 /* -----  control : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
73 #define MAC_SUBTYPE_CONTROL_PSPOLL          0xA4
74 #define MAC_SUBTYPE_CONTROL_RTS             0xB4
75 #define MAC_SUBTYPE_CONTROL_CTS             0xC4
76 #define MAC_SUBTYPE_CONTROL_ACK             0xD4
77 #define MAC_SUBTYPE_CONTROL_CFEND           0xE4
78 #define MAC_SUBTYPE_CONTROL_CFEND_CFACK     0xF4
79
80 /* -----  data : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
81 #define MAC_SUBTYPE_DATA                    0x08
82 #define MAC_SUBTYPE_DATA_CFACK              0x18
83 #define MAC_SUBTYPE_DATA_CFPOLL             0x28
84 #define MAC_SUBTYPE_DATA_CFACK_CFPOLL       0x38
85 #define MAC_SUBTYPE_DATA_NULL               0x48
86 #define MAC_SUBTYPE_DATA_CFACK_NULL         0x58
87 #define MAC_SUBTYPE_DATA_CFPOLL_NULL        0x68
88 #define MAC_SUBTYPE_DATA_CFACK_CFPOLL_NULL  0x78
89
90 /* -----  Frame Type of Bits (2, 3) */
91 #define MAC_TYPE_MANAGEMENT                 0x00
92 #define MAC_TYPE_CONTROL                    0x04
93 #define MAC_TYPE_DATA                       0x08
94
95 /* ----- definitions for Management Frame Element ID (1 BYTE) */
96 #define ELEMENT_ID_SSID                     0
97 #define ELEMENT_ID_SUPPORTED_RATES          1
98 #define ELEMENT_ID_FH_PARAMETER_SET         2
99 #define ELEMENT_ID_DS_PARAMETER_SET         3
100 #define ELEMENT_ID_CF_PARAMETER_SET         4
101 #define ELEMENT_ID_TIM                      5
102 #define ELEMENT_ID_IBSS_PARAMETER_SET       6
103 /* 7~15 reserverd */
104 #define ELEMENT_ID_CHALLENGE_TEXT           16
105 /* 17~31 reserved for challenge text extension */
106 /* 32~255 reserved */
107 /*--  11G  -- */
108 #define ELEMENT_ID_ERP_INFORMATION                      42
109 #define ELEMENT_ID_EXTENDED_SUPPORTED_RATES 50
110
111 /* --  WPA  -- */
112
113 #define ELEMENT_ID_RSN_WPA                                      221
114
115 #define WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT    ((u16) 6)
116 #define WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT  ((u16) 2)
117
118 /* ===================================================================
119 *  Reason Code (Table 18): indicate the reason of DisAssoc, DeAuthen
120 *  length of ReasonCode is 2 Octs.
121 * =================================================================== */
122 #define REASON_REASERED             0
123 #define REASON_UNSPECIDIED          1
124 #define REASON_PREAUTH_INVALID      2
125 #define DEAUTH_REASON_LEFT_BSS      3
126 #define DISASS_REASON_AP_INACTIVE   4
127 #define DISASS_REASON_AP_BUSY       5
128 #define REASON_CLASS2_FRAME_FROM_NONAUTH_STA    6
129 #define REASON_CLASS3_FRAME_FROM_NONASSO_STA    7
130 #define DISASS_REASON_LEFT_BSS      8
131 #define REASON_NOT_AUTH_YET         9
132 /* 802.11i define */
133 #define REASON_INVALID_IE                                               13
134 #define REASON_MIC_ERROR                                                14
135 #define REASON_4WAY_HANDSHAKE_TIMEOUT                   15
136 #define REASON_GROUPKEY_UPDATE_TIMEOUT                  16
137 #define REASON_IE_DIFF_4WAY_ASSOC                               17
138 #define REASON_INVALID_MULTICAST_CIPHER                 18
139 #define REASON_INVALID_UNICAST_CIPHER                   19
140 #define REASON_INVALID_AKMP                                             20
141 #define REASON_UNSUPPORTED_RSNIE_VERSION                21
142 #define REASON_INVALID_RSNIE_CAPABILITY                 22
143 #define REASON_802_1X_AUTH_FAIL                                 23
144 #define REASON_CIPHER_REJECT_PER_SEC_POLICY             14
145
146 /*
147 //===========================================================
148 // enum_MMPDUResultCode --
149 //   Status code (2 Octs) in the MMPDU's frame body. Table.19
150 //
151 //===========================================================
152 enum enum_MMPDUResultCode
153 {
154 //    SUCCESS   = 0,      // Redefined
155     UNSPECIFIED_FAILURE                         = 1,
156
157     // 2 - 9 Reserved
158
159     NOT_SUPPROT_CAPABILITIES                    = 10,
160
161     //REASSOCIATION_DENIED
162     //
163     REASSOC_DENIED_UNABLE_CFM_ASSOC_EXIST       = 11,
164
165     //ASSOCIATION_DENIED_NOT_IN_STANDARD
166     //
167     ASSOC_DENIED_REASON_NOT_IN_STANDARD         = 12,
168     PEER_NOT_SUPPORT_AUTH_ALGORITHM             = 13,
169     AUTH_SEQNUM_OUT_OF_EXPECT                   = 14,
170     AUTH_REJECT_REASON_CHALLENGE_FAIL           = 15,
171     AUTH_REJECT_REASON_WAIT_TIMEOUT             = 16,
172     ASSOC_DENIED_REASON_AP_BUSY                 = 17,
173     ASSOC_DENIED_REASON_NOT_SUPPORT_BASIC_RATE  = 18
174 } WB_MMPDURESULTCODE, *PWB_MMPDURESULTCODE;
175 */
176
177 #define RATE_BITMAP_1M                          1
178 #define RATE_BITMAP_2M                          2
179 #define RATE_BITMAP_5dot5M                      5
180 #define RATE_BITMAP_6M                          6
181 #define RATE_BITMAP_9M                          9
182 #define RATE_BITMAP_11M                         11
183 #define RATE_BITMAP_12M                         12
184 #define RATE_BITMAP_18M                         18
185 #define RATE_BITMAP_22M                         22
186 #define RATE_BITMAP_24M                         24
187 #define RATE_BITMAP_33M                         17
188 #define RATE_BITMAP_36M                         19
189 #define RATE_BITMAP_48M                         25
190 #define RATE_BITMAP_54M                         28
191
192 #define RATE_AUTO                                       0
193 #define RATE_1M                                         2
194 #define RATE_2M                                         4
195 #define RATE_5dot5M                                     11
196 #define RATE_6M                                         12
197 #define RATE_9M                                         18
198 #define RATE_11M                                        22
199 #define RATE_12M                                        24
200 #define RATE_18M                                        36
201 #define RATE_22M                                        44
202 #define RATE_24M                                        48
203 #define RATE_33M                                        66
204 #define RATE_36M                                        72
205 #define RATE_48M                                        96
206 #define RATE_54M                                        108
207 #define RATE_MAX                                        255
208
209 /* CAPABILITY */
210 #define CAPABILITY_ESS_BIT                              0x0001
211 #define CAPABILITY_IBSS_BIT                             0x0002
212 #define CAPABILITY_CF_POLL_BIT                  0x0004
213 #define CAPABILITY_CF_POLL_REQ_BIT              0x0008
214 #define CAPABILITY_PRIVACY_BIT                  0x0010
215 #define CAPABILITY_SHORT_PREAMBLE_BIT   0x0020
216 #define CAPABILITY_PBCC_BIT                             0x0040
217 #define CAPABILITY_CHAN_AGILITY_BIT             0x0080
218 #define CAPABILITY_SHORT_SLOT_TIME_BIT  0x0400
219 #define CAPABILITY_DSSS_OFDM_BIT                0x2000
220
221
222 struct Capability_Information_Element {
223   union {
224         u16 __attribute__ ((packed)) wValue;
225     #ifdef _BIG_ENDIAN_  /* 20060926 add by anson's endian */
226     struct _Capability {
227         /* --  11G  -- */
228         u8      Reserved3:2;
229         u8      DSSS_OFDM:1;
230         u8      Reserved2:2;
231         u8      Short_Slot_Time:1;
232         u8    Reserved1:2;
233         u8    Channel_Agility:1;
234         u8    PBCC:1;
235         u8    ShortPreamble:1;
236         u8    CF_Privacy:1;
237         u8    CF_Poll_Request:1;
238         u8    CF_Pollable:1;
239         u8    IBSS:1;
240         u8    ESS:1;
241     } __attribute__ ((packed)) Capability;
242     #else
243     struct _Capability {
244         u8    ESS:1;
245         u8    IBSS:1;
246         u8    CF_Pollable:1;
247         u8    CF_Poll_Request:1;
248         u8    CF_Privacy:1;
249         u8    ShortPreamble:1;
250         u8    PBCC:1;
251         u8    Channel_Agility:1;
252         u8    Reserved1:2;
253                 /* --  11G  -- */
254                 u8      Short_Slot_Time:1;
255                 u8      Reserved2:2;
256                 u8      DSSS_OFDM:1;
257                 u8      Reserved3:2;
258     } __attribute__ ((packed)) Capability;
259     #endif
260   } __attribute__ ((packed)) ;
261 } __attribute__ ((packed));
262
263 struct FH_Parameter_Set_Element {
264     u8    Element_ID;
265     u8    Length;
266     u8    Dwell_Time[2];
267     u8    Hop_Set;
268     u8    Hop_Pattern;
269     u8    Hop_Index;
270 };
271
272 struct DS_Parameter_Set_Element {
273     u8    Element_ID;
274     u8    Length;
275     u8    Current_Channel;
276 };
277
278 struct Supported_Rates_Element {
279     u8    Element_ID;
280     u8    Length;
281     u8    SupportedRates[8];
282 } __attribute__ ((packed));
283
284 struct SSID_Element {
285     u8    Element_ID;
286     u8    Length;
287     u8    SSID[32];
288 } __attribute__ ((packed)) ;
289
290 struct CF_Parameter_Set_Element {
291     u8    Element_ID;
292     u8    Length;
293     u8    CFP_Count;
294     u8    CFP_Period;
295     u8    CFP_MaxDuration[2];     /* in Time Units */
296     u8    CFP_DurRemaining[2];    /* in time units */
297 };
298
299 struct TIM_Element {
300     u8    Element_ID;
301     u8    Length;
302     u8    DTIM_Count;
303     u8    DTIM_Period;
304     u8    Bitmap_Control;
305     u8    Partial_Virtual_Bitmap[251];
306 };
307
308 struct IBSS_Parameter_Set_Element {
309     u8    Element_ID;
310     u8    Length;
311     u8    ATIM_Window[2];
312 };
313
314 struct Challenge_Text_Element {
315     u8    Element_ID;
316     u8    Length;
317     u8    Challenge_Text[253];
318 };
319
320 struct PHY_Parameter_Set_Element {
321 /*  int     aSlotTime; */
322 /*  int     aSifsTime; */
323     s32     aCCATime;
324     s32     aRxTxTurnaroundTime;
325     s32     aTxPLCPDelay;
326     s32     RxPLCPDelay;
327     s32     aRxTxSwitchTime;
328     s32     aTxRampOntime;
329     s32     aTxRampOffTime;
330     s32     aTxRFDelay;
331     s32     aRxRFDelay;
332     s32     aAirPropagationTime;
333     s32     aMACProcessingDelay;
334     s32     aPreambleLength;
335     s32     aPLCPHeaderLength;
336     s32     aMPDUDurationFactor;
337     s32     aMPDUMaxLength;
338 /*  int     aCWmin; */
339 /*  int     aCWmax; */
340 };
341
342 /* --  11G  -- */
343 struct ERP_Information_Element {
344     u8  Element_ID;
345     u8  Length;
346     #ifdef _BIG_ENDIAN_ /* 20060926 add by anson's endian */
347         u8      Reserved:5;   /* 20060926 add by anson */
348         u8      Barker_Preamble_Mode:1;
349         u8      Use_Protection:1;
350        u8       NonERP_Present:1;
351     #else
352         u8      NonERP_Present:1;
353         u8      Use_Protection:1;
354         u8      Barker_Preamble_Mode:1;
355         u8      Reserved:5;
356     #endif
357 };
358
359 struct Extended_Supported_Rates_Element {
360     u8  Element_ID;
361     u8  Length;
362     u8  ExtendedSupportedRates[255];
363 } __attribute__ ((packed));
364
365 /* WPA(802.11i draft 3.0) */
366 #define VERSION_WPA                             1
367 /* WPA2.0 OUI=00:50:F2, the MSB is reserved for suite type */
368 #define OUI_WPA                                 0x00F25000
369
370 #define OUI_WPA_ADDITIONAL              0x01
371 #define WLAN_MIN_RSN_WPA_LENGTH                 6 /* added by ws 09/10/04 */
372
373 #define oui_wpa                  (u32)(OUI_WPA|OUI_WPA_ADDITIONAL)
374
375 #define WPA_OUI_BIG    ((u32) 0x01F25000)/* added by ws 09/23/04 */
376 #define WPA_OUI_LITTLE  ((u32) 0x01F25001)/* added by ws 09/23/04 */
377 /* 20061108 For WPS. It's little endian. Big endian is 0x0050F204 */
378 #define WPA_WPS_OUI                             cpu_to_le32(0x04F25000)
379
380 /* Authentication suite */
381 #define OUI_AUTH_WPA_NONE           0x00 /* for WPA_NONE */
382 #define OUI_AUTH_8021X                          0x01
383 #define OUI_AUTH_PSK                            0x02
384 /* Cipher suite */
385 #define OUI_CIPHER_GROUP_KEY        0x00  /* added by ws 05/21/04 */
386 #define OUI_CIPHER_WEP_40                       0x01
387 #define OUI_CIPHER_TKIP                         0x02
388 #define OUI_CIPHER_CCMP                         0x04
389 #define OUI_CIPHER_WEP_104                      0x05
390
391 struct suite_selector{
392         union{
393                 u8      Value[4];
394                 struct _SUIT_ {
395                         u8      OUI[3];
396                         u8      Type;
397                 } SuitSelector;
398         };
399 };
400
401 /* --  WPA  -- */
402 struct  RSN_Information_Element{
403         u8                                      Element_ID;
404         u8                                      Length;
405  /* WPA version 2.0 additional field, and should be 00:50:F2:01 */
406         struct suite_selector   OuiWPAAdditional;
407         u16                                     Version;
408         struct suite_selector           GroupKeySuite;
409         u16                                     PairwiseKeySuiteCount;
410         struct suite_selector           PairwiseKeySuite[1];
411 } __attribute__ ((packed));
412 struct RSN_Auth_Sub_Information_Element {
413         u16                             AuthKeyMngtSuiteCount;
414         struct suite_selector   AuthKeyMngtSuite[1];
415 } __attribute__ ((packed));
416
417 /* --  WPA2  -- */
418 struct RSN_Capability_Element {
419   union {
420         u16     __attribute__ ((packed))        wValue;
421     #ifdef _BIG_ENDIAN_  /* 20060927 add by anson's endian */
422     struct _RSN_Capability {
423         u16   __attribute__ ((packed))  Reserved2:8; /* 20051201 */
424         u16   __attribute__ ((packed))  Reserved1:2;
425         u16   __attribute__ ((packed))  GTK_Replay_Counter:2;
426         u16   __attribute__ ((packed))  PTK_Replay_Counter:2;
427         u16   __attribute__ ((packed))  No_Pairwise:1;
428         u16   __attribute__ ((packed))  Pre_Auth:1;
429     } __attribute__ ((packed))  RSN_Capability;
430     #else
431     struct _RSN_Capability {
432         u16   __attribute__ ((packed))  Pre_Auth:1;
433         u16   __attribute__ ((packed))  No_Pairwise:1;
434         u16   __attribute__ ((packed))  PTK_Replay_Counter:2;
435         u16   __attribute__ ((packed))  GTK_Replay_Counter:2;
436         u16   __attribute__ ((packed))  Reserved1:2;
437         u16   __attribute__ ((packed))  Reserved2:8; /* 20051201 */
438     } __attribute__ ((packed))  RSN_Capability;
439     #endif
440
441   } __attribute__ ((packed)) ;
442 } __attribute__ ((packed)) ;
443
444 /*============================================================
445 // MAC Frame structure (different type) and subfield structure
446 //============================================================*/
447 struct MAC_frame_control {
448 /* a combination of the [Protocol Version, Control Type, Control Subtype]*/
449     u8    mac_frame_info;
450 /* 20060927 add by anson's endian */
451     #ifdef _BIG_ENDIAN_
452     u8    order:1;
453     u8    WEP:1;
454     u8    more_data:1;
455     u8    pwr_mgt:1;
456     u8    retry:1;
457     u8    more_frag:1;
458     u8    from_ds:1;
459     u8    to_ds:1;
460     #else
461     u8    to_ds:1;
462     u8    from_ds:1;
463     u8    more_frag:1;
464     u8    retry:1;
465     u8    pwr_mgt:1;
466     u8    more_data:1;
467     u8    WEP:1;
468     u8    order:1;
469     #endif
470 } __attribute__ ((packed));
471
472 struct Management_Frame {
473 /* 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 */
474     struct MAC_frame_control frame_control;
475     u16         duration;
476     u8          DA[MAC_ADDR_LENGTH];                    /* Addr1 */
477     u8          SA[MAC_ADDR_LENGTH];                    /* Addr2 */
478     u8          BSSID[MAC_ADDR_LENGTH];                 /* Addr3 */
479     u16         Sequence_Control;
480     /* Management Frame Body <= 325 bytes */
481     /* FCS 4 bytes */
482 } __attribute__ ((packed));
483
484 /* SW-MAC don't Tx/Rx Control-Frame, HW-MAC do it. */
485 struct Control_Frame {
486 /* ToDS,FromDS,MoreFrag,Retry,MoreData,WEP,Order=0 */
487     struct MAC_frame_control frame_control;
488     u16         duration;
489     u8          RA[MAC_ADDR_LENGTH];
490     u8          TA[MAC_ADDR_LENGTH];
491     u16         FCS;
492 } __attribute__ ((packed));
493
494 struct Data_Frame {
495     struct MAC_frame_control frame_control;
496     u16         duration;
497     u8          Addr1[MAC_ADDR_LENGTH];
498     u8          Addr2[MAC_ADDR_LENGTH];
499     u8          Addr3[MAC_ADDR_LENGTH];
500     u16         Sequence_Control;
501     u8          Addr4[MAC_ADDR_LENGTH]; /* only exist when ToDS=FromDS=1 */
502     /* Data Frame Body <= 2312 */
503     /* FCS */
504 } __attribute__ ((packed));
505
506 struct Disassociation_Frame_Body {
507     u16    reasonCode;
508 } __attribute__ ((packed));
509
510 struct Association_Request_Frame_Body {
511     u16    capability_information;
512     u16    listenInterval;
513     u8     Current_AP_Address[MAC_ADDR_LENGTH];/* for reassociation only */
514     /*  SSID (2+32 bytes) */
515     /*  Supported_Rates (2+8 bytes) */
516 } __attribute__ ((packed));
517
518 struct Association_Response_Frame_Body {
519     u16    capability_information;
520     u16    statusCode;
521     u16    Association_ID;
522     struct Supported_Rates_Element supportedRates;
523 } __attribute__ ((packed));
524
525 /*struct Reassociation_Request_Frame_Body
526 {
527     u16    capability_information;
528     u16    listenInterval;
529     u8     Current_AP_Address[MAC_ADDR_LENGTH];
530     // SSID (2+32 bytes)
531     // Supported_Rates (2+8 bytes)
532 };*/
533 /* eliminated by WS 07/22/04 comboined with associateion request frame. */
534
535 struct Reassociation_Response_Frame_Body {
536     u16    capability_information;
537     u16    statusCode;
538     u16    Association_ID;
539     struct Supported_Rates_Element supportedRates;
540 } __attribute__ ((packed));
541
542 struct Deauthentication_Frame_Body {
543     u16    reasonCode;
544 } __attribute__ ((packed));
545
546
547 struct Probe_Response_Frame_Body {
548     u16    Timestamp;
549     u16    Beacon_Interval;
550     u16    Capability_Information;
551     /* SSID
552     // Supported_Rates
553     // PHY parameter Set (DS Parameters)
554     // CF parameter Set
555     // IBSS parameter Set */
556 } __attribute__ ((packed));
557
558 struct Authentication_Frame_Body {
559     u16    algorithmNumber;
560     u16    sequenceNumber;
561     u16    statusCode;
562         /* NB: don't include ChallengeText in this structure
563         // struct Challenge_Text_Element sChallengeTextElement;
564         // wkchen added */
565 } __attribute__ ((packed));
566
567
568 #endif /* _MAC_Structure_H_ */
569
570