]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / drivers / staging / rtl8192su / ieee80211 / rtl819x_Qos.h
1 #ifndef __INC_QOS_TYPE_H
2 #define __INC_QOS_TYPE_H
3
4 //#include "EndianFree.h"
5 #define BIT0                    0x00000001
6 #define BIT1                    0x00000002
7 #define BIT2                    0x00000004
8 #define BIT3                    0x00000008
9 #define BIT4                    0x00000010
10 #define BIT5                    0x00000020
11 #define BIT6                    0x00000040
12 #define BIT7                    0x00000080
13 #define BIT8                    0x00000100
14 #define BIT9                    0x00000200
15 #define BIT10                   0x00000400
16 #define BIT11                   0x00000800
17 #define BIT12                   0x00001000
18 #define BIT13                   0x00002000
19 #define BIT14                   0x00004000
20 #define BIT15                   0x00008000
21 #define BIT16                   0x00010000
22 #define BIT17                   0x00020000
23 #define BIT18                   0x00040000
24 #define BIT19                   0x00080000
25 #define BIT20                   0x00100000
26 #define BIT21                   0x00200000
27 #define BIT22                   0x00400000
28 #define BIT23                   0x00800000
29 #define BIT24                   0x01000000
30 #define BIT25                   0x02000000
31 #define BIT26                   0x04000000
32 #define BIT27                   0x08000000
33 #define BIT28                   0x10000000
34 #define BIT29                   0x20000000
35 #define BIT30                   0x40000000
36 #define BIT31                   0x80000000
37
38 #define MAX_WMMELE_LENGTH       64
39
40 //
41 // QoS mode.
42 // enum 0, 1, 2, 4: since we can use the OR(|) operation.
43 //
44 // QOS_MODE is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
45 //typedef       enum _QOS_MODE{
46 //      QOS_DISABLE             = 0,
47 //      QOS_WMM                 = 1,
48 //      QOS_EDCA                        = 2,
49 //      QOS_HCCA                        = 4,
50 //}QOS_MODE,*PQOS_MODE;
51 //
52 typedef u32 QOS_MODE, *PQOS_MODE;
53 #define QOS_DISABLE             0
54 #define QOS_WMM                 1
55 #define QOS_WMMSA               2
56 #define QOS_EDCA                4
57 #define QOS_HCCA                8
58 #define QOS_WMM_UAPSD           16   //WMM Power Save, 2006-06-14 Isaiah
59
60 #define AC_PARAM_SIZE   4
61 #define WMM_PARAM_ELE_BODY_LEN  18
62
63 //
64 // QoS ACK Policy Field Values
65 // Ref: WMM spec 2.1.6: QoS Control Field, p.10.
66 //
67 typedef enum _ACK_POLICY{
68         eAckPlc0_ACK            = 0x00,
69         eAckPlc1_NoACK          = 0x01,
70 }ACK_POLICY,*PACK_POLICY;
71
72 #define WMM_PARAM_ELEMENT_SIZE  (8+(4*AC_PARAM_SIZE))
73
74 //
75 // QoS Control Field
76 // Ref:
77 //      1. WMM spec 2.1.6: QoS Control Field, p.9.
78 //      2. 802.11e/D13.0 7.1.3.5, p.26.
79 //
80 typedef union _QOS_CTRL_FIELD{
81         u8      charData[2];
82         u16     shortData;
83
84         // WMM spec
85         struct
86         {
87                 u8              UP:3;
88                 u8              usRsvd1:1;
89                 u8              EOSP:1;
90                 u8              AckPolicy:2;
91                 u8              usRsvd2:1;
92                 u8              ucRsvdByte;
93         }WMM;
94
95         // 802.11e: QoS data type frame sent by non-AP QSTAs.
96         struct
97         {
98                 u8              TID:4;
99                 u8              bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
100                 u8              AckPolicy:2;
101                 u8              usRsvd:1;
102                 u8              TxopOrQsize;    // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
103         }BySta;
104
105         // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
106         struct
107         {
108                 u8              TID:4;
109                 u8              EOSP:1;
110                 u8              AckPolicy:2;
111                 u8              usRsvd:1;
112                 u8              PSBufState;             // QAP PS Buffer State.
113         }ByHc_Data;
114
115         // 802.11e: QoS (+) CF-Poll frames sent by HC.
116         struct
117         {
118                 u8              TID:4;
119                 u8              EOSP:1;
120                 u8              AckPolicy:2;
121                 u8              usRsvd:1;
122                 u8              TxopLimit;              // TXOP Limit.
123         }ByHc_CFP;
124
125 }QOS_CTRL_FIELD, *PQOS_CTRL_FIELD;
126
127
128 //
129 // QoS Info Field
130 // Ref:
131 //      1. WMM spec 2.2.1: WME Information Element, p.11.
132 //      2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
133 //
134 typedef union _QOS_INFO_FIELD{
135         u8      charData;
136
137         struct
138         {
139                 u8              ucParameterSetCount:4;
140                 u8              ucReserved:4;
141         }WMM;
142
143         struct
144         {
145                 //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
146                 u8              ucAC_VO_UAPSD:1;
147                 u8              ucAC_VI_UAPSD:1;
148                 u8              ucAC_BE_UAPSD:1;
149                 u8              ucAC_BK_UAPSD:1;
150                 u8              ucReserved1:1;
151                 u8              ucMaxSPLen:2;
152                 u8              ucReserved2:1;
153
154         }ByWmmPsSta;
155
156         struct
157         {
158                 //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
159                 u8              ucParameterSetCount:4;
160                 u8              ucReserved:3;
161                 u8              ucApUapsd:1;
162         }ByWmmPsAp;
163
164         struct
165         {
166                 u8              ucAC3_UAPSD:1;
167                 u8              ucAC2_UAPSD:1;
168                 u8              ucAC1_UAPSD:1;
169                 u8              ucAC0_UAPSD:1;
170                 u8              ucQAck:1;
171                 u8              ucMaxSPLen:2;
172                 u8              ucMoreDataAck:1;
173         } By11eSta;
174
175         struct
176         {
177                 u8              ucParameterSetCount:4;
178                 u8              ucQAck:1;
179                 u8              ucQueueReq:1;
180                 u8              ucTXOPReq:1;
181                 u8              ucReserved:1;
182         } By11eAp;
183
184         struct
185         {
186                 u8              ucReserved1:4;
187                 u8              ucQAck:1;
188                 u8              ucReserved2:2;
189                 u8              ucMoreDataAck:1;
190         } ByWmmsaSta;
191
192         struct
193         {
194                 u8              ucReserved1:4;
195                 u8              ucQAck:1;
196                 u8              ucQueueReq:1;
197                 u8              ucTXOPReq:1;
198                 u8              ucReserved2:1;
199         } ByWmmsaAp;
200
201         struct
202         {
203                 u8              ucAC3_UAPSD:1;
204                 u8              ucAC2_UAPSD:1;
205                 u8              ucAC1_UAPSD:1;
206                 u8              ucAC0_UAPSD:1;
207                 u8              ucQAck:1;
208                 u8              ucMaxSPLen:2;
209                 u8              ucMoreDataAck:1;
210         } ByAllSta;
211
212         struct
213         {
214                 u8              ucParameterSetCount:4;
215                 u8              ucQAck:1;
216                 u8              ucQueueReq:1;
217                 u8              ucTXOPReq:1;
218                 u8              ucApUapsd:1;
219         } ByAllAp;
220
221 }QOS_INFO_FIELD, *PQOS_INFO_FIELD;
222
223 //
224 // ACI to AC coding.
225 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
226 //
227 // AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
228 //typedef       enum _AC_CODING{
229 //      AC0_BE  = 0,            // ACI: 0x00    // Best Effort
230 //      AC1_BK  = 1,            // ACI: 0x01    // Background
231 //      AC2_VI  = 2,            // ACI: 0x10    // Video
232 //      AC3_VO  = 3,            // ACI: 0x11    // Voice
233 //      AC_MAX = 4,             // Max: define total number; Should not to be used as a real enum.
234 //}AC_CODING,*PAC_CODING;
235 //
236 typedef u32 AC_CODING;
237 #define AC0_BE  0               // ACI: 0x00    // Best Effort
238 #define AC1_BK  1               // ACI: 0x01    // Background
239 #define AC2_VI  2               // ACI: 0x10    // Video
240 #define AC3_VO  3               // ACI: 0x11    // Voice
241 #define AC_MAX  4               // Max: define total number; Should not to be used as a real enum.
242
243 //
244 // ACI/AIFSN Field.
245 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
246 //
247 typedef union _ACI_AIFSN{
248         u8      charData;
249
250         struct
251         {
252                 u8      AIFSN:4;
253                 u8      ACM:1;
254                 u8      ACI:2;
255                 u8      Reserved:1;
256         }f;     // Field
257 }ACI_AIFSN, *PACI_AIFSN;
258
259 //
260 // ECWmin/ECWmax field.
261 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
262 //
263 typedef union _ECW{
264         u8      charData;
265         struct
266         {
267                 u8      ECWmin:4;
268                 u8      ECWmax:4;
269         }f;     // Field
270 }ECW, *PECW;
271
272 //
273 // AC Parameters Record Format.
274 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
275 //
276 typedef union _AC_PARAM{
277         u32     longData;
278         u8      charData[4];
279
280         struct
281         {
282                 ACI_AIFSN       AciAifsn;
283                 ECW             Ecw;
284                 u16             TXOPLimit;
285         }f;     // Field
286 }AC_PARAM, *PAC_PARAM;
287
288
289
290 //
291 // QoS element subtype
292 //
293 typedef enum _QOS_ELE_SUBTYPE{
294         QOSELE_TYPE_INFO        = 0x00,         // 0x00: Information element
295         QOSELE_TYPE_PARAM       = 0x01,         // 0x01: parameter element
296 }QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;
297
298
299 //
300 // Direction Field Values.
301 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
302 //
303 typedef enum _DIRECTION_VALUE{
304         DIR_UP                  = 0,            // 0x00 // UpLink
305         DIR_DOWN                = 1,            // 0x01 // DownLink
306         DIR_DIRECT              = 2,            // 0x10 // DirectLink
307         DIR_BI_DIR              = 3,            // 0x11 // Bi-Direction
308 }DIRECTION_VALUE,*PDIRECTION_VALUE;
309
310
311 //
312 // TS Info field in WMM TSPEC Element.
313 // Ref:
314 //      1. WMM spec 2.2.11: WME TSPEC Element, p.18.
315 //      2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
316 //
317 typedef union _QOS_TSINFO{
318         u8              charData[3];
319         struct {
320                 u8              ucTrafficType:1;                        //WMM is reserved
321                 u8              ucTSID:4;
322                 u8              ucDirection:2;
323                 u8              ucAccessPolicy:2;       //WMM: bit8=0, bit7=1
324                 u8              ucAggregation:1;                //WMM is reserved
325                 u8              ucPSB:1;                                //WMMSA is APSD
326                 u8              ucUP:3;
327                 u8              ucTSInfoAckPolicy:2;            //WMM is reserved
328                 u8              ucSchedule:1;                   //WMM is reserved
329                 u8              ucReserved:7;
330         }field;
331 }QOS_TSINFO, *PQOS_TSINFO;
332
333 //
334 // WMM TSPEC Body.
335 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
336 //
337 typedef union _TSPEC_BODY{
338         u8              charData[55];
339
340         struct
341         {
342                 QOS_TSINFO      TSInfo; //u8    TSInfo[3];
343                 u16     NominalMSDUsize;
344                 u16     MaxMSDUsize;
345                 u32     MinServiceItv;
346                 u32     MaxServiceItv;
347                 u32     InactivityItv;
348                 u32     SuspenItv;
349                 u32     ServiceStartTime;
350                 u32     MinDataRate;
351                 u32     MeanDataRate;
352                 u32     PeakDataRate;
353                 u32     MaxBurstSize;
354                 u32     DelayBound;
355                 u32     MinPhyRate;
356                 u16     SurplusBandwidthAllowance;
357                 u16     MediumTime;
358         } f;    // Field
359 }TSPEC_BODY, *PTSPEC_BODY;
360
361
362 //
363 // WMM TSPEC Element.
364 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
365 //
366 typedef struct _WMM_TSPEC{
367         u8              ID;
368         u8              Length;
369         u8              OUI[3];
370         u8              OUI_Type;
371         u8              OUI_SubType;
372         u8              Version;
373         TSPEC_BODY      Body;
374 } WMM_TSPEC, *PWMM_TSPEC;
375
376 //
377 // ACM implementation method.
378 // Annie, 2005-12-13.
379 //
380 typedef enum _ACM_METHOD{
381         eAcmWay0_SwAndHw                = 0,            // By SW and HW.
382         eAcmWay1_HW                     = 1,            // By HW.
383         eAcmWay2_SW                     = 2,            // By SW.
384 }ACM_METHOD,*PACM_METHOD;
385
386
387 typedef struct _ACM{
388 //      u8              RegEnableACM;
389         u64             UsedTime;
390         u64             MediumTime;
391         u8              HwAcmCtl;       // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
392 }ACM, *PACM;
393
394 typedef u8              AC_UAPSD, *PAC_UAPSD;
395
396 #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
397 #define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
398
399 #define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
400 #define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
401
402 #define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
403 #define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
404
405 #define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
406 #define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
407
408
409 //typedef struct _TCLASS{
410 // TODO
411 //} TCLASS, *PTCLASS;
412 typedef union _QOS_TCLAS{
413
414         struct _TYPE_GENERAL{
415                 u8              Priority;
416                 u8              ClassifierType;
417                 u8              Mask;
418         } TYPE_GENERAL;
419
420         struct _TYPE0_ETH{
421                 u8              Priority;
422                 u8              ClassifierType;
423                 u8              Mask;
424                 u8              SrcAddr[6];
425                 u8              DstAddr[6];
426                 u16             Type;
427         } TYPE0_ETH;
428
429         struct _TYPE1_IPV4{
430                 u8              Priority;
431                 u8              ClassifierType;
432                 u8              Mask;
433                 u8              Version;
434                 u8              SrcIP[4];
435                 u8              DstIP[4];
436                 u16             SrcPort;
437                 u16             DstPort;
438                 u8              DSCP;
439                 u8              Protocol;
440                 u8              Reserved;
441         } TYPE1_IPV4;
442
443         struct _TYPE1_IPV6{
444                 u8              Priority;
445                 u8              ClassifierType;
446                 u8              Mask;
447                 u8              Version;
448                 u8              SrcIP[16];
449                 u8              DstIP[16];
450                 u16             SrcPort;
451                 u16             DstPort;
452                 u8              FlowLabel[3];
453         } TYPE1_IPV6;
454
455         struct _TYPE2_8021Q{
456                 u8              Priority;
457                 u8              ClassifierType;
458                 u8              Mask;
459                 u16             TagType;
460         } TYPE2_8021Q;
461 } QOS_TCLAS, *PQOS_TCLAS;
462
463 //typedef struct _WMM_TSTREAM{
464 //
465 //- TSPEC
466 //- AC (which to mapping)
467 //} WMM_TSTREAM, *PWMM_TSTREAM;
468 typedef struct _QOS_TSTREAM{
469         u8                      AC;
470         WMM_TSPEC               TSpec;
471         QOS_TCLAS               TClass;
472 } QOS_TSTREAM, *PQOS_TSTREAM;
473
474 //typedef struct _U_APSD{
475 //- TriggerEnable [4]
476 //- MaxSPLength
477 //- HighestAcBuffered
478 //} U_APSD, *PU_APSD;
479
480 //joseph TODO:
481 //      UAPSD function should be implemented by 2 data structure
482 //      "Qos control field" and "Qos info field"
483 //typedef struct _QOS_UAPSD{
484 //      u8                      bTriggerEnable[4];
485 //      u8                      MaxSPLength;
486 //      u8                      HighestBufAC;
487 //} QOS_UAPSD, *PQOS_APSD;
488
489 //----------------------------------------------------------------------------
490 //      802.11 Management frame Status Code field
491 //----------------------------------------------------------------------------
492 typedef struct _OCTET_STRING{
493         u8              *Octet;
494         u16             Length;
495 }OCTET_STRING, *POCTET_STRING;
496
497 //
498 // STA QoS data.
499 // Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
500 //
501 typedef struct _STA_QOS{
502         //DECLARE_RT_OBJECT(STA_QOS);
503         u8                              WMMIEBuf[MAX_WMMELE_LENGTH];
504         u8*                             WMMIE;
505
506         // Part 1. Self QoS Mode.
507         QOS_MODE                        QosCapability; //QoS Capability, 2006-06-14 Isaiah
508         QOS_MODE                        CurrentQosMode;
509
510         // For WMM Power Save Mode :
511         // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
512         AC_UAPSD                        b4ac_Uapsd;  //VoUapsd(bit0), ViUapsd(bit1),  BkUapsd(bit2), BeUapsd(bit3),
513         AC_UAPSD                        Curr4acUapsd;
514         u8                              bInServicePeriod;
515         u8                              MaxSPLength;
516         int                             NumBcnBeforeTrigger;
517
518         // Part 2. EDCA Parameter (perAC)
519         u8 *                            pWMMInfoEle;
520         u8                              WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
521         u8                              WMMPELength;
522
523         // <Bruce_Note>
524         //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
525         // By Bruce, 2008-01-30.
526         // Part 2. EDCA Parameter (perAC)
527         QOS_INFO_FIELD                  QosInfoField_STA;       // Maintained by STA
528         QOS_INFO_FIELD                  QosInfoField_AP;        // Retrieved from AP
529
530         AC_PARAM                        CurAcParameters[4];
531
532         // Part 3. ACM
533         ACM                             acm[4];
534         ACM_METHOD                      AcmMethod;
535
536         // Part 4. Per TID (Part 5: TCLASS will be described by TStream)
537         QOS_TSTREAM                     TStream[16];
538         WMM_TSPEC                       TSpec;
539
540         u32                             QBssWirelessMode;
541
542         // No Ack Setting
543         u8                              bNoAck;
544
545         // Enable/Disable Rx immediate BA capability.
546         u8                              bEnableRxImmBA;
547
548 }STA_QOS, *PSTA_QOS;
549
550 //
551 // BSS QOS data.
552 // Ref: BssDscr in 8185 code. [def. in BssDscr.h]
553 //
554 typedef struct _BSS_QOS{
555         QOS_MODE                bdQoSMode;
556
557         u8                      bdWMMIEBuf[MAX_WMMELE_LENGTH];
558         u8*             bdWMMIE;
559
560         QOS_ELE_SUBTYPE         EleSubType;
561
562         u8 *                    pWMMInfoEle;
563         u8 *                    pWMMParamEle;
564
565         QOS_INFO_FIELD          QosInfoField;
566         AC_PARAM                AcParameter[4];
567 }BSS_QOS, *PBSS_QOS;
568
569
570 //
571 // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code.
572 //#define QoSCtl   ((   (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA))    )  ?sQoSCtlLng:0)
573 //
574 #define sQoSCtlLng                      2
575 #define QOS_CTRL_LEN(_QosMode)          ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)
576
577
578 //Added by joseph
579 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
580 //#define UP2AC(up)                     ((up<3)?((up==0)?1:0):(up>>1))
581 #define IsACValid(ac)                   ((ac<=7 )?true:false )
582
583 #endif // #ifndef __INC_QOS_TYPE_H