]> Pileus Git - ~andy/linux/blob - drivers/staging/rtl8192e/rtl819x_Qos.h
From: wlanfae <wlanfae@realtek.com>
[~andy/linux] / drivers / staging / rtl8192e / rtl819x_Qos.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 __INC_QOS_TYPE_H
20 #define __INC_QOS_TYPE_H
21
22 #include "rtllib_endianfree.h"
23
24 #define BIT0                    0x00000001
25 #define BIT1                    0x00000002
26 #define BIT2                    0x00000004
27 #define BIT3                    0x00000008
28 #define BIT4                    0x00000010
29 #define BIT5                    0x00000020
30 #define BIT6                    0x00000040
31 #define BIT7                    0x00000080
32 #define BIT8                    0x00000100
33 #define BIT9                    0x00000200
34 #define BIT10                   0x00000400
35 #define BIT11                   0x00000800
36 #define BIT12                   0x00001000
37 #define BIT13                   0x00002000
38 #define BIT14                   0x00004000
39 #define BIT15                   0x00008000
40 #define BIT16                   0x00010000
41 #define BIT17                   0x00020000
42 #define BIT18                   0x00040000
43 #define BIT19                   0x00080000
44 #define BIT20                   0x00100000
45 #define BIT21                   0x00200000
46 #define BIT22                   0x00400000
47 #define BIT23                   0x00800000
48 #define BIT24                   0x01000000
49 #define BIT25                   0x02000000
50 #define BIT26                   0x04000000
51 #define BIT27                   0x08000000
52 #define BIT28                   0x10000000
53 #define BIT29                   0x20000000
54 #define BIT30                   0x40000000
55 #define BIT31                   0x80000000
56
57 #ifndef RTK_DMP_PLATFORM
58 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
59 #ifndef bool
60 typedef enum{false = 0, true} bool;
61 #endif
62 #endif
63 #endif
64
65 typedef union _QOS_TSINFO{
66         u8              charData[3];
67         struct {
68                 u8              ucTrafficType:1;
69                 u8              ucTSID:4;
70                 u8              ucDirection:2;
71                 u8              ucAccessPolicy:2;
72                 u8              ucAggregation:1;
73                 u8              ucPSB:1;
74                 u8              ucUP:3;
75                 u8              ucTSInfoAckPolicy:2;
76                 u8              ucSchedule:1;
77                 u8              ucReserved:7;
78         }field;
79 }QOS_TSINFO, *PQOS_TSINFO;
80 typedef union _TSPEC_BODY{
81         u8              charData[55];
82
83         struct
84         {
85                 QOS_TSINFO      TSInfo;
86                 u16     NominalMSDUsize;
87                 u16     MaxMSDUsize;
88                 u32     MinServiceItv;
89                 u32     MaxServiceItv;
90                 u32     InactivityItv;
91                 u32     SuspenItv;
92                 u32     ServiceStartTime;
93                 u32     MinDataRate;
94                 u32     MeanDataRate;
95                 u32     PeakDataRate;
96                 u32     MaxBurstSize;
97                 u32     DelayBound;
98                 u32     MinPhyRate;
99                 u16     SurplusBandwidthAllowance;
100                 u16     MediumTime;
101         } f;
102 }TSPEC_BODY, *PTSPEC_BODY;
103
104 typedef struct _WMM_TSPEC{
105         u8              ID;
106         u8              Length;
107         u8              OUI[3];
108         u8              OUI_Type;
109         u8              OUI_SubType;
110         u8              Version;
111         TSPEC_BODY      Body;
112 } WMM_TSPEC, *PWMM_TSPEC;
113
114 typedef struct _OCTET_STRING{
115         u8              *Octet;
116         u16             Length;
117 }OCTET_STRING, *POCTET_STRING;
118 #define MAX_WMMELE_LENGTH       64
119
120 typedef u32 QOS_MODE, *PQOS_MODE;
121 #define QOS_DISABLE             0
122 #define QOS_WMM         1
123 #define QOS_WMMSA               2
124 #define QOS_EDCA                4
125 #define QOS_HCCA                8
126 #define QOS_WMM_UAPSD           16
127
128 #define WMM_PARAM_ELE_BODY_LEN  18
129
130 #define MAX_STA_TS_COUNT                        16
131 #define MAX_AP_TS_COUNT                 32
132 #define QOS_TSTREAM_KEY_SIZE            13
133
134 #define WMM_ACTION_CATEGORY_CODE        17
135 #define WMM_PARAM_ELE_BODY_LEN  18
136
137 #define MAX_TSPEC_TSID                          15
138 #define SESSION_REJECT_TSID                     0xfe
139 #define DEFAULT_TSID                                    0xff
140
141 #define ADDTS_TIME_SLOT                         100
142
143 #define ACM_TIMEOUT                             1000
144 #define SESSION_REJECT_TIMEOUT          60000
145
146 typedef enum _ACK_POLICY{
147         eAckPlc0_ACK            = 0x00,
148         eAckPlc1_NoACK          = 0x01,
149 }ACK_POLICY,*PACK_POLICY;
150
151
152 #define SET_WMM_QOS_INFO_FIELD(_pStart, _val)                                           WriteEF1Byte(_pStart, _val)
153
154 #define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart)              LE_BITS_TO_1BYTE(_pStart, 0, 4)
155 #define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val)        SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val)
156
157 #define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart)                                        LE_BITS_TO_1BYTE(_pStart, 7, 1)
158 #define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val)                          SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val)
159
160 #define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart)                 LE_BITS_TO_1BYTE(_pStart, 0, 1)
161 #define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val)           SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val)
162
163 #define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart)                 LE_BITS_TO_1BYTE(_pStart, 1, 1)
164 #define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val)           SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val)
165
166 #define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart)                 LE_BITS_TO_1BYTE(_pStart, 2, 1)
167 #define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val)           SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val)
168
169 #define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart)                 LE_BITS_TO_1BYTE(_pStart, 3, 1)
170 #define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val)           SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val)
171
172 #define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart)                  LE_BITS_TO_1BYTE(_pStart, 5, 2)
173 #define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val)            SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val)
174
175 typedef enum {
176         QOSIE_SRC_ADDTSREQ,
177         QOSIE_SRC_ADDTSRSP,
178         QOSIE_SRC_REASOCREQ,
179         QOSIE_SRC_REASOCRSP,
180         QOSIE_SRC_DELTS,
181 } QOSIE_SOURCE;
182
183
184 typedef u32 AC_CODING;
185 #define AC0_BE  0
186 #define AC1_BK  1
187 #define AC2_VI  2
188 #define AC3_VO  3
189 #define AC_MAX  4
190
191
192 #define AC_PARAM_SIZE   4
193
194 #define GET_WMM_AC_PARAM_AIFSN(_pStart)                         ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) )
195 #define SET_WMM_AC_PARAM_AIFSN(_pStart, _val)           SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val)
196
197 #define GET_WMM_AC_PARAM_ACM(_pStart)                           ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) )
198 #define SET_WMM_AC_PARAM_ACM(_pStart, _val)                     SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val)
199
200 #define GET_WMM_AC_PARAM_ACI(_pStart)                           ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) )
201 #define SET_WMM_AC_PARAM_ACI(_pStart, _val)                     SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val)
202
203 #define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart)                     ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) )
204 #define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val)       SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val)
205
206 #define GET_WMM_AC_PARAM_ECWMIN(_pStart)                        ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) )
207 #define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val)          SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val)
208
209 #define GET_WMM_AC_PARAM_ECWMAX(_pStart)                        ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) )
210 #define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val)          SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val)
211
212 #define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart)            ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) )
213 #define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val)      SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val)
214
215
216
217 #define WMM_PARAM_ELEMENT_SIZE  (8+(4*AC_PARAM_SIZE))
218
219 typedef enum _QOS_ELE_SUBTYPE{
220         QOSELE_TYPE_INFO                = 0x00,
221         QOSELE_TYPE_PARAM       = 0x01,
222 }QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;
223
224
225 typedef enum _DIRECTION_VALUE{
226         DIR_UP                  = 0,
227         DIR_DOWN                = 1,
228         DIR_DIRECT              = 2,
229         DIR_BI_DIR              = 3,
230 }DIRECTION_VALUE,*PDIRECTION_VALUE;
231
232 typedef enum _ACM_METHOD{
233         eAcmWay0_SwAndHw                = 0,
234         eAcmWay1_HW                     = 1,
235         eAcmWay2_SW                     = 2,
236 }ACM_METHOD,*PACM_METHOD;
237
238
239 typedef struct _ACM{
240         u64             UsedTime;
241         u64             MediumTime;
242         u8              HwAcmCtl;
243 }ACM, *PACM;
244
245
246
247 typedef u8              AC_UAPSD, *PAC_UAPSD;
248
249 #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
250 #define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
251
252 #define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
253 #define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
254
255 #define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
256 #define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
257
258 #define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
259 #define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
260
261 typedef union _QOS_TCLAS{
262
263         struct _TYPE_GENERAL{
264                 u8              Priority;
265                 u8              ClassifierType;
266                 u8              Mask;
267         } TYPE_GENERAL;
268
269         struct _TYPE0_ETH{
270                 u8              Priority;
271                 u8              ClassifierType;
272                 u8              Mask;
273                 u8              SrcAddr[6];
274                 u8              DstAddr[6];
275                 u16             Type;
276         } TYPE0_ETH;
277
278         struct _TYPE1_IPV4{
279                 u8              Priority;
280                 u8              ClassifierType;
281                 u8              Mask;
282                 u8              Version;
283                 u8              SrcIP[4];
284                 u8              DstIP[4];
285                 u16             SrcPort;
286                 u16             DstPort;
287                 u8              DSCP;
288                 u8              Protocol;
289                 u8              Reserved;
290         } TYPE1_IPV4;
291
292         struct _TYPE1_IPV6{
293                 u8              Priority;
294                 u8              ClassifierType;
295                 u8              Mask;
296                 u8              Version;
297                 u8              SrcIP[16];
298                 u8              DstIP[16];
299                 u16             SrcPort;
300                 u16             DstPort;
301                 u8              FlowLabel[3];
302         } TYPE1_IPV6;
303
304         struct _TYPE2_8021Q{
305                 u8              Priority;
306                 u8              ClassifierType;
307                 u8              Mask;
308                 u16             TagType;
309         } TYPE2_8021Q;
310 } QOS_TCLAS, *PQOS_TCLAS;
311
312 typedef struct _QOS_TSTREAM{
313
314         bool                    bUsed;
315         u16                     MsduLifetime;
316         bool                    bEstablishing;
317         u8                      TimeSlotCount;
318         u8                      DialogToken;
319         WMM_TSPEC       TSpec;
320         WMM_TSPEC       OutStandingTSpec;
321         u8                      NominalPhyRate;
322 } QOS_TSTREAM, *PQOS_TSTREAM;
323
324 typedef struct _STA_QOS{
325         u8                              WMMIEBuf[MAX_WMMELE_LENGTH];
326         u8*                             WMMIE;
327
328         QOS_MODE                QosCapability;
329         QOS_MODE                CurrentQosMode;
330
331         AC_UAPSD                b4ac_Uapsd;
332         AC_UAPSD                Curr4acUapsd;
333         u8                              bInServicePeriod;
334         u8                              MaxSPLength;
335         int                             NumBcnBeforeTrigger;
336
337         u8 *                            pWMMInfoEle;
338         u8                              WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
339
340         ACM                             acm[4];
341         ACM_METHOD              AcmMethod;
342
343         QOS_TSTREAM             StaTsArray[MAX_STA_TS_COUNT];
344         u8                              DialogToken;
345         WMM_TSPEC               TSpec;
346
347         u8                              QBssWirelessMode;
348
349         bool                            bNoAck;
350
351         bool                            bEnableRxImmBA;
352
353 }STA_QOS, *PSTA_QOS;
354
355 #define QBSS_LOAD_SIZE 5
356 #define GET_QBSS_LOAD_STA_COUNT(__pStart)                                       ReadEF2Byte(__pStart)
357 #define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value)                      WriteEF2Byte(__pStart, __Value)
358 #define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart)                        ReadEF1Byte((u8*)(__pStart) + 2)
359 #define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value)               WriteEF1Byte((u8*)(__pStart) + 2, __Value)
360 #define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart)                      ReadEF2Byte((u8*)(__pStart) + 3)
361 #define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value)     WriteEF2Byte((u8*)(__pStart) + 3, __Value)
362
363 typedef struct _BSS_QOS{
364
365         QOS_MODE                        bdQoSMode;
366         u8                                      bdWMMIEBuf[MAX_WMMELE_LENGTH];
367         OCTET_STRING                    bdWMMIE;
368
369         QOS_ELE_SUBTYPE         EleSubType;
370
371         u8*                                     pWMMInfoEle;
372         u8*                                     pWMMParamEle;
373
374         u8                                      QBssLoad[QBSS_LOAD_SIZE];
375         bool                                    bQBssLoadValid;
376 }BSS_QOS, *PBSS_QOS;
377
378 #define sQoSCtlLng      2
379 #define QOS_CTRL_LEN(_QosMode)          ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 )
380
381
382 #define IsACValid(ac)           ( ( ac>=0 && ac<=7 )? true : false )
383
384
385 typedef union _ACI_AIFSN{
386         u8      charData;
387
388         struct
389         {
390                 u8      AIFSN:4;
391                 u8      ACM:1;
392                 u8      ACI:2;
393                 u8      Reserved:1;
394         }f;
395 }ACI_AIFSN, *PACI_AIFSN;
396
397 typedef union _ECW{
398         u8      charData;
399         struct
400         {
401                 u8      ECWmin:4;
402                 u8      ECWmax:4;
403         }f;
404 }ECW, *PECW;
405
406 typedef union _AC_PARAM{
407         u32     longData;
408         u8      charData[4];
409
410         struct
411         {
412                 ACI_AIFSN       AciAifsn;
413                 ECW             Ecw;
414                 u16             TXOPLimit;
415         }f;
416 }AC_PARAM, *PAC_PARAM;
417
418
419
420
421
422 #endif