Merge branch 'fix/asoc' into for-linus
[linux-2.6] / drivers / staging / rt3070 / mlme.h
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
10  * This program is free software; you can redistribute it and/or modify  *
11  * it under the terms of the GNU General Public License as published by  *
12  * the Free Software Foundation; either version 2 of the License, or     *
13  * (at your option) any later version.                                   *
14  *                                                                       *
15  * This program is distributed in the hope that it will be useful,       *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  * GNU General Public License for more details.                          *
19  *                                                                       *
20  * You should have received a copy of the GNU General Public License     *
21  * along with this program; if not, write to the                         *
22  * Free Software Foundation, Inc.,                                       *
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24  *                                                                       *
25  *************************************************************************
26
27         Module Name:
28         mlme.h
29
30         Abstract:
31
32         Revision History:
33         Who                     When                    What
34         --------        ----------              ----------------------------------------------
35         John Chang      2003-08-28              Created
36         John Chang  2004-09-06      modified for RT2600
37
38 */
39 #ifndef __MLME_H__
40 #define __MLME_H__
41
42 //extern UCHAR BROADCAST_ADDR[];
43
44 // maximum supported capability information -
45 // ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
46 #define SUPPORTED_CAPABILITY_INFO   0x0533
47
48 #define END_OF_ARGS                 -1
49 #define LFSR_MASK                   0x80000057
50 #define MLME_TASK_EXEC_INTV         100/*200*/       //
51 #define LEAD_TIME                   5
52 #define MLME_TASK_EXEC_MULTIPLE       10  /*5*/       // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
53 #define REORDER_EXEC_INTV               100       // 0.1 sec
54 //#define TBTT_PRELOAD_TIME         384        // usec. LomgPreamble + 24-byte at 1Mbps
55
56 // The definition of Radar detection duration region
57 #define CE              0
58 #define FCC             1
59 #define JAP             2
60 #define JAP_W53 3
61 #define JAP_W56 4
62 #define MAX_RD_REGION 5
63
64 #ifdef  NDIS51_MINIPORT
65 #define BEACON_LOST_TIME            4000       // 2048 msec = 2 sec
66 #else
67 #define BEACON_LOST_TIME            4 * OS_HZ    // 2048 msec = 2 sec
68 #endif
69
70 #define DLS_TIMEOUT                 1200      // unit: msec
71 #define AUTH_TIMEOUT                300       // unit: msec
72 #define ASSOC_TIMEOUT               300       // unit: msec
73 #define JOIN_TIMEOUT                2 * OS_HZ      // unit: msec
74 #define SHORT_CHANNEL_TIME          90        // unit: msec
75 #define MIN_CHANNEL_TIME            110        // unit: msec, for dual band scan
76 #define MAX_CHANNEL_TIME            140       // unit: msec, for single band scan
77 #define FAST_ACTIVE_SCAN_TIME       30            // Active scan waiting for probe response time
78 #define CW_MIN_IN_BITS              4         // actual CwMin = 2^CW_MIN_IN_BITS - 1
79
80
81 #ifdef CONFIG_STA_SUPPORT
82 #ifndef CONFIG_AP_SUPPORT
83 #define CW_MAX_IN_BITS              10        // actual CwMax = 2^CW_MAX_IN_BITS - 1
84 #endif
85 #endif // CONFIG_STA_SUPPORT //
86
87 #ifdef CONFIG_APSTA_MIXED_SUPPORT
88 extern UINT32 CW_MAX_IN_BITS;
89 #endif // CONFIG_APSTA_MIXED_SUPPORT //
90
91 // Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
92 // SHould not refer to this constant anymore
93 //#define RSSI_TO_DBM_OFFSET          120 // for RT2530 RSSI-115 = dBm
94 #define RSSI_FOR_MID_TX_POWER       -55  // -55 db is considered mid-distance
95 #define RSSI_FOR_LOW_TX_POWER       -45  // -45 db is considered very short distance and
96                                         // eligible to use a lower TX power
97 #define RSSI_FOR_LOWEST_TX_POWER    -30
98 //#define MID_TX_POWER_DELTA          0   // 0 db from full TX power upon mid-distance to AP
99 #define LOW_TX_POWER_DELTA          6    // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
100 #define LOWEST_TX_POWER_DELTA       16   // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
101
102 #define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD     0
103 #define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD   1
104 #define RSSI_THRESHOLD_FOR_ROAMING              25
105 #define RSSI_DELTA                              5
106
107 // Channel Quality Indication
108 #define CQI_IS_GOOD(cqi)            ((cqi) >= 50)
109 //#define CQI_IS_FAIR(cqi)          (((cqi) >= 20) && ((cqi) < 50))
110 #define CQI_IS_POOR(cqi)            (cqi < 50)  //(((cqi) >= 5) && ((cqi) < 20))
111 #define CQI_IS_BAD(cqi)             (cqi < 5)
112 #define CQI_IS_DEAD(cqi)            (cqi == 0)
113
114 // weighting factor to calculate Channel quality, total should be 100%
115 #define RSSI_WEIGHTING                   50
116 #define TX_WEIGHTING                     30
117 #define RX_WEIGHTING                     20
118
119 //#define PEER_KEY_NOT_USED                0
120 //#define PEER_KEY_64_BIT                  64
121 //#define PEER_KEY_128_BIT                 128
122
123 //#define PEER_KEY_64BIT_LEN               8
124 //#define PEER_KEY_128BIT_LEN              16
125
126 #define BSS_NOT_FOUND                    0xFFFFFFFF
127
128
129 #ifdef CONFIG_STA_SUPPORT
130 #define MAX_LEN_OF_MLME_QUEUE            40 //10
131 #endif // CONFIG_STA_SUPPORT //
132
133 #define SCAN_PASSIVE                     18             // scan with no probe request, only wait beacon and probe response
134 #define SCAN_ACTIVE                      19             // scan with probe request, and wait beacon and probe response
135 #define SCAN_CISCO_PASSIVE                               20             // Single channel passive scan
136 #define SCAN_CISCO_ACTIVE                                21             // Single channel active scan
137 #define SCAN_CISCO_NOISE                                 22             // Single channel passive scan for noise histogram collection
138 #define SCAN_CISCO_CHANNEL_LOAD                  23             // Single channel passive scan for channel load collection
139 #define FAST_SCAN_ACTIVE                 24             // scan with probe request, and wait beacon and probe response
140
141 #ifdef DOT11N_DRAFT3
142 #define SCAN_2040_BSS_COEXIST                  26
143 #endif // DOT11N_DRAFT3 //
144
145 //#define BSS_TABLE_EMPTY(x)             ((x).BssNr == 0)
146 #define MAC_ADDR_IS_GROUP(Addr)       (((Addr[0]) & 0x01))
147 #define MAC_ADDR_HASH(Addr)            (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
148 #define MAC_ADDR_HASH_INDEX(Addr)      (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
149 #define TID_MAC_HASH(Addr,TID)            (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
150 #define TID_MAC_HASH_INDEX(Addr,TID)      (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
151
152 // LED Control
153 // assoiation ON. one LED ON. another blinking when TX, OFF when idle
154 // no association, both LED off
155 #define ASIC_LED_ACT_ON(pAd)        RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
156 #define ASIC_LED_ACT_OFF(pAd)       RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
157
158 // bit definition of the 2-byte pBEACON->Capability field
159 #define CAP_IS_ESS_ON(x)                 (((x) & 0x0001) != 0)
160 #define CAP_IS_IBSS_ON(x)                (((x) & 0x0002) != 0)
161 #define CAP_IS_CF_POLLABLE_ON(x)         (((x) & 0x0004) != 0)
162 #define CAP_IS_CF_POLL_REQ_ON(x)         (((x) & 0x0008) != 0)
163 #define CAP_IS_PRIVACY_ON(x)             (((x) & 0x0010) != 0)
164 #define CAP_IS_SHORT_PREAMBLE_ON(x)      (((x) & 0x0020) != 0)
165 #define CAP_IS_PBCC_ON(x)                (((x) & 0x0040) != 0)
166 #define CAP_IS_AGILITY_ON(x)             (((x) & 0x0080) != 0)
167 #define CAP_IS_SPECTRUM_MGMT(x)          (((x) & 0x0100) != 0)  // 802.11e d9
168 #define CAP_IS_QOS(x)                    (((x) & 0x0200) != 0)  // 802.11e d9
169 #define CAP_IS_SHORT_SLOT(x)             (((x) & 0x0400) != 0)
170 #define CAP_IS_APSD(x)                   (((x) & 0x0800) != 0)  // 802.11e d9
171 #define CAP_IS_IMMED_BA(x)               (((x) & 0x1000) != 0)  // 802.11e d9
172 #define CAP_IS_DSSS_OFDM(x)              (((x) & 0x2000) != 0)
173 #define CAP_IS_DELAY_BA(x)               (((x) & 0x4000) != 0)  // 802.11e d9
174
175 #define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum)  (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
176
177 //#define STA_QOS_CAPABILITY               0 // 1-byte. see 802.11e d9.0 for bit definition
178
179 #define ERP_IS_NON_ERP_PRESENT(x)        (((x) & 0x01) != 0)    // 802.11g
180 #define ERP_IS_USE_PROTECTION(x)         (((x) & 0x02) != 0)    // 802.11g
181 #define ERP_IS_USE_BARKER_PREAMBLE(x)    (((x) & 0x04) != 0)    // 802.11g
182
183 #define DRS_TX_QUALITY_WORST_BOUND       8// 3  // just test by gary
184 #define DRS_PENALTY                      8
185
186 #define BA_NOTUSE       2
187 //BA Policy subfiled value in ADDBA frame
188 #define IMMED_BA        1
189 #define DELAY_BA        0
190
191 // BA Initiator subfield in DELBA frame
192 #define ORIGINATOR      1
193 #define RECIPIENT       0
194
195 // ADDBA Status Code
196 #define ADDBA_RESULTCODE_SUCCESS                                        0
197 #define ADDBA_RESULTCODE_REFUSED                                        37
198 #define ADDBA_RESULTCODE_INVALID_PARAMETERS                     38
199
200 // DELBA Reason Code
201 #define DELBA_REASONCODE_QSTA_LEAVING                           36
202 #define DELBA_REASONCODE_END_BA                                         37
203 #define DELBA_REASONCODE_UNKNOWN_BA                                     38
204 #define DELBA_REASONCODE_TIMEOUT                                        39
205
206 // reset all OneSecTx counters
207 #define RESET_ONE_SEC_TX_CNT(__pEntry) \
208 if (((__pEntry)) != NULL) \
209 { \
210         (__pEntry)->OneSecTxRetryOkCount = 0; \
211         (__pEntry)->OneSecTxFailCount = 0; \
212         (__pEntry)->OneSecTxNoRetryOkCount = 0; \
213 }
214
215 //
216 // 802.11 frame formats
217 //
218 //  HT Capability INFO field in HT Cap IE .
219 typedef struct PACKED {
220 #ifdef RT_BIG_ENDIAN
221         USHORT  LSIGTxopProSup:1;
222         USHORT  Forty_Mhz_Intolerant:1;
223         USHORT  PSMP:1;
224         USHORT  CCKmodein40:1;
225         USHORT  AMsduSize:1;
226         USHORT  DelayedBA:1;    //rt2860c not support
227         USHORT  RxSTBC:2;
228         USHORT  TxSTBC:1;
229         USHORT  ShortGIfor40:1; //for40MHz
230         USHORT  ShortGIfor20:1;
231         USHORT  GF:1;   //green field
232         USHORT  MimoPs:2;//momi power safe
233         USHORT  ChannelWidth:1;
234         USHORT  AdvCoding:1;
235 #else
236         USHORT  AdvCoding:1;
237         USHORT  ChannelWidth:1;
238         USHORT  MimoPs:2;//momi power safe
239         USHORT  GF:1;   //green field
240         USHORT  ShortGIfor20:1;
241         USHORT  ShortGIfor40:1; //for40MHz
242         USHORT  TxSTBC:1;
243         USHORT  RxSTBC:2;
244         USHORT  DelayedBA:1;    //rt2860c not support
245         USHORT  AMsduSize:1;    // only support as zero
246         USHORT  CCKmodein40:1;
247         USHORT  PSMP:1;
248         USHORT  Forty_Mhz_Intolerant:1;
249         USHORT  LSIGTxopProSup:1;
250 #endif  /* !RT_BIG_ENDIAN */
251 } HT_CAP_INFO, *PHT_CAP_INFO;
252
253 //  HT Capability INFO field in HT Cap IE .
254 typedef struct PACKED {
255 #ifdef RT_BIG_ENDIAN
256         UCHAR   rsv:3;//momi power safe
257         UCHAR   MpduDensity:3;
258         UCHAR   MaxRAmpduFactor:2;
259 #else
260         UCHAR   MaxRAmpduFactor:2;
261         UCHAR   MpduDensity:3;
262         UCHAR   rsv:3;//momi power safe
263 #endif /* !RT_BIG_ENDIAN */
264 } HT_CAP_PARM, *PHT_CAP_PARM;
265
266 //  HT Capability INFO field in HT Cap IE .
267 typedef struct PACKED {
268         UCHAR   MCSSet[10];
269         UCHAR   SupRate[2];  // unit : 1Mbps
270 #ifdef RT_BIG_ENDIAN
271         UCHAR   rsv:3;
272         UCHAR   MpduDensity:1;
273         UCHAR   TxStream:2;
274         UCHAR   TxRxNotEqual:1;
275         UCHAR   TxMCSSetDefined:1;
276 #else
277         UCHAR   TxMCSSetDefined:1;
278         UCHAR   TxRxNotEqual:1;
279         UCHAR   TxStream:2;
280         UCHAR   MpduDensity:1;
281         UCHAR   rsv:3;
282 #endif // RT_BIG_ENDIAN //
283         UCHAR   rsv3[3];
284 } HT_MCS_SET, *PHT_MCS_SET;
285
286 //  HT Capability INFO field in HT Cap IE .
287 typedef struct PACKED {
288 #ifdef RT_BIG_ENDIAN
289         USHORT  rsv2:4;
290         USHORT  RDGSupport:1;   //reverse Direction Grant  support
291         USHORT  PlusHTC:1;      //+HTC control field support
292         USHORT  MCSFeedback:2;  //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback,  1:rsv.
293         USHORT  rsv:5;//momi power safe
294         USHORT  TranTime:2;
295         USHORT  Pco:1;
296 #else
297         USHORT  Pco:1;
298         USHORT  TranTime:2;
299         USHORT  rsv:5;//momi power safe
300         USHORT  MCSFeedback:2;  //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback,  1:rsv.
301         USHORT  PlusHTC:1;      //+HTC control field support
302         USHORT  RDGSupport:1;   //reverse Direction Grant  support
303         USHORT  rsv2:4;
304 #endif /* RT_BIG_ENDIAN */
305 } EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
306
307 //  HT Beamforming field in HT Cap IE .
308 typedef struct PACKED _HT_BF_CAP{
309 #ifdef RT_BIG_ENDIAN
310         ULONG   rsv:3;
311         ULONG   ChanEstimation:2;
312         ULONG   CSIRowBFSup:2;
313         ULONG   ComSteerBFAntSup:2;
314         ULONG   NoComSteerBFAntSup:2;
315         ULONG   CSIBFAntSup:2;
316         ULONG   MinGrouping:2;
317         ULONG   ExpComBF:2;
318         ULONG   ExpNoComBF:2;
319         ULONG   ExpCSIFbk:2;
320         ULONG   ExpComSteerCapable:1;
321         ULONG   ExpNoComSteerCapable:1;
322         ULONG   ExpCSICapable:1;
323         ULONG   Calibration:2;
324         ULONG   ImpTxBFCapable:1;
325         ULONG   TxNDPCapable:1;
326         ULONG   RxNDPCapable:1;
327         ULONG   TxSoundCapable:1;
328         ULONG   RxSoundCapable:1;
329         ULONG   TxBFRecCapable:1;
330 #else
331         ULONG   TxBFRecCapable:1;
332         ULONG   RxSoundCapable:1;
333         ULONG   TxSoundCapable:1;
334         ULONG   RxNDPCapable:1;
335         ULONG   TxNDPCapable:1;
336         ULONG   ImpTxBFCapable:1;
337         ULONG   Calibration:2;
338         ULONG   ExpCSICapable:1;
339         ULONG   ExpNoComSteerCapable:1;
340         ULONG   ExpComSteerCapable:1;
341         ULONG   ExpCSIFbk:2;
342         ULONG   ExpNoComBF:2;
343         ULONG   ExpComBF:2;
344         ULONG   MinGrouping:2;
345         ULONG   CSIBFAntSup:2;
346         ULONG   NoComSteerBFAntSup:2;
347         ULONG   ComSteerBFAntSup:2;
348         ULONG   CSIRowBFSup:2;
349         ULONG   ChanEstimation:2;
350         ULONG   rsv:3;
351 #endif // RT_BIG_ENDIAN //
352 } HT_BF_CAP, *PHT_BF_CAP;
353
354 //  HT antenna selection field in HT Cap IE .
355 typedef struct PACKED _HT_AS_CAP{
356 #ifdef RT_BIG_ENDIAN
357         UCHAR   rsv:1;
358         UCHAR   TxSoundPPDU:1;
359         UCHAR   RxASel:1;
360         UCHAR   AntIndFbk:1;
361         UCHAR   ExpCSIFbk:1;
362         UCHAR   AntIndFbkTxASEL:1;
363         UCHAR   ExpCSIFbkTxASEL:1;
364         UCHAR   AntSelect:1;
365 #else
366         UCHAR   AntSelect:1;
367         UCHAR   ExpCSIFbkTxASEL:1;
368         UCHAR   AntIndFbkTxASEL:1;
369         UCHAR   ExpCSIFbk:1;
370         UCHAR   AntIndFbk:1;
371         UCHAR   RxASel:1;
372         UCHAR   TxSoundPPDU:1;
373         UCHAR   rsv:1;
374 #endif // RT_BIG_ENDIAN //
375 } HT_AS_CAP, *PHT_AS_CAP;
376
377 // Draft 1.0 set IE length 26, but is extensible..
378 #define SIZE_HT_CAP_IE          26
379 // The structure for HT Capability IE.
380 typedef struct PACKED _HT_CAPABILITY_IE{
381         HT_CAP_INFO             HtCapInfo;
382         HT_CAP_PARM             HtCapParm;
383 //      HT_MCS_SET              HtMCSSet;
384         UCHAR                   MCSSet[16];
385         EXT_HT_CAP_INFO ExtHtCapInfo;
386         HT_BF_CAP               TxBFCap;        // beamforming cap. rt2860c not support beamforming.
387         HT_AS_CAP               ASCap;  //antenna selection.
388 } HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
389
390
391 // 802.11n draft3 related structure definitions.
392 // 7.3.2.60
393 #define dot11OBSSScanPassiveDwell                                                       20      // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
394 #define dot11OBSSScanActiveDwell                                                        10      // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
395 #define dot11BSSWidthTriggerScanInterval                                        300  // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
396 #define dot11OBSSScanPassiveTotalPerChannel                                     200     // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
397 #define dot11OBSSScanActiveTotalPerChannel                                      20      //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
398 #define dot11BSSWidthChannelTransactionDelayFactor                      5       // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
399                                                                                                                                 //      interval between overlapping BSS scan operations.
400 #define dot11BSSScanActivityThreshold                                           25      // in %%, max total time that a STA may be active on the medium during a period of
401                                                                                                                                 //      (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
402                                                                                                                                 //      being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
403
404 typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
405         USHORT          ScanPassiveDwell;
406         USHORT          ScanActiveDwell;
407         USHORT          TriggerScanInt;                         // Trigger scan interval
408         USHORT          PassiveTalPerChannel;           // passive total per channel
409         USHORT          ActiveTalPerChannel;            // active total per channel
410         USHORT          DelayFactor;                            // BSS width channel transition delay factor
411         USHORT          ScanActThre;                            // Scan Activity threshold
412 }OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
413
414
415 //  7.3.2.56. 20/40 Coexistence element used in  Element ID = 72 = IE_2040_BSS_COEXIST
416 typedef union PACKED _BSS_2040_COEXIST_IE{
417  struct PACKED {
418  #ifdef RT_BIG_ENDIAN
419         UCHAR   rsv:5;
420         UCHAR   BSS20WidthReq:1;
421         UCHAR   Intolerant40:1;
422         UCHAR   InfoReq:1;
423  #else
424         UCHAR   InfoReq:1;
425         UCHAR   Intolerant40:1;                 // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
426         UCHAR   BSS20WidthReq:1;                // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
427         UCHAR   rsv:5;
428 #endif // RT_BIG_ENDIAN //
429     } field;
430  UCHAR   word;
431 } BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
432
433
434 typedef struct  _TRIGGER_EVENTA{
435         BOOLEAN                 bValid;
436         UCHAR   BSSID[6];
437         UCHAR   RegClass;       // Regulatory Class
438         USHORT  Channel;
439         ULONG   CDCounter;   // Maintain a seperate count down counter for each Event A.
440 } TRIGGER_EVENTA, *PTRIGGER_EVENTA;
441
442 // 20/40 trigger event table
443 // If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
444 #define MAX_TRIGGER_EVENT               64
445 typedef struct  _TRIGGER_EVENT_TAB{
446         UCHAR   EventANo;
447         TRIGGER_EVENTA  EventA[MAX_TRIGGER_EVENT];
448         ULONG                   EventBCountDown;        // Count down counter for Event B.
449 } TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
450
451 // 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
452 //      This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
453 typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
454 #ifdef RT_BIG_ENDIAN
455         UCHAR   rsv2:5;
456         UCHAR   ExtendChannelSwitch:1;
457         UCHAR   rsv:1;
458         UCHAR   BssCoexistMgmtSupport:1;
459 #else
460         UCHAR   BssCoexistMgmtSupport:1;
461         UCHAR   rsv:1;
462         UCHAR   ExtendChannelSwitch:1;
463         UCHAR   rsv2:5;
464 #endif // RT_BIG_ENDIAN //
465 }EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
466
467
468 // 802.11n 7.3.2.61
469 typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
470         UCHAR                                   ElementID;              // ID = IE_2040_BSS_COEXIST = 72
471         UCHAR                                   Len;
472         BSS_2040_COEXIST_IE             BssCoexistIe;
473 }BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
474
475
476 //802.11n 7.3.2.59
477 typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
478         UCHAR                           ElementID;              // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
479         UCHAR                           Len;
480         UCHAR                           RegulatoryClass;
481         UCHAR                           ChList[0];
482 }BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
483
484
485 // The structure for channel switch annoucement IE. This is in 802.11n D3.03
486 typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
487         UCHAR                   SwitchMode;     //channel switch mode
488         UCHAR                   NewChannel;     //
489         UCHAR                   SwitchCount;    //
490 } CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
491
492
493 // The structure for channel switch annoucement IE. This is in 802.11n D3.03
494 typedef struct PACKED _SEC_CHA_OFFSET_IE{
495         UCHAR                   SecondaryChannelOffset;  // 1: Secondary above, 3: Secondary below, 0: no Secondary
496 } SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
497
498
499 // This structure is extracted from struct RT_HT_CAPABILITY
500 typedef struct {
501         BOOLEAN                 bHtEnable;       // If we should use ht rate.
502         BOOLEAN                 bPreNHt;         // If we should use ht rate.
503         //Substract from HT Capability IE
504         UCHAR                   MCSSet[16];     //only supoort MCS=0-15,32 ,
505 } RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
506
507 //This structure substracts ralink supports from all 802.11n-related features.
508 //Features not listed here but contained in 802.11n spec are not supported in rt2860.
509 typedef struct {
510 #ifdef RT_BIG_ENDIAN
511         USHORT  rsv:5;
512         USHORT  AmsduSize:1;    // Max receiving A-MSDU size
513         USHORT  AmsduEnable:1;  // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
514         USHORT  RxSTBC:2;       // 2 bits
515         USHORT  TxSTBC:1;
516         USHORT  ShortGIfor40:1; //for40MHz
517         USHORT  ShortGIfor20:1;
518         USHORT  GF:1;   //green field
519         USHORT  MimoPs:2;//mimo power safe MMPS_
520         USHORT  ChannelWidth:1;
521 #else
522         USHORT  ChannelWidth:1;
523         USHORT  MimoPs:2;//mimo power safe MMPS_
524         USHORT  GF:1;   //green field
525         USHORT  ShortGIfor20:1;
526         USHORT  ShortGIfor40:1; //for40MHz
527         USHORT  TxSTBC:1;
528         USHORT  RxSTBC:2;       // 2 bits
529         USHORT  AmsduEnable:1;  // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
530         USHORT  AmsduSize:1;    // Max receiving A-MSDU size
531         USHORT  rsv:5;
532 #endif
533
534         //Substract from Addiont HT INFO IE
535 #ifdef RT_BIG_ENDIAN
536         UCHAR   RecomWidth:1;
537         UCHAR   ExtChanOffset:2;        // Please not the difference with following     UCHAR   NewExtChannelOffset; from 802.11n
538         UCHAR   MpduDensity:3;
539         UCHAR   MaxRAmpduFactor:2;
540 #else
541         UCHAR   MaxRAmpduFactor:2;
542         UCHAR   MpduDensity:3;
543         UCHAR   ExtChanOffset:2;        // Please not the difference with following     UCHAR   NewExtChannelOffset; from 802.11n
544         UCHAR   RecomWidth:1;
545 #endif
546
547 #ifdef RT_BIG_ENDIAN
548         USHORT  rsv2:11;
549         USHORT  OBSS_NonHTExist:1;
550         USHORT  rsv3:1;
551         USHORT  NonGfPresent:1;
552         USHORT  OperaionMode:2;
553 #else
554         USHORT  OperaionMode:2;
555         USHORT  NonGfPresent:1;
556         USHORT  rsv3:1;
557         USHORT  OBSS_NonHTExist:1;
558         USHORT  rsv2:11;
559 #endif
560
561         // New Extension Channel Offset IE
562         UCHAR   NewExtChannelOffset;
563         // Extension Capability IE = 127
564         UCHAR   BSSCoexist2040;
565 } RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
566
567 //   field in Addtional HT Information IE .
568 typedef struct PACKED {
569 #ifdef RT_BIG_ENDIAN
570         UCHAR   SerInterGranu:3;
571         UCHAR   S_PSMPSup:1;
572         UCHAR   RifsMode:1;
573         UCHAR   RecomWidth:1;
574         UCHAR   ExtChanOffset:2;
575 #else
576         UCHAR   ExtChanOffset:2;
577         UCHAR   RecomWidth:1;
578         UCHAR   RifsMode:1;
579         UCHAR   S_PSMPSup:1;     //Indicate support for scheduled PSMP
580         UCHAR   SerInterGranu:3;         //service interval granularity
581 #endif
582 } ADD_HTINFO, *PADD_HTINFO;
583
584 typedef struct PACKED{
585 #ifdef RT_BIG_ENDIAN
586         USHORT  rsv2:11;
587         USHORT  OBSS_NonHTExist:1;
588         USHORT  rsv:1;
589         USHORT  NonGfPresent:1;
590         USHORT  OperaionMode:2;
591 #else
592         USHORT  OperaionMode:2;
593         USHORT  NonGfPresent:1;
594         USHORT  rsv:1;
595         USHORT  OBSS_NonHTExist:1;
596         USHORT  rsv2:11;
597 #endif
598 } ADD_HTINFO2, *PADD_HTINFO2;
599
600
601 // TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
602 typedef struct PACKED{
603 #ifdef RT_BIG_ENDIAN
604         USHORT  rsv:4;
605         USHORT  PcoPhase:1;
606         USHORT  PcoActive:1;
607         USHORT  LsigTxopProt:1;
608         USHORT  STBCBeacon:1;
609         USHORT  DualCTSProtect:1;
610         USHORT  DualBeacon:1;
611         USHORT  StbcMcs:6;
612 #else
613         USHORT  StbcMcs:6;
614         USHORT  DualBeacon:1;
615         USHORT  DualCTSProtect:1;
616         USHORT  STBCBeacon:1;
617         USHORT  LsigTxopProt:1; // L-SIG TXOP protection full support
618         USHORT  PcoActive:1;
619         USHORT  PcoPhase:1;
620         USHORT  rsv:4;
621 #endif // RT_BIG_ENDIAN //
622 } ADD_HTINFO3, *PADD_HTINFO3;
623
624 #define SIZE_ADD_HT_INFO_IE             22
625 typedef struct  PACKED{
626         UCHAR                           ControlChan;
627         ADD_HTINFO                      AddHtInfo;
628         ADD_HTINFO2                     AddHtInfo2;
629         ADD_HTINFO3                     AddHtInfo3;
630         UCHAR                           MCSSet[16];             // Basic MCS set
631 } ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
632
633 typedef struct  PACKED{
634         UCHAR                           NewExtChanOffset;
635 } NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
636
637
638 // 4-byte HTC field.  maybe included in any frame except non-QOS data frame.  The Order bit must set 1.
639 typedef struct PACKED {
640 #ifdef RT_BIG_ENDIAN
641     UINT32              RDG:1;  //RDG / More PPDU
642     UINT32              ACConstraint:1; //feedback request
643     UINT32              rsv:5;  //calibration sequence
644     UINT32              ZLFAnnouce:1;   // ZLF announcement
645     UINT32              CSISTEERING:2;  //CSI/ STEERING
646     UINT32              FBKReq:2;       //feedback request
647     UINT32              CalSeq:2;  //calibration sequence
648     UINT32              CalPos:2;       // calibration position
649     UINT32              MFBorASC:7;     //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
650     UINT32              MFS:3;  //SET to the received value of MRS. 0x111 for unsolicited MFB.
651     UINT32              MRSorASI:3;     // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
652     UINT32              MRQ:1;  //MCS feedback. Request for a MCS feedback
653     UINT32              TRQ:1;  //sounding request
654     UINT32              MA:1;   //management action payload exist in (QoS Null+HTC)
655 #else
656     UINT32              MA:1;   //management action payload exist in (QoS Null+HTC)
657     UINT32              TRQ:1;  //sounding request
658     UINT32              MRQ:1;  //MCS feedback. Request for a MCS feedback
659     UINT32              MRSorASI:3;     // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
660     UINT32              MFS:3;  //SET to the received value of MRS. 0x111 for unsolicited MFB.
661     UINT32              MFBorASC:7;     //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
662     UINT32              CalPos:2;       // calibration position
663     UINT32              CalSeq:2;  //calibration sequence
664     UINT32              FBKReq:2;       //feedback request
665     UINT32              CSISTEERING:2;  //CSI/ STEERING
666     UINT32              ZLFAnnouce:1;   // ZLF announcement
667     UINT32              rsv:5;  //calibration sequence
668     UINT32              ACConstraint:1; //feedback request
669     UINT32              RDG:1;  //RDG / More PPDU
670 #endif /* !RT_BIG_ENDIAN */
671 } HT_CONTROL, *PHT_CONTROL;
672
673 // 2-byte QOS CONTROL field
674 typedef struct PACKED {
675 #ifdef RT_BIG_ENDIAN
676     USHORT      Txop_QueueSize:8;
677     USHORT      AMsduPresent:1;
678     USHORT      AckPolicy:2;  //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP  3: BA
679     USHORT      EOSP:1;
680     USHORT      TID:4;
681 #else
682     USHORT      TID:4;
683     USHORT      EOSP:1;
684     USHORT      AckPolicy:2;  //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP  3: BA
685     USHORT      AMsduPresent:1;
686     USHORT      Txop_QueueSize:8;
687 #endif /* !RT_BIG_ENDIAN */
688 } QOS_CONTROL, *PQOS_CONTROL;
689
690 // 2-byte Frame control field
691 typedef struct  PACKED {
692 #ifdef RT_BIG_ENDIAN
693         USHORT          Order:1;                        // Strict order expected
694         USHORT          Wep:1;                          // Wep data
695         USHORT          MoreData:1;                     // More data bit
696         USHORT          PwrMgmt:1;                      // Power management bit
697         USHORT          Retry:1;                        // Retry status bit
698         USHORT          MoreFrag:1;                     // More fragment bit
699         USHORT          FrDs:1;                         // From DS indication
700         USHORT          ToDs:1;                         // To DS indication
701         USHORT          SubType:4;                      // MSDU subtype
702         USHORT          Type:2;                         // MSDU type
703         USHORT          Ver:2;                          // Protocol version
704 #else
705         USHORT          Ver:2;                          // Protocol version
706         USHORT          Type:2;                         // MSDU type
707         USHORT          SubType:4;                      // MSDU subtype
708         USHORT          ToDs:1;                         // To DS indication
709         USHORT          FrDs:1;                         // From DS indication
710         USHORT          MoreFrag:1;                     // More fragment bit
711         USHORT          Retry:1;                        // Retry status bit
712         USHORT          PwrMgmt:1;                      // Power management bit
713         USHORT          MoreData:1;                     // More data bit
714         USHORT          Wep:1;                          // Wep data
715         USHORT          Order:1;                        // Strict order expected
716 #endif /* !RT_BIG_ENDIAN */
717 } FRAME_CONTROL, *PFRAME_CONTROL;
718
719 typedef struct  PACKED _HEADER_802_11   {
720     FRAME_CONTROL   FC;
721     USHORT          Duration;
722     UCHAR           Addr1[MAC_ADDR_LEN];
723     UCHAR           Addr2[MAC_ADDR_LEN];
724         UCHAR                   Addr3[MAC_ADDR_LEN];
725 #ifdef RT_BIG_ENDIAN
726         USHORT                  Sequence:12;
727         USHORT                  Frag:4;
728 #else
729         USHORT                  Frag:4;
730         USHORT                  Sequence:12;
731 #endif /* !RT_BIG_ENDIAN */
732         UCHAR                   Octet[0];
733 }       HEADER_802_11, *PHEADER_802_11;
734
735 typedef struct PACKED _FRAME_802_11 {
736     HEADER_802_11   Hdr;
737     UCHAR            Octet[1];
738 }   FRAME_802_11, *PFRAME_802_11;
739
740 // QoSNull embedding of management action. When HT Control MA field set to 1.
741 typedef struct PACKED _MA_BODY {
742     UCHAR            Category;
743     UCHAR            Action;
744     UCHAR            Octet[1];
745 }   MA_BODY, *PMA_BODY;
746
747 typedef struct  PACKED _HEADER_802_3    {
748     UCHAR           DAAddr1[MAC_ADDR_LEN];
749     UCHAR           SAAddr2[MAC_ADDR_LEN];
750     UCHAR           Octet[2];
751 }       HEADER_802_3, *PHEADER_802_3;
752 ////Block ACK related format
753 // 2-byte BA Parameter  field  in       DELBA frames to terminate an already set up bA
754 typedef struct PACKED{
755 #ifdef RT_BIG_ENDIAN
756     USHORT      TID:4;  // value of TC os TS
757     USHORT      Initiator:1;    // 1: originator    0:recipient
758     USHORT      Rsv:11; // always set to 0
759 #else
760     USHORT      Rsv:11; // always set to 0
761     USHORT      Initiator:1;    // 1: originator    0:recipient
762     USHORT      TID:4;  // value of TC os TS
763 #endif /* !RT_BIG_ENDIAN */
764 } DELBA_PARM, *PDELBA_PARM;
765
766 // 2-byte BA Parameter Set field  in ADDBA frames to signal parm for setting up a BA
767 typedef struct PACKED {
768 #ifdef RT_BIG_ENDIAN
769     USHORT      BufSize:10;     // number of buffe of size 2304 octetsr
770     USHORT      TID:4;  // value of TC os TS
771     USHORT      BAPolicy:1;     // 1: immediately BA    0:delayed BA
772     USHORT      AMSDUSupported:1;       // 0: not permitted             1: permitted
773 #else
774     USHORT      AMSDUSupported:1;       // 0: not permitted             1: permitted
775     USHORT      BAPolicy:1;     // 1: immediately BA    0:delayed BA
776     USHORT      TID:4;  // value of TC os TS
777     USHORT      BufSize:10;     // number of buffe of size 2304 octetsr
778 #endif /* !RT_BIG_ENDIAN */
779 } BA_PARM, *PBA_PARM;
780
781 // 2-byte BA Starting Seq CONTROL field
782 typedef union PACKED {
783     struct PACKED {
784 #ifdef RT_BIG_ENDIAN
785     USHORT      StartSeq:12;   // sequence number of the 1st MSDU for which this BAR is sent
786         USHORT      FragNum:4;  // always set to 0
787 #else
788     USHORT      FragNum:4;      // always set to 0
789         USHORT      StartSeq:12;   // sequence number of the 1st MSDU for which this BAR is sent
790 #endif /* RT_BIG_ENDIAN */
791     }   field;
792     USHORT           word;
793 } BASEQ_CONTROL, *PBASEQ_CONTROL;
794
795 //BAControl and BARControl are the same
796 // 2-byte BA CONTROL field in BA frame
797 typedef struct PACKED {
798 #ifdef RT_BIG_ENDIAN
799     USHORT      TID:4;
800     USHORT      Rsv:9;
801     USHORT      Compressed:1;
802     USHORT      MTID:1;         //EWC V1.24
803     USHORT      ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK  1:No ACK
804 #else
805     USHORT      ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK  1:No ACK
806     USHORT      MTID:1;         //EWC V1.24
807     USHORT      Compressed:1;
808     USHORT      Rsv:9;
809     USHORT      TID:4;
810 #endif /* !RT_BIG_ENDIAN */
811 } BA_CONTROL, *PBA_CONTROL;
812
813 // 2-byte BAR CONTROL field in BAR frame
814 typedef struct PACKED {
815 #ifdef RT_BIG_ENDIAN
816     USHORT      TID:4;
817     USHORT      Rsv1:9;
818     USHORT      Compressed:1;
819     USHORT      MTID:1;         //if this bit1, use  FRAME_MTBA_REQ,  if 0, use FRAME_BA_REQ
820     USHORT      ACKPolicy:1;
821 #else
822     USHORT      ACKPolicy:1; // 0:normal ack,  1:no ack.
823     USHORT      MTID:1;         //if this bit1, use  FRAME_MTBA_REQ,  if 0, use FRAME_BA_REQ
824     USHORT      Compressed:1;
825     USHORT      Rsv1:9;
826     USHORT      TID:4;
827 #endif /* !RT_BIG_ENDIAN */
828 } BAR_CONTROL, *PBAR_CONTROL;
829
830 // BARControl in MTBAR frame
831 typedef struct PACKED {
832 #ifdef RT_BIG_ENDIAN
833     USHORT      NumTID:4;
834     USHORT      Rsv1:9;
835     USHORT      Compressed:1;
836     USHORT      MTID:1;
837     USHORT      ACKPolicy:1;
838 #else
839     USHORT      ACKPolicy:1;
840     USHORT      MTID:1;
841     USHORT      Compressed:1;
842     USHORT      Rsv1:9;
843     USHORT      NumTID:4;
844 #endif /* !RT_BIG_ENDIAN */
845 } MTBAR_CONTROL, *PMTBAR_CONTROL;
846
847 typedef struct PACKED {
848 #ifdef RT_BIG_ENDIAN
849     USHORT      TID:4;
850     USHORT      Rsv1:12;
851 #else
852     USHORT      Rsv1:12;
853     USHORT      TID:4;
854 #endif /* !RT_BIG_ENDIAN */
855 } PER_TID_INFO, *PPER_TID_INFO;
856
857 typedef struct {
858         PER_TID_INFO      PerTID;
859         BASEQ_CONTROL    BAStartingSeq;
860 } EACH_TID, *PEACH_TID;
861
862
863 typedef struct PACKED _PSPOLL_FRAME {
864     FRAME_CONTROL   FC;
865     USHORT          Aid;
866     UCHAR           Bssid[MAC_ADDR_LEN];
867     UCHAR           Ta[MAC_ADDR_LEN];
868 }   PSPOLL_FRAME, *PPSPOLL_FRAME;
869
870 typedef struct  PACKED _RTS_FRAME       {
871     FRAME_CONTROL   FC;
872     USHORT          Duration;
873     UCHAR           Addr1[MAC_ADDR_LEN];
874     UCHAR           Addr2[MAC_ADDR_LEN];
875 }RTS_FRAME, *PRTS_FRAME;
876
877 // BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
878 typedef struct PACKED _FRAME_BA_REQ {
879         FRAME_CONTROL   FC;
880         USHORT          Duration;
881         UCHAR           Addr1[MAC_ADDR_LEN];
882         UCHAR           Addr2[MAC_ADDR_LEN];
883         BAR_CONTROL  BARControl;
884         BASEQ_CONTROL    BAStartingSeq;
885 }   FRAME_BA_REQ, *PFRAME_BA_REQ;
886
887 typedef struct PACKED _FRAME_MTBA_REQ {
888         FRAME_CONTROL   FC;
889         USHORT          Duration;
890         UCHAR           Addr1[MAC_ADDR_LEN];
891         UCHAR           Addr2[MAC_ADDR_LEN];
892         MTBAR_CONTROL  MTBARControl;
893         PER_TID_INFO    PerTIDInfo;
894         BASEQ_CONTROL    BAStartingSeq;
895 }   FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
896
897 // Compressed format is mandantory in HT STA
898 typedef struct PACKED _FRAME_MTBA {
899         FRAME_CONTROL   FC;
900         USHORT          Duration;
901         UCHAR           Addr1[MAC_ADDR_LEN];
902         UCHAR           Addr2[MAC_ADDR_LEN];
903         BA_CONTROL  BAControl;
904         BASEQ_CONTROL    BAStartingSeq;
905         UCHAR           BitMap[8];
906 }   FRAME_MTBA, *PFRAME_MTBA;
907
908 typedef struct PACKED _FRAME_PSMP_ACTION {
909         HEADER_802_11   Hdr;
910         UCHAR   Category;
911         UCHAR   Action;
912         UCHAR   Psmp;   // 7.3.1.25
913 }   FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
914
915 typedef struct PACKED _FRAME_ACTION_HDR {
916         HEADER_802_11   Hdr;
917         UCHAR   Category;
918         UCHAR   Action;
919 }   FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
920
921 //Action Frame
922 //Action Frame  Category:Spectrum,  Action:Channel Switch. 7.3.2.20
923 typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
924         UCHAR                                   ElementID;      // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
925         UCHAR                                   Len;
926         CHA_SWITCH_ANNOUNCE_IE  CSAnnounceIe;
927 }   CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
928
929
930 //802.11n : 7.3.2.20a
931 typedef struct PACKED _SECOND_CHAN_OFFSET {
932         UCHAR                           ElementID;              // ID = IE_SECONDARY_CH_OFFSET = 62
933         UCHAR                           Len;
934         SEC_CHA_OFFSET_IE       SecChOffsetIe;
935 }   SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
936
937
938 typedef struct PACKED _FRAME_SPETRUM_CS {
939         HEADER_802_11   Hdr;
940         UCHAR   Category;
941         UCHAR   Action;
942         CHAN_SWITCH_ANNOUNCE    CSAnnounce;
943         SECOND_CHAN_OFFSET              SecondChannel;
944 }   FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
945
946
947 typedef struct PACKED _FRAME_ADDBA_REQ {
948         HEADER_802_11   Hdr;
949         UCHAR   Category;
950         UCHAR   Action;
951         UCHAR   Token;  // 1
952         BA_PARM         BaParm;       //  2 - 10
953         USHORT          TimeOutValue;   // 0 - 0
954         BASEQ_CONTROL   BaStartSeq; // 0-0
955 }   FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
956
957 typedef struct PACKED _FRAME_ADDBA_RSP {
958         HEADER_802_11   Hdr;
959         UCHAR   Category;
960         UCHAR   Action;
961         UCHAR   Token;
962         USHORT  StatusCode;
963         BA_PARM         BaParm; //0 - 2
964         USHORT          TimeOutValue;
965 }   FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
966
967 typedef struct PACKED _FRAME_DELBA_REQ {
968         HEADER_802_11   Hdr;
969         UCHAR   Category;
970         UCHAR   Action;
971         DELBA_PARM              DelbaParm;
972         USHORT  ReasonCode;
973 }   FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
974
975
976 //7.2.1.7
977 typedef struct PACKED _FRAME_BAR {
978         FRAME_CONTROL   FC;
979         USHORT          Duration;
980         UCHAR           Addr1[MAC_ADDR_LEN];
981         UCHAR           Addr2[MAC_ADDR_LEN];
982         BAR_CONTROL             BarControl;
983         BASEQ_CONTROL   StartingSeq;
984 }   FRAME_BAR, *PFRAME_BAR;
985
986 //7.2.1.7
987 typedef struct PACKED _FRAME_BA {
988         FRAME_CONTROL   FC;
989         USHORT          Duration;
990         UCHAR           Addr1[MAC_ADDR_LEN];
991         UCHAR           Addr2[MAC_ADDR_LEN];
992         BAR_CONTROL             BarControl;
993         BASEQ_CONTROL   StartingSeq;
994         UCHAR           bitmask[8];
995 }   FRAME_BA, *PFRAME_BA;
996
997
998 // Radio Measuement Request Frame Format
999 typedef struct PACKED _FRAME_RM_REQ_ACTION {
1000         HEADER_802_11   Hdr;
1001         UCHAR   Category;
1002         UCHAR   Action;
1003         UCHAR   Token;
1004         USHORT  Repetition;
1005         UCHAR   data[0];
1006 }   FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
1007
1008 typedef struct PACKED {
1009         UCHAR           ID;
1010         UCHAR           Length;
1011         UCHAR           ChannelSwitchMode;
1012         UCHAR           NewRegClass;
1013         UCHAR           NewChannelNum;
1014         UCHAR           ChannelSwitchCount;
1015 } HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
1016
1017
1018 //
1019 // _Limit must be the 2**n - 1
1020 // _SEQ1 , _SEQ2 must be within 0 ~ _Limit
1021 //
1022 #define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit)       ((_SEQ1 == ((_SEQ2+1) & _Limit)))
1023 #define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit)       (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
1024 #define SEQ_LARGER(_SEQ1, _SEQ2, _Limit)        ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
1025 #define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) &&  \
1026                                                                                                 SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
1027
1028 //
1029 // Contention-free parameter (without ID and Length)
1030 //
1031 typedef struct PACKED {
1032     BOOLEAN     bValid;         // 1: variable contains valid value
1033     UCHAR       CfpCount;
1034     UCHAR       CfpPeriod;
1035     USHORT      CfpMaxDuration;
1036     USHORT      CfpDurRemaining;
1037 } CF_PARM, *PCF_PARM;
1038
1039 typedef struct  _CIPHER_SUITE   {
1040         NDIS_802_11_ENCRYPTION_STATUS   PairCipher;             // Unicast cipher 1, this one has more secured cipher suite
1041         NDIS_802_11_ENCRYPTION_STATUS   PairCipherAux;  // Unicast cipher 2 if AP announce two unicast cipher suite
1042         NDIS_802_11_ENCRYPTION_STATUS   GroupCipher;    // Group cipher
1043         USHORT                                                  RsnCapability;  // RSN capability from beacon
1044         BOOLEAN                                                 bMixMode;               // Indicate Pair & Group cipher might be different
1045 }       CIPHER_SUITE, *PCIPHER_SUITE;
1046
1047 // EDCA configuration from AP's BEACON/ProbeRsp
1048 typedef struct {
1049     BOOLEAN     bValid;         // 1: variable contains valid value
1050     BOOLEAN     bAdd;         // 1: variable contains valid value
1051     BOOLEAN     bQAck;
1052     BOOLEAN     bQueueRequest;
1053     BOOLEAN     bTxopRequest;
1054     BOOLEAN     bAPSDCapable;
1055 //  BOOLEAN     bMoreDataAck;
1056     UCHAR       EdcaUpdateCount;
1057     UCHAR       Aifsn[4];       // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
1058     UCHAR       Cwmin[4];
1059     UCHAR       Cwmax[4];
1060     USHORT      Txop[4];      // in unit of 32-us
1061     BOOLEAN     bACM[4];      // 1: Admission Control of AC_BK is mandattory
1062 } EDCA_PARM, *PEDCA_PARM;
1063
1064 // QBSS LOAD information from QAP's BEACON/ProbeRsp
1065 typedef struct {
1066     BOOLEAN     bValid;                     // 1: variable contains valid value
1067     USHORT      StaNum;
1068     UCHAR       ChannelUtilization;
1069     USHORT      RemainingAdmissionControl;  // in unit of 32-us
1070 } QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
1071
1072 // QBSS Info field in QSTA's assoc req
1073 typedef struct PACKED {
1074 #ifdef RT_BIG_ENDIAN
1075         UCHAR           Rsv2:1;
1076         UCHAR           MaxSPLength:2;
1077         UCHAR           Rsv1:1;
1078         UCHAR           UAPSD_AC_BE:1;
1079         UCHAR           UAPSD_AC_BK:1;
1080         UCHAR           UAPSD_AC_VI:1;
1081         UCHAR           UAPSD_AC_VO:1;
1082 #else
1083     UCHAR               UAPSD_AC_VO:1;
1084         UCHAR           UAPSD_AC_VI:1;
1085         UCHAR           UAPSD_AC_BK:1;
1086         UCHAR           UAPSD_AC_BE:1;
1087         UCHAR           Rsv1:1;
1088         UCHAR           MaxSPLength:2;
1089         UCHAR           Rsv2:1;
1090 #endif /* !RT_BIG_ENDIAN */
1091 } QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
1092
1093 // QBSS Info field in QAP's Beacon/ProbeRsp
1094 typedef struct PACKED {
1095 #ifdef RT_BIG_ENDIAN
1096         UCHAR           UAPSD:1;
1097         UCHAR           Rsv:3;
1098     UCHAR               ParamSetCount:4;
1099 #else
1100     UCHAR               ParamSetCount:4;
1101         UCHAR           Rsv:3;
1102         UCHAR           UAPSD:1;
1103 #endif /* !RT_BIG_ENDIAN */
1104 } QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
1105
1106 // QOS Capability reported in QAP's BEACON/ProbeRsp
1107 // QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
1108 typedef struct {
1109     BOOLEAN     bValid;                     // 1: variable contains valid value
1110     BOOLEAN     bQAck;
1111     BOOLEAN     bQueueRequest;
1112     BOOLEAN     bTxopRequest;
1113 //  BOOLEAN     bMoreDataAck;
1114     UCHAR       EdcaUpdateCount;
1115 } QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
1116
1117 #ifdef CONFIG_STA_SUPPORT
1118 typedef struct {
1119     UCHAR       IELen;
1120     UCHAR       IE[MAX_CUSTOM_LEN];
1121 } WPA_IE_;
1122 #endif // CONFIG_STA_SUPPORT //
1123
1124
1125 typedef struct {
1126     UCHAR   Bssid[MAC_ADDR_LEN];
1127     UCHAR   Channel;
1128         UCHAR   CentralChannel; //Store the wide-band central channel for 40MHz.  .used in 40MHz AP. Or this is the same as Channel.
1129     UCHAR   BssType;
1130     USHORT  AtimWin;
1131     USHORT  BeaconPeriod;
1132
1133     UCHAR   SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1134     UCHAR   SupRateLen;
1135     UCHAR   ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1136     UCHAR   ExtRateLen;
1137         HT_CAPABILITY_IE HtCapability;
1138         UCHAR                   HtCapabilityLen;
1139         ADD_HT_INFO_IE AddHtInfo;       // AP might use this additional ht info IE
1140         UCHAR                   AddHtInfoLen;
1141         UCHAR                   NewExtChanOffset;
1142         CHAR    Rssi;
1143     UCHAR   Privacy;                    // Indicate security function ON/OFF. Don't mess up with auth mode.
1144         UCHAR   Hidden;
1145
1146     USHORT  DtimPeriod;
1147     USHORT  CapabilityInfo;
1148
1149     USHORT  CfpCount;
1150     USHORT  CfpPeriod;
1151     USHORT  CfpMaxDuration;
1152     USHORT  CfpDurRemaining;
1153     UCHAR   SsidLen;
1154     CHAR    Ssid[MAX_LEN_OF_SSID];
1155
1156     ULONG   LastBeaconRxTime; // OS's timestamp
1157
1158         BOOLEAN bSES;
1159
1160         // New for WPA2
1161         CIPHER_SUITE                                    WPA;                    // AP announced WPA cipher suite
1162         CIPHER_SUITE                                    WPA2;                   // AP announced WPA2 cipher suite
1163
1164         // New for microsoft WPA support
1165         NDIS_802_11_FIXED_IEs   FixIEs;
1166         NDIS_802_11_AUTHENTICATION_MODE AuthModeAux;    // Addition mode for WPA2 / WPA capable AP
1167         NDIS_802_11_AUTHENTICATION_MODE AuthMode;
1168         NDIS_802_11_WEP_STATUS  WepStatus;                              // Unicast Encryption Algorithm extract from VAR_IE
1169         USHORT                                  VarIELen;                               // Length of next VIE include EID & Length
1170         UCHAR                                   VarIEs[MAX_VIE_LEN];
1171
1172         // CCX Ckip information
1173     UCHAR   CkipFlag;
1174
1175         // CCX 2 TSF
1176         UCHAR   PTSF[4];                // Parent TSF
1177         UCHAR   TTSF[8];                // Target TSF
1178
1179     // 802.11e d9, and WMM
1180         EDCA_PARM           EdcaParm;
1181         QOS_CAPABILITY_PARM QosCapability;
1182         QBSS_LOAD_PARM      QbssLoad;
1183 #ifdef CONFIG_STA_SUPPORT
1184     WPA_IE_     WpaIE;
1185     WPA_IE_     RsnIE;
1186 #ifdef EXT_BUILD_CHANNEL_LIST
1187         UCHAR           CountryString[3];
1188         BOOLEAN         bHasCountryIE;
1189 #endif // EXT_BUILD_CHANNEL_LIST //
1190 #endif // CONFIG_STA_SUPPORT //
1191 } BSS_ENTRY, *PBSS_ENTRY;
1192
1193 typedef struct {
1194     UCHAR           BssNr;
1195     UCHAR           BssOverlapNr;
1196     BSS_ENTRY       BssEntry[MAX_LEN_OF_BSS_TABLE];
1197 } BSS_TABLE, *PBSS_TABLE;
1198
1199
1200 typedef struct _MLME_QUEUE_ELEM {
1201     ULONG             Machine;
1202     ULONG             MsgType;
1203     ULONG             MsgLen;
1204     UCHAR             Msg[MGMT_DMA_BUFFER_SIZE];
1205     LARGE_INTEGER     TimeStamp;
1206     UCHAR             Rssi0;
1207     UCHAR             Rssi1;
1208     UCHAR             Rssi2;
1209     UCHAR             Signal;
1210     UCHAR             Channel;
1211     UCHAR             Wcid;
1212     BOOLEAN           Occupied;
1213 #ifdef MLME_EX
1214         USHORT            Idx;
1215 #endif // MLME_EX //
1216 } MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
1217
1218 typedef struct _MLME_QUEUE {
1219     ULONG             Num;
1220     ULONG             Head;
1221     ULONG             Tail;
1222     NDIS_SPIN_LOCK   Lock;
1223     MLME_QUEUE_ELEM  Entry[MAX_LEN_OF_MLME_QUEUE];
1224 } MLME_QUEUE, *PMLME_QUEUE;
1225
1226 typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
1227
1228 typedef struct _STATE_MACHINE {
1229     ULONG                           Base;
1230     ULONG                           NrState;
1231     ULONG                           NrMsg;
1232     ULONG                           CurrState;
1233     STATE_MACHINE_FUNC             *TransFunc;
1234 } STATE_MACHINE, *PSTATE_MACHINE;
1235
1236
1237 // MLME AUX data structure that hold temporarliy settings during a connection attempt.
1238 // Once this attemp succeeds, all settings will be copy to pAd->StaActive.
1239 // A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
1240 // several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
1241 // separate this under-trial settings away from pAd->StaActive so that once
1242 // this new attempt failed, driver can auto-recover back to the active settings.
1243 typedef struct _MLME_AUX {
1244     UCHAR               BssType;
1245     UCHAR               Ssid[MAX_LEN_OF_SSID];
1246     UCHAR               SsidLen;
1247     UCHAR               Bssid[MAC_ADDR_LEN];
1248         UCHAR                           AutoReconnectSsid[MAX_LEN_OF_SSID];
1249         UCHAR                           AutoReconnectSsidLen;
1250     USHORT              Alg;
1251     UCHAR               ScanType;
1252     UCHAR               Channel;
1253         UCHAR               CentralChannel;
1254     USHORT              Aid;
1255     USHORT              CapabilityInfo;
1256     USHORT              BeaconPeriod;
1257     USHORT              CfpMaxDuration;
1258     USHORT              CfpPeriod;
1259     USHORT              AtimWin;
1260
1261         // Copy supported rate from desired AP's beacon. We are trying to match
1262         // AP's supported and extended rate settings.
1263         UCHAR                   SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1264         UCHAR                   ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1265         UCHAR                   SupRateLen;
1266         UCHAR                   ExtRateLen;
1267         HT_CAPABILITY_IE                HtCapability;
1268         UCHAR                           HtCapabilityLen;
1269         ADD_HT_INFO_IE          AddHtInfo;      // AP might use this additional ht info IE
1270         UCHAR                   NewExtChannelOffset;
1271         //RT_HT_CAPABILITY      SupportedHtPhy;
1272
1273     // new for QOS
1274     QOS_CAPABILITY_PARM APQosCapability;    // QOS capability of the current associated AP
1275     EDCA_PARM           APEdcaParm;         // EDCA parameters of the current associated AP
1276     QBSS_LOAD_PARM      APQbssLoad;         // QBSS load of the current associated AP
1277
1278     // new to keep Ralink specific feature
1279     ULONG               APRalinkIe;
1280
1281     BSS_TABLE           SsidBssTab;     // AP list for the same SSID
1282     BSS_TABLE           RoamTab;        // AP list eligible for roaming
1283     ULONG               BssIdx;
1284     ULONG               RoamIdx;
1285
1286         BOOLEAN                         CurrReqIsFromNdis;
1287
1288     RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
1289     RALINK_TIMER_STRUCT AuthTimer;
1290     RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
1291 } MLME_AUX, *PMLME_AUX;
1292
1293 typedef struct _MLME_ADDBA_REQ_STRUCT{
1294         UCHAR   Wcid;   //
1295         UCHAR   pAddr[MAC_ADDR_LEN];
1296         UCHAR   BaBufSize;
1297         USHORT  TimeOutValue;
1298         UCHAR   TID;
1299         UCHAR   Token;
1300         USHORT  BaStartSeq;
1301 } MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
1302
1303
1304 typedef struct _MLME_DELBA_REQ_STRUCT{
1305         UCHAR   Wcid;   //
1306         UCHAR     Addr[MAC_ADDR_LEN];
1307         UCHAR   TID;
1308         UCHAR   Initiator;
1309 } MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
1310
1311 // assoc struct is equal to reassoc
1312 typedef struct _MLME_ASSOC_REQ_STRUCT{
1313     UCHAR     Addr[MAC_ADDR_LEN];
1314     USHORT    CapabilityInfo;
1315     USHORT    ListenIntv;
1316     ULONG     Timeout;
1317 } MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
1318
1319 typedef struct _MLME_DISASSOC_REQ_STRUCT{
1320     UCHAR     Addr[MAC_ADDR_LEN];
1321     USHORT    Reason;
1322 } MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
1323
1324 typedef struct _MLME_AUTH_REQ_STRUCT {
1325     UCHAR        Addr[MAC_ADDR_LEN];
1326     USHORT       Alg;
1327     ULONG        Timeout;
1328 } MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
1329
1330 typedef struct _MLME_DEAUTH_REQ_STRUCT {
1331     UCHAR        Addr[MAC_ADDR_LEN];
1332     USHORT       Reason;
1333 } MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
1334
1335 typedef struct {
1336     ULONG      BssIdx;
1337 } MLME_JOIN_REQ_STRUCT;
1338
1339 typedef struct _MLME_SCAN_REQ_STRUCT {
1340     UCHAR      Bssid[MAC_ADDR_LEN];
1341     UCHAR      BssType;
1342     UCHAR      ScanType;
1343     UCHAR      SsidLen;
1344     CHAR       Ssid[MAX_LEN_OF_SSID];
1345 } MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
1346
1347 typedef struct _MLME_START_REQ_STRUCT {
1348     CHAR        Ssid[MAX_LEN_OF_SSID];
1349     UCHAR       SsidLen;
1350 } MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
1351
1352 #ifdef CONFIG_STA_SUPPORT
1353 #ifdef QOS_DLS_SUPPORT
1354 // structure for DLS
1355 typedef struct _RT_802_11_DLS {
1356         USHORT                                          TimeOut;                // Use to time out while slience, unit: second , set by UI
1357         USHORT                                          CountDownTimer; // Use to time out while slience,unit: second , used by driver only
1358         NDIS_802_11_MAC_ADDRESS         MacAddr;                // set by UI
1359         UCHAR                                           Status;                 // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
1360         BOOLEAN                                         Valid;                  // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
1361         RALINK_TIMER_STRUCT                     Timer;                  // Use to time out while handshake
1362         USHORT                                          Sequence;
1363         USHORT                                          MacTabMatchWCID;        // ASIC
1364         BOOLEAN                                         bHTCap;
1365         PVOID                                           pAd;
1366 } RT_802_11_DLS, *PRT_802_11_DLS;
1367
1368 typedef struct _MLME_DLS_REQ_STRUCT {
1369     PRT_802_11_DLS      pDLS;
1370     USHORT                      Reason;
1371 } MLME_DLS_REQ_STRUCT, *PMLME_DLS_REQ_STRUCT;
1372 #endif // QOS_DLS_SUPPORT //
1373 #endif // CONFIG_STA_SUPPORT //
1374
1375 typedef struct PACKED {
1376     UCHAR   Eid;
1377     UCHAR   Len;
1378     CHAR   Octet[1];
1379 } EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
1380
1381 typedef struct PACKED _RTMP_TX_RATE_SWITCH
1382 {
1383         UCHAR   ItemNo;
1384 #ifdef RT_BIG_ENDIAN
1385         UCHAR   Rsv2:2;
1386         UCHAR   Mode:2;
1387         UCHAR   Rsv1:1;
1388         UCHAR   BW:1;
1389         UCHAR   ShortGI:1;
1390         UCHAR   STBC:1;
1391 #else
1392         UCHAR   STBC:1;
1393         UCHAR   ShortGI:1;
1394         UCHAR   BW:1;
1395         UCHAR   Rsv1:1;
1396         UCHAR   Mode:2;
1397         UCHAR   Rsv2:2;
1398 #endif
1399         UCHAR   CurrMCS;
1400         UCHAR   TrainUp;
1401         UCHAR   TrainDown;
1402 } RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
1403
1404 // ========================== AP mlme.h ===============================
1405 #define TBTT_PRELOAD_TIME       384        // usec. LomgPreamble + 24-byte at 1Mbps
1406 #define DEFAULT_DTIM_PERIOD     1
1407
1408 // weighting factor to calculate Channel quality, total should be 100%
1409 //#define RSSI_WEIGHTING                   0
1410 //#define TX_WEIGHTING                     40
1411 //#define RX_WEIGHTING                     60
1412
1413 #define MAC_TABLE_AGEOUT_TIME                   300                     // unit: sec
1414 #define MAC_TABLE_ASSOC_TIMEOUT                 5                       // unit: sec
1415 #define MAC_TABLE_FULL(Tab)                             ((Tab).size == MAX_LEN_OF_MAC_TABLE)
1416
1417 // AP shall drop the sta if contine Tx fail count reach it.
1418 #define MAC_ENTRY_LIFE_CHECK_CNT                20                      // packet cnt.
1419
1420 // Value domain of pMacEntry->Sst
1421 typedef enum _Sst {
1422     SST_NOT_AUTH,   // 0: equivalent to IEEE 802.11/1999 state 1
1423     SST_AUTH,       // 1: equivalent to IEEE 802.11/1999 state 2
1424     SST_ASSOC       // 2: equivalent to IEEE 802.11/1999 state 3
1425 } SST;
1426
1427 // value domain of pMacEntry->AuthState
1428 typedef enum _AuthState {
1429     AS_NOT_AUTH,
1430     AS_AUTH_OPEN,       // STA has been authenticated using OPEN SYSTEM
1431     AS_AUTH_KEY,        // STA has been authenticated using SHARED KEY
1432     AS_AUTHENTICATING   // STA is waiting for AUTH seq#3 using SHARED KEY
1433 } AUTH_STATE;
1434
1435 //for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114
1436 typedef enum _ApWpaState {
1437     AS_NOTUSE,              // 0
1438     AS_DISCONNECT,          // 1
1439     AS_DISCONNECTED,        // 2
1440     AS_INITIALIZE,          // 3
1441     AS_AUTHENTICATION,      // 4
1442     AS_AUTHENTICATION2,     // 5
1443     AS_INITPMK,             // 6
1444     AS_INITPSK,             // 7
1445     AS_PTKSTART,            // 8
1446     AS_PTKINIT_NEGOTIATING, // 9
1447     AS_PTKINITDONE,         // 10
1448     AS_UPDATEKEYS,          // 11
1449     AS_INTEGRITY_FAILURE,   // 12
1450     AS_KEYUPDATE,           // 13
1451 } AP_WPA_STATE;
1452
1453 // for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114
1454 typedef enum _GTKState {
1455     REKEY_NEGOTIATING,
1456     REKEY_ESTABLISHED,
1457     KEYERROR,
1458 } GTK_STATE;
1459
1460 //  for-wpa  value domain of pMacEntry->WpaState  802.1i D3   p.114
1461 typedef enum _WpaGTKState {
1462     SETKEYS,
1463     SETKEYS_DONE,
1464 } WPA_GTK_STATE;
1465 // ====================== end of AP mlme.h ============================
1466
1467
1468 #endif  // MLME_H__