Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtl819x_Qos.h
Go to the documentation of this file.
1 #ifndef __INC_QOS_TYPE_H
2 #define __INC_QOS_TYPE_H
3 
4 #define BIT0 0x00000001
5 #define BIT1 0x00000002
6 #define BIT2 0x00000004
7 #define BIT3 0x00000008
8 #define BIT4 0x00000010
9 #define BIT5 0x00000020
10 #define BIT6 0x00000040
11 #define BIT7 0x00000080
12 #define BIT8 0x00000100
13 #define BIT9 0x00000200
14 #define BIT10 0x00000400
15 #define BIT11 0x00000800
16 #define BIT12 0x00001000
17 #define BIT13 0x00002000
18 #define BIT14 0x00004000
19 #define BIT15 0x00008000
20 #define BIT16 0x00010000
21 #define BIT17 0x00020000
22 #define BIT18 0x00040000
23 #define BIT19 0x00080000
24 #define BIT20 0x00100000
25 #define BIT21 0x00200000
26 #define BIT22 0x00400000
27 #define BIT23 0x00800000
28 #define BIT24 0x01000000
29 #define BIT25 0x02000000
30 #define BIT26 0x04000000
31 #define BIT27 0x08000000
32 #define BIT28 0x10000000
33 #define BIT29 0x20000000
34 #define BIT30 0x40000000
35 #define BIT31 0x80000000
36 
37 #define MAX_WMMELE_LENGTH 64
38 
39 //
40 // QoS mode.
41 // enum 0, 1, 2, 4: since we can use the OR(|) operation.
42 //
43 // QOS_MODE is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
44 //typedef enum _QOS_MODE{
45 // QOS_DISABLE = 0,
46 // QOS_WMM = 1,
47 // QOS_EDCA = 2,
48 // QOS_HCCA = 4,
49 //}QOS_MODE,*PQOS_MODE;
50 //
52 #define QOS_DISABLE 0
53 #define QOS_WMM 1
54 #define QOS_WMMSA 2
55 #define QOS_EDCA 4
56 #define QOS_HCCA 8
57 #define QOS_WMM_UAPSD 16 //WMM Power Save, 2006-06-14 Isaiah
58 
59 #define AC_PARAM_SIZE 4
60 #define WMM_PARAM_ELE_BODY_LEN 18
61 
62 //
63 // QoS ACK Policy Field Values
64 // Ref: WMM spec 2.1.6: QoS Control Field, p.10.
65 //
66 typedef enum _ACK_POLICY{
67  eAckPlc0_ACK = 0x00,
70 
71 #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE))
72 
73 //
74 // QoS Control Field
75 // Ref:
76 // 1. WMM spec 2.1.6: QoS Control Field, p.9.
77 // 2. 802.11e/D13.0 7.1.3.5, p.26.
78 //
79 typedef union _QOS_CTRL_FIELD{
82 
83  // WMM spec
84  struct
85  {
86  u8 UP:3;
88  u8 EOSP:1;
92  }WMM;
93 
94  // 802.11e: QoS data type frame sent by non-AP QSTAs.
95  struct
96  {
97  u8 TID:4;
98  u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
99  u8 AckPolicy:2;
101  u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
102  }BySta;
103 
104  // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
105  struct
106  {
107  u8 TID:4;
108  u8 EOSP:1;
109  u8 AckPolicy:2;
110  u8 usRsvd:1;
111  u8 PSBufState; // QAP PS Buffer State.
112  }ByHc_Data;
113 
114  // 802.11e: QoS (+) CF-Poll frames sent by HC.
115  struct
116  {
117  u8 TID:4;
118  u8 EOSP:1;
119  u8 AckPolicy:2;
120  u8 usRsvd:1;
121  u8 TxopLimit; // TXOP Limit.
122  }ByHc_CFP;
123 
125 
126 
127 //
128 // QoS Info Field
129 // Ref:
130 // 1. WMM spec 2.2.1: WME Information Element, p.11.
131 // 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
132 //
133 typedef union _QOS_INFO_FIELD{
135 
136  struct
137  {
140  }WMM;
141 
142  struct
143  {
144  //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
152 
153  }ByWmmPsSta;
154 
155  struct
156  {
157  //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
159  u8 ucReserved:3;
161  }ByWmmPsAp;
162 
163  struct
164  {
170  u8 ucMaxSPLen:2;
172  } By11eSta;
173 
174  struct
175  {
177  u8 ucQAck:1;
180  u8 ucReserved:1;
181  } By11eAp;
182 
183  struct
184  {
185  u8 ucReserved1:4;
186  u8 ucQAck:1;
187  u8 ucReserved2:2;
188  u8 ucMoreDataAck:1;
189  } ByWmmsaSta;
190 
191  struct
192  {
193  u8 ucReserved1:4;
194  u8 ucQAck:1;
195  u8 ucQueueReq:1;
196  u8 ucTXOPReq:1;
197  u8 ucReserved2:1;
198  } ByWmmsaAp;
199 
200  struct
201  {
202  u8 ucAC3_UAPSD:1;
203  u8 ucAC2_UAPSD:1;
204  u8 ucAC1_UAPSD:1;
205  u8 ucAC0_UAPSD:1;
206  u8 ucQAck:1;
207  u8 ucMaxSPLen:2;
208  u8 ucMoreDataAck:1;
209  } ByAllSta;
210 
211  struct
212  {
214  u8 ucQAck:1;
215  u8 ucQueueReq:1;
216  u8 ucTXOPReq:1;
217  u8 ucApUapsd:1;
218  } ByAllAp;
219 
221 
222 //
223 // ACI to AC coding.
224 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
225 //
226 // AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
227 //typedef enum _AC_CODING{
228 // AC0_BE = 0, // ACI: 0x00 // Best Effort
229 // AC1_BK = 1, // ACI: 0x01 // Background
230 // AC2_VI = 2, // ACI: 0x10 // Video
231 // AC3_VO = 3, // ACI: 0x11 // Voice
232 // AC_MAX = 4, // Max: define total number; Should not to be used as a real enum.
233 //}AC_CODING,*PAC_CODING;
234 //
235 typedef u32 AC_CODING;
236 #define AC0_BE 0 // ACI: 0x00 // Best Effort
237 #define AC1_BK 1 // ACI: 0x01 // Background
238 #define AC2_VI 2 // ACI: 0x10 // Video
239 #define AC3_VO 3 // ACI: 0x11 // Voice
240 #define AC_MAX 4 // Max: define total number; Should not to be used as a real enum.
241 
242 //
243 // ACI/AIFSN Field.
244 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
245 //
246 typedef union _ACI_AIFSN{
247  u8 charData;
248 
249  struct
250  {
251  u8 AIFSN:4;
252  u8 ACM:1;
253  u8 ACI:2;
254  u8 Reserved:1;
255  }f; // Field
257 
258 //
259 // ECWmin/ECWmax field.
260 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
261 //
262 typedef union _ECW{
263  u8 charData;
264  struct
265  {
266  u8 ECWmin:4;
267  u8 ECWmax:4;
268  }f; // Field
269 }ECW, *PECW;
270 
271 //
272 // AC Parameters Record Format.
273 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
274 //
275 typedef union _AC_PARAM{
276  u32 longData;
277  u8 charData[4];
278 
279  struct
280  {
282  ECW Ecw;
283  u16 TXOPLimit;
284  }f; // Field
286 
287 
288 
289 //
290 // QoS element subtype
291 //
292 typedef enum _QOS_ELE_SUBTYPE{
293  QOSELE_TYPE_INFO = 0x00, // 0x00: Information element
294  QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element
296 
297 
298 //
299 // Direction Field Values.
300 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
301 //
302 typedef enum _DIRECTION_VALUE{
303  DIR_UP = 0, // 0x00 // UpLink
304  DIR_DOWN = 1, // 0x01 // DownLink
305  DIR_DIRECT = 2, // 0x10 // DirectLink
306  DIR_BI_DIR = 3, // 0x11 // Bi-Direction
308 
309 
310 //
311 // TS Info field in WMM TSPEC Element.
312 // Ref:
313 // 1. WMM spec 2.2.11: WME TSPEC Element, p.18.
314 // 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
315 //
316 typedef union _QOS_TSINFO{
318  struct {
319  u8 ucTrafficType:1; //WMM is reserved
322  u8 ucAccessPolicy:2; //WMM: bit8=0, bit7=1
323  u8 ucAggregation:1; //WMM is reserved
324  u8 ucPSB:1; //WMMSA is APSD
325  u8 ucUP:3;
326  u8 ucTSInfoAckPolicy:2; //WMM is reserved
327  u8 ucSchedule:1; //WMM is reserved
329  }field;
331 
332 //
333 // WMM TSPEC Body.
334 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
335 //
336 typedef union _TSPEC_BODY{
338 
339  struct
340  {
341  QOS_TSINFO TSInfo; //u8 TSInfo[3];
357  } f; // Field
359 
360 
361 //
362 // WMM TSPEC Element.
363 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
364 //
365 typedef struct _WMM_TSPEC{
368  u8 OUI[3];
374 
375 //
376 // ACM implementation method.
377 // Annie, 2005-12-13.
378 //
379 typedef enum _ACM_METHOD{
380  eAcmWay0_SwAndHw = 0, // By SW and HW.
381  eAcmWay1_HW = 1, // By HW.
382  eAcmWay2_SW = 2, // By SW.
384 
385 
386 typedef struct _ACM{
387 // u8 RegEnableACM;
390  u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
391 }ACM, *PACM;
392 
394 
395 #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
396 #define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
397 
398 #define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
399 #define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
400 
401 #define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
402 #define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
403 
404 #define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
405 #define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
406 
407 
408 //typedef struct _TCLASS{
409 // TODO
410 //} TCLASS, *PTCLASS;
411 typedef union _QOS_TCLAS{
412 
417  } TYPE_GENERAL;
418 
419  struct _TYPE0_ETH{
426  } TYPE0_ETH;
427 
428  struct _TYPE1_IPV4{
433  u8 SrcIP[4];
434  u8 DstIP[4];
440  } TYPE1_IPV4;
441 
442  struct _TYPE1_IPV6{
447  u8 SrcIP[16];
448  u8 DstIP[16];
452  } TYPE1_IPV6;
453 
454  struct _TYPE2_8021Q{
459  } TYPE2_8021Q;
461 
462 //typedef struct _WMM_TSTREAM{
463 //
464 //- TSPEC
465 //- AC (which to mapping)
466 //} WMM_TSTREAM, *PWMM_TSTREAM;
467 typedef struct _QOS_TSTREAM{
472 
473 //typedef struct _U_APSD{
474 //- TriggerEnable [4]
475 //- MaxSPLength
476 //- HighestAcBuffered
477 //} U_APSD, *PU_APSD;
478 
479 //joseph TODO:
480 // UAPSD function should be implemented by 2 data structure
481 // "Qos control field" and "Qos info field"
482 //typedef struct _QOS_UAPSD{
483 // u8 bTriggerEnable[4];
484 // u8 MaxSPLength;
485 // u8 HighestBufAC;
486 //} QOS_UAPSD, *PQOS_APSD;
487 
488 //----------------------------------------------------------------------------
489 // 802.11 Management frame Status Code field
490 //----------------------------------------------------------------------------
491 typedef struct _OCTET_STRING{
495 
496 //
497 // STA QoS data.
498 // Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
499 //
500 typedef struct _STA_QOS{
501  //DECLARE_RT_OBJECT(STA_QOS);
504 
505  // Part 1. Self QoS Mode.
506  QOS_MODE QosCapability; //QoS Capability, 2006-06-14 Isaiah
508 
509  // For WMM Power Save Mode :
510  // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
511  AC_UAPSD b4ac_Uapsd; //VoUapsd(bit0), ViUapsd(bit1), BkUapsd(bit2), BeUapsd(bit3),
516 
517  // Part 2. EDCA Parameter (perAC)
521 
522  // <Bruce_Note>
523  //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
524  // By Bruce, 2008-01-30.
525  // Part 2. EDCA Parameter (perAC)
526  QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA
527  QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP
528 
530 
531  // Part 3. ACM
532  ACM acm[4];
534 
535  // Part 4. Per TID (Part 5: TCLASS will be described by TStream)
538 
540 
541  // No Ack Setting
543 
544  // Enable/Disable Rx immediate BA capability.
546 
547 }STA_QOS, *PSTA_QOS;
548 
549 //
550 // BSS QOS data.
551 // Ref: BssDscr in 8185 code. [def. in BssDscr.h]
552 //
553 typedef struct _BSS_QOS{
555 
558 
560 
563 
566 }BSS_QOS, *PBSS_QOS;
567 
568 
569 //
570 // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code.
571 //#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0)
572 //
573 #define sQoSCtlLng 2
574 #define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)
575 
576 
577 //Added by joseph
578 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
579 //#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1))
580 #define IsACValid(ac) ((ac<=7 )?true:false )
581 
582 #endif // #ifndef __INC_QOS_TYPE_H