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