Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm
[cascardo/linux.git] / drivers / staging / rtl8192su / ieee80211 / rtl819x_HT.h
1 /******************************************************************************
2  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3  *
4  * This program is distributed in the hope that it will be useful, but WITHOUT
5  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
7  * more details.
8  *
9  * You should have received a copy of the GNU General Public License along with
10  * this program; if not, write to the Free Software Foundation, Inc.,
11  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
12  *
13  * The full GNU General Public License is included in this distribution in the
14  * file called LICENSE.
15  *
16  * Contact Information:
17  * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #ifndef _RTL819XU_HTTYPE_H_
20 #define _RTL819XU_HTTYPE_H_
21
22 //------------------------------------------------------------
23 // The HT Capability element is present in beacons, association request,
24 //      reassociation request and probe response frames
25 //------------------------------------------------------------
26
27 //
28 // Operation mode value
29 //
30 #define HT_OPMODE_NO_PROTECT            0
31 #define HT_OPMODE_OPTIONAL              1
32 #define HT_OPMODE_40MHZ_PROTECT 2
33 #define HT_OPMODE_MIXED                 3
34
35 //
36 // MIMO Power Save Setings
37 //
38 #define MIMO_PS_STATIC                          0
39 #define MIMO_PS_DYNAMIC                 1
40 #define MIMO_PS_NOLIMIT                 3
41
42
43 //
44 //      There should be 128 bits to cover all of the MCS rates. However, since
45 //      8190 does not support too much rates, one integer is quite enough.
46 //
47
48 #define sHTCLng 4
49
50
51 #define HT_SUPPORTED_MCS_1SS_BITMAP                                     0x000000ff
52 #define HT_SUPPORTED_MCS_2SS_BITMAP                                     0x0000ff00
53 #define HT_SUPPORTED_MCS_1SS_2SS_BITMAP                 HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
54
55
56 typedef enum _HT_MCS_RATE{
57         HT_MCS0   = 0x00000001,
58         HT_MCS1   = 0x00000002,
59         HT_MCS2   = 0x00000004,
60         HT_MCS3   = 0x00000008,
61         HT_MCS4   = 0x00000010,
62         HT_MCS5   = 0x00000020,
63         HT_MCS6   = 0x00000040,
64         HT_MCS7   = 0x00000080,
65         HT_MCS8   = 0x00000100,
66         HT_MCS9   = 0x00000200,
67         HT_MCS10 = 0x00000400,
68         HT_MCS11 = 0x00000800,
69         HT_MCS12 = 0x00001000,
70         HT_MCS13 = 0x00002000,
71         HT_MCS14 = 0x00004000,
72         HT_MCS15 = 0x00008000,
73         // Do not define MCS32 here although 8190 support MCS32
74 }HT_MCS_RATE,*PHT_MCS_RATE;
75
76 //
77 // Represent Channel Width in HT Capabilities
78 //
79 typedef enum _HT_CHANNEL_WIDTH{
80         HT_CHANNEL_WIDTH_20 = 0,
81         HT_CHANNEL_WIDTH_20_40 = 1,
82 }HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH;
83
84 //
85 // Represent Extention Channel Offset in HT Capabilities
86 // This is available only in 40Mhz mode.
87 //
88 typedef enum _HT_EXTCHNL_OFFSET{
89         HT_EXTCHNL_OFFSET_NO_EXT = 0,
90         HT_EXTCHNL_OFFSET_UPPER = 1,
91         HT_EXTCHNL_OFFSET_NO_DEF = 2,
92         HT_EXTCHNL_OFFSET_LOWER = 3,
93 }HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET;
94
95 typedef enum _CHNLOP{
96         CHNLOP_NONE = 0, // No Action now
97         CHNLOP_SCAN = 1, // Scan in progress
98         CHNLOP_SWBW = 2, // Bandwidth switching in progress
99         CHNLOP_SWCHNL = 3, // Software Channel switching in progress
100 } CHNLOP, *PCHNLOP;
101
102 // Determine if the Channel Operation is in progress
103 #define CHHLOP_IN_PROGRESS(_pHTInfo)    \
104                 ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
105
106 /*
107 typedef union _HT_CAPABILITY{
108         u16     ShortData;
109         u8      CharData[2];
110         struct
111         {
112                 u16     AdvCoding:1;
113                 u16     ChlWidth:1;
114                 u16     MimoPwrSave:2;
115                 u16     GreenField:1;
116                 u16     ShortGI20Mhz:1;
117                 u16     ShortGI40Mhz:1;
118                 u16     STBC:1;
119                 u16     BeamForm:1;
120                 u16     DelayBA:1;
121                 u16     MaxAMSDUSize:1;
122                 u16     DssCCk:1;
123                 u16     PSMP:1;
124                 u16     Rsvd:3;
125         }Field;
126 }HT_CAPABILITY, *PHT_CAPABILITY;
127
128 typedef union _HT_CAPABILITY_MACPARA{
129         u8      ShortData;
130         u8      CharData[1];
131         struct
132         {
133                 u8      MaxRxAMPDU:2;
134                 u8      MPDUDensity:2;
135                 u8      Rsvd:4;
136         }Field;
137 }HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
138 */
139
140 typedef enum _HT_ACTION{
141         ACT_RECOMMAND_WIDTH             = 0,
142         ACT_MIMO_PWR_SAVE               = 1,
143         ACT_PSMP                                        = 2,
144         ACT_SET_PCO_PHASE               = 3,
145         ACT_MIMO_CHL_MEASURE    = 4,
146         ACT_RECIPROCITY_CORRECT = 5,
147         ACT_MIMO_CSI_MATRICS            = 6,
148         ACT_MIMO_NOCOMPR_STEER  = 7,
149         ACT_MIMO_COMPR_STEER            = 8,
150         ACT_ANTENNA_SELECT              = 9,
151 } HT_ACTION, *PHT_ACTION;
152
153
154 /* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */
155 typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{
156         SC_MODE_DUPLICATE = 0,
157         SC_MODE_LOWER = 1,
158         SC_MODE_UPPER = 2,
159         SC_MODE_FULL40MHZ = 3,
160 }HT_BW40_SC_E;
161
162 typedef struct _HT_CAPABILITY_ELE{
163
164         //HT capability info
165         u8      AdvCoding:1;
166         u8      ChlWidth:1;
167         u8      MimoPwrSave:2;
168         u8      GreenField:1;
169         u8      ShortGI20Mhz:1;
170         u8      ShortGI40Mhz:1;
171         u8      TxSTBC:1;
172         u8      RxSTBC:2;
173         u8      DelayBA:1;
174         u8      MaxAMSDUSize:1;
175         u8      DssCCk:1;
176         u8      PSMP:1;
177         u8      Rsvd1:1;
178         u8      LSigTxopProtect:1;
179
180         //MAC HT parameters info
181         u8      MaxRxAMPDUFactor:2;
182         u8      MPDUDensity:3;
183         u8      Rsvd2:3;
184
185         //Supported MCS set
186         u8      MCS[16];
187
188
189         //Extended HT Capability Info
190         u16     ExtHTCapInfo;
191
192         //TXBF Capabilities
193         u8      TxBFCap[4];
194
195         //Antenna Selection Capabilities
196         u8      ASCap;
197
198 } __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
199
200 //------------------------------------------------------------
201 // The HT Information element is present in beacons
202 // Only AP is required to include this element
203 //------------------------------------------------------------
204
205 typedef struct _HT_INFORMATION_ELE{
206         u8      ControlChl;
207
208         u8      ExtChlOffset:2;
209         u8      RecommemdedTxWidth:1;
210         u8      RIFS:1;
211         u8      PSMPAccessOnly:1;
212         u8      SrvIntGranularity:3;
213
214         u8      OptMode:2;
215         u8      NonGFDevPresent:1;
216         u8      Revd1:5;
217         u8      Revd2:8;
218
219         u8      Rsvd3:6;
220         u8      DualBeacon:1;
221         u8      DualCTSProtect:1;
222
223         u8      SecondaryBeacon:1;
224         u8      LSigTxopProtectFull:1;
225         u8      PcoActive:1;
226         u8      PcoPhase:1;
227         u8      Rsvd4:4;
228
229         u8      BasicMSC[16];
230 } __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
231
232 //
233 // MIMO Power Save control field.
234 // This is appear in MIMO Power Save Action Frame
235 //
236 typedef struct _MIMOPS_CTRL{
237         u8      MimoPsEnable:1;
238         u8      MimoPsMode:1;
239         u8      Reserved:6;
240 } MIMOPS_CTRL, *PMIMOPS_CTRL;
241
242 typedef enum _HT_SPEC_VER{
243         HT_SPEC_VER_IEEE = 0,
244         HT_SPEC_VER_EWC = 1,
245 }HT_SPEC_VER, *PHT_SPEC_VER;
246
247 typedef enum _HT_AGGRE_MODE_E{
248         HT_AGG_AUTO = 0,
249         HT_AGG_FORCE_ENABLE = 1,
250         HT_AGG_FORCE_DISABLE = 2,
251 }HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
252
253 //------------------------------------------------------------
254 //  The Data structure is used to keep HT related variables when card is
255 //  configured as non-AP STA mode.  **Note**  Current_xxx should be set
256 //      to default value in HTInitializeHTInfo()
257 //------------------------------------------------------------
258
259 typedef struct _RT_HIGH_THROUGHPUT{
260         u8                              bEnableHT;
261         u8                              bCurrentHTSupport;
262
263         u8                              bRegBW40MHz;                            // Tx 40MHz channel capablity
264         u8                              bCurBW40MHz;                            // Tx 40MHz channel capability
265
266         u8                              bRegShortGI40MHz;                       // Tx Short GI for 40Mhz
267         u8                              bCurShortGI40MHz;                       // Tx Short GI for 40MHz
268
269         u8                              bRegShortGI20MHz;                       // Tx Short GI for 20MHz
270         u8                              bCurShortGI20MHz;                       // Tx Short GI for 20MHz
271
272         u8                              bRegSuppCCK;                            // Tx CCK rate capability
273         u8                              bCurSuppCCK;                            // Tx CCK rate capability
274
275         // 802.11n spec version for "peer"
276         HT_SPEC_VER                     ePeerHTSpecVer;
277
278
279         // HT related information for "Self"
280         HT_CAPABILITY_ELE       SelfHTCap;              // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
281         HT_INFORMATION_ELE      SelfHTInfo;             // This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
282
283         // HT related information for "Peer"
284         u8                              PeerHTCapBuf[32];
285         u8                              PeerHTInfoBuf[32];
286
287
288         // A-MSDU related
289         u8                              bAMSDU_Support;                 // This indicates Tx A-MSDU capability
290         u16                             nAMSDU_MaxSize;                 // This indicates Tx A-MSDU capability
291         u8                              bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability
292         u16                             nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability
293
294
295         // AMPDU  related <2006.08.10 Emily>
296         u8                              bAMPDUEnable;                           // This indicate Tx A-MPDU capability
297         u8                              bCurrentAMPDUEnable;            // This indicate Tx A-MPDU capability
298         u8                              AMPDU_Factor;                           // This indicate Tx A-MPDU capability
299         u8                              CurrentAMPDUFactor;             // This indicate Tx A-MPDU capability
300         u8                              MPDU_Density;                           // This indicate Tx A-MPDU capability
301         u8                              CurrentMPDUDensity;                     // This indicate Tx A-MPDU capability
302
303         // Forced A-MPDU enable
304         HT_AGGRE_MODE_E ForcedAMPDUMode;
305         u8                              ForcedAMPDUFactor;
306         u8                              ForcedMPDUDensity;
307
308         // Forced A-MSDU enable
309         HT_AGGRE_MODE_E ForcedAMSDUMode;
310         u16                             ForcedAMSDUMaxSize;
311
312         u8                              bForcedShortGI;
313
314         u8                              CurrentOpMode;
315
316         // MIMO PS related
317         u8                              SelfMimoPs;
318         u8                              PeerMimoPs;
319
320         // 40MHz Channel Offset settings.
321         HT_EXTCHNL_OFFSET       CurSTAExtChnlOffset;
322         u8                              bCurTxBW40MHz;  // If we use 40 MHz to Tx
323         u8                              PeerBandwidth;
324
325         // For Bandwidth Switching
326         u8                              bSwBwInProgress;
327         CHNLOP                          ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
328         u8                              SwBwStep;
329         //struct timer_list             SwBwTimer;  //moved to ieee80211_device. as timer_list need include some header file here.
330
331         // For Realtek proprietary A-MPDU factor for aggregation
332         u8                              bRegRT2RTAggregation;
333         u8                              RT2RT_HT_Mode;
334         u8                              bCurrentRT2RTAggregation;
335         u8                              bCurrentRT2RTLongSlotTime;
336         u8                              szRT2RTAggBuffer[10];
337
338         // Rx Reorder control
339         u8                              bRegRxReorderEnable;
340         u8                              bCurRxReorderEnable;
341         u8                              RxReorderWinSize;
342         u8                              RxReorderPendingTime;
343         u16                             RxReorderDropCounter;
344
345
346         // Add for Broadcom(Linksys) IOT. Joseph
347         u8                              bIsPeerBcm;
348
349         // For IOT issue.
350         u8                              IOTPeer;
351         u32                             IOTAction;
352         u8                              IOTRaFunc;
353 } __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
354
355
356 //------------------------------------------------------------
357 // The Data structure is used to keep HT related variable for "each Sta"
358 // when card is configured as "AP mode"
359 //------------------------------------------------------------
360
361 typedef struct _RT_HTINFO_STA_ENTRY{
362         u8                      bEnableHT;
363
364         u8                      bSupportCck;
365
366         u16                     AMSDU_MaxSize;
367
368         u8                      AMPDU_Factor;
369         u8                      MPDU_Density;
370
371         u8                      HTHighestOperaRate;
372
373         u8                      bBw40MHz;
374
375         u8                      MimoPs;
376
377         u8                      McsRateSet[16];
378
379
380 }RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY;
381
382
383
384
385
386 //------------------------------------------------------------
387 // The Data structure is used to keep HT related variable for "each AP"
388 // when card is configured as "STA mode"
389 //------------------------------------------------------------
390
391 typedef struct _BSS_HT{
392
393         u8                              bdSupportHT;
394
395         // HT related elements
396         u8                                      bdHTCapBuf[32];
397         u16                                     bdHTCapLen;
398         u8                                      bdHTInfoBuf[32];
399         u16                                     bdHTInfoLen;
400
401         HT_SPEC_VER                             bdHTSpecVer;
402         HT_CHANNEL_WIDTH                        bdBandWidth;
403
404         u8                                      bdRT2RTAggregation;
405         u8                                      bdRT2RTLongSlotTime;
406         u8                                      RT2RT_HT_Mode;
407         bool                                    bdHT1R;
408 } __attribute__ ((packed)) BSS_HT, *PBSS_HT;
409
410 typedef struct _MIMO_RSSI{
411         u32     EnableAntenna;
412         u32     AntennaA;
413         u32     AntennaB;
414         u32     AntennaC;
415         u32     AntennaD;
416         u32     Average;
417 }MIMO_RSSI, *PMIMO_RSSI;
418
419 typedef struct _MIMO_EVM{
420         u32     EVM1;
421         u32    EVM2;
422 }MIMO_EVM, *PMIMO_EVM;
423
424 typedef struct _FALSE_ALARM_STATISTICS{
425         u32     Cnt_Parity_Fail;
426         u32     Cnt_Rate_Illegal;
427         u32     Cnt_Crc8_fail;
428         u32     Cnt_all;
429 }FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS;
430
431
432 extern u8 MCS_FILTER_ALL[16];
433 extern u8 MCS_FILTER_1SS[16];
434
435 /* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set
436    STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We have
437    to add a macro to judge wireless mode. */
438 #define PICK_RATE(_nLegacyRate, _nMcsRate)      \
439                 (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate)
440 /* 2007/07/12 MH We only define legacy and HT wireless mode now. */
441 #define LEGACY_WIRELESS_MODE    IEEE_MODE_MASK
442
443 #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate)  \
444                                         ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\
445                                                 (LegacyRate):\
446                                                 (PICK_RATE(LegacyRate, HTRate))
447
448
449
450 // MCS Bw 40 {1~7, 12~15,32}
451 #define RATE_ADPT_1SS_MASK              0xFF
452 #define RATE_ADPT_2SS_MASK              0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily
453 #define RATE_ADPT_MCS32_MASK            0x01
454
455 #define         IS_11N_MCS_RATE(rate)           (rate&0x80)
456
457 typedef enum _HT_AGGRE_SIZE{
458         HT_AGG_SIZE_8K = 0,
459         HT_AGG_SIZE_16K = 1,
460         HT_AGG_SIZE_32K = 2,
461         HT_AGG_SIZE_64K = 3,
462 }HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E;
463
464 /* Indicate different AP vendor for IOT issue */
465 typedef enum _HT_IOT_PEER
466 {
467         HT_IOT_PEER_UNKNOWN = 0,
468         HT_IOT_PEER_REALTEK = 1,
469         HT_IOT_PEER_REALTEK_92SE = 2,
470         HT_IOT_PEER_BROADCOM = 3,
471         HT_IOT_PEER_RALINK = 4,
472         HT_IOT_PEER_ATHEROS = 5,
473         HT_IOT_PEER_CISCO= 6,
474         HT_IOT_PEER_MARVELL=7,
475         HT_IOT_PEER_92U_SOFTAP = 8,
476         HT_IOT_PEER_SELF_SOFTAP = 9,
477         HT_IOT_PEER_MAX = 10,
478 }HT_IOT_PEER_E, *PHTIOT_PEER_E;
479
480 //
481 // IOT Action for different AP
482 //
483 typedef enum _HT_IOT_ACTION{
484         HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
485         HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
486         HT_IOT_ACT_DISABLE_MCS14 = 0x00000004,
487         HT_IOT_ACT_DISABLE_MCS15 = 0x00000008,
488         HT_IOT_ACT_DISABLE_ALL_2SS = 0x00000010,
489         HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000020,
490         HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000040,
491         HT_IOT_ACT_CDD_FSYNC = 0x00000080,
492         HT_IOT_ACT_PURE_N_MODE = 0x00000100,
493         HT_IOT_ACT_FORCED_CTS2SELF = 0x00000200,
494         HT_IOT_ACT_FORCED_RTS = 0x00000400,
495         HT_IOT_ACT_AMSDU_ENABLE = 0x00000800,
496         HT_IOT_ACT_REJECT_ADDBA_REQ = 0x00001000,
497         HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT = 0x00002000,
498         HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00004000,
499
500         HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000,
501         HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000,
502         HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000,
503         HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000,
504         HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000,
505         HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000,
506         
507         HT_IOT_ACT_MID_HIGHPOWER = 0x00400000,
508         HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000,
509         
510         HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000,
511         HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000,
512         HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000,
513 }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
514
515 typedef enum _HT_IOT_RAFUNC{
516         HT_IOT_RAFUNC_DISABLE_ALL = 0x00,
517         HT_IOT_RAFUNC_PEER_1R = 0x01,
518         HT_IOT_RAFUNC_TX_AMSDU = 0x02,
519 }HT_IOT_RAFUNC, *PHT_IOT_RAFUNC;
520
521 typedef enum _RT_HT_CAP{
522         RT_HT_CAP_USE_TURBO_AGGR = 0x01,
523         RT_HT_CAP_USE_LONG_PREAMBLE = 0x02,
524         RT_HT_CAP_USE_AMPDU = 0x04,
525         RT_HT_CAP_USE_WOW = 0x8,
526         RT_HT_CAP_USE_SOFTAP = 0x10,
527         RT_HT_CAP_USE_92SE = 0x20,
528 }RT_HT_CAPBILITY, *PRT_HT_CAPBILITY;
529
530 #endif