staging: rtl8192e: Convert typedef WMM_TSPEC to struct wmm_tspec
[pohmelfs.git] / drivers / staging / rtl8192e / rtl819x_Qos.h
blobe9eea5aba9863bfe2dea4e06498096e03297acb3
1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
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.
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
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #ifndef __INC_QOS_TYPE_H
20 #define __INC_QOS_TYPE_H
22 #include "rtllib_endianfree.h"
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
57 typedef union _QOS_TSINFO{
58 u8 charData[3];
59 struct {
60 u8 ucTrafficType:1;
61 u8 ucTSID:4;
62 u8 ucDirection:2;
63 u8 ucAccessPolicy:2;
64 u8 ucAggregation:1;
65 u8 ucPSB:1;
66 u8 ucUP:3;
67 u8 ucTSInfoAckPolicy:2;
68 u8 ucSchedule:1;
69 u8 ucReserved:7;
70 }field;
71 }QOS_TSINFO, *PQOS_TSINFO;
72 typedef union _TSPEC_BODY{
73 u8 charData[55];
75 struct
77 QOS_TSINFO TSInfo;
78 u16 NominalMSDUsize;
79 u16 MaxMSDUsize;
80 u32 MinServiceItv;
81 u32 MaxServiceItv;
82 u32 InactivityItv;
83 u32 SuspenItv;
84 u32 ServiceStartTime;
85 u32 MinDataRate;
86 u32 MeanDataRate;
87 u32 PeakDataRate;
88 u32 MaxBurstSize;
89 u32 DelayBound;
90 u32 MinPhyRate;
91 u16 SurplusBandwidthAllowance;
92 u16 MediumTime;
93 } f;
94 }TSPEC_BODY, *PTSPEC_BODY;
96 struct wmm_tspec {
97 u8 ID;
98 u8 Length;
99 u8 OUI[3];
100 u8 OUI_Type;
101 u8 OUI_SubType;
102 u8 Version;
103 TSPEC_BODY Body;
106 typedef struct _OCTET_STRING{
107 u8 *Octet;
108 u16 Length;
109 }OCTET_STRING, *POCTET_STRING;
110 #define MAX_WMMELE_LENGTH 64
112 typedef u32 QOS_MODE, *PQOS_MODE;
113 #define QOS_DISABLE 0
114 #define QOS_WMM 1
115 #define QOS_WMMSA 2
116 #define QOS_EDCA 4
117 #define QOS_HCCA 8
118 #define QOS_WMM_UAPSD 16
120 #define WMM_PARAM_ELE_BODY_LEN 18
122 #define MAX_STA_TS_COUNT 16
123 #define MAX_AP_TS_COUNT 32
124 #define QOS_TSTREAM_KEY_SIZE 13
126 #define WMM_ACTION_CATEGORY_CODE 17
127 #define WMM_PARAM_ELE_BODY_LEN 18
129 #define MAX_TSPEC_TSID 15
130 #define SESSION_REJECT_TSID 0xfe
131 #define DEFAULT_TSID 0xff
133 #define ADDTS_TIME_SLOT 100
135 #define ACM_TIMEOUT 1000
136 #define SESSION_REJECT_TIMEOUT 60000
138 typedef enum _ACK_POLICY{
139 eAckPlc0_ACK = 0x00,
140 eAckPlc1_NoACK = 0x01,
141 }ACK_POLICY,*PACK_POLICY;
144 #define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val)
146 #define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4)
147 #define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val)
149 #define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1)
150 #define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val)
152 #define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1)
153 #define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val)
155 #define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1)
156 #define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val)
158 #define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1)
159 #define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val)
161 #define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1)
162 #define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val)
164 #define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2)
165 #define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val)
167 typedef enum {
168 QOSIE_SRC_ADDTSREQ,
169 QOSIE_SRC_ADDTSRSP,
170 QOSIE_SRC_REASOCREQ,
171 QOSIE_SRC_REASOCRSP,
172 QOSIE_SRC_DELTS,
173 } QOSIE_SOURCE;
176 typedef u32 AC_CODING;
177 #define AC0_BE 0
178 #define AC1_BK 1
179 #define AC2_VI 2
180 #define AC3_VO 3
181 #define AC_MAX 4
184 #define AC_PARAM_SIZE 4
186 #define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) )
187 #define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val)
189 #define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) )
190 #define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val)
192 #define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) )
193 #define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val)
195 #define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) )
196 #define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val)
198 #define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) )
199 #define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val)
201 #define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) )
202 #define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val)
204 #define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) )
205 #define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val)
209 #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE))
211 typedef enum _QOS_ELE_SUBTYPE{
212 QOSELE_TYPE_INFO = 0x00,
213 QOSELE_TYPE_PARAM = 0x01,
214 }QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;
217 typedef enum _DIRECTION_VALUE{
218 DIR_UP = 0,
219 DIR_DOWN = 1,
220 DIR_DIRECT = 2,
221 DIR_BI_DIR = 3,
222 }DIRECTION_VALUE,*PDIRECTION_VALUE;
224 typedef enum _ACM_METHOD{
225 eAcmWay0_SwAndHw = 0,
226 eAcmWay1_HW = 1,
227 eAcmWay2_SW = 2,
228 }ACM_METHOD,*PACM_METHOD;
231 typedef struct _ACM{
232 u64 UsedTime;
233 u64 MediumTime;
234 u8 HwAcmCtl;
235 }ACM, *PACM;
239 typedef u8 AC_UAPSD, *PAC_UAPSD;
241 #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
242 #define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
244 #define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
245 #define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
247 #define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
248 #define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
250 #define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
251 #define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
253 typedef union _QOS_TCLAS{
255 struct _TYPE_GENERAL{
256 u8 Priority;
257 u8 ClassifierType;
258 u8 Mask;
259 } TYPE_GENERAL;
261 struct _TYPE0_ETH{
262 u8 Priority;
263 u8 ClassifierType;
264 u8 Mask;
265 u8 SrcAddr[6];
266 u8 DstAddr[6];
267 u16 Type;
268 } TYPE0_ETH;
270 struct _TYPE1_IPV4{
271 u8 Priority;
272 u8 ClassifierType;
273 u8 Mask;
274 u8 Version;
275 u8 SrcIP[4];
276 u8 DstIP[4];
277 u16 SrcPort;
278 u16 DstPort;
279 u8 DSCP;
280 u8 Protocol;
281 u8 Reserved;
282 } TYPE1_IPV4;
284 struct _TYPE1_IPV6{
285 u8 Priority;
286 u8 ClassifierType;
287 u8 Mask;
288 u8 Version;
289 u8 SrcIP[16];
290 u8 DstIP[16];
291 u16 SrcPort;
292 u16 DstPort;
293 u8 FlowLabel[3];
294 } TYPE1_IPV6;
296 struct _TYPE2_8021Q{
297 u8 Priority;
298 u8 ClassifierType;
299 u8 Mask;
300 u16 TagType;
301 } TYPE2_8021Q;
302 } QOS_TCLAS, *PQOS_TCLAS;
304 typedef struct _QOS_TSTREAM{
306 bool bUsed;
307 u16 MsduLifetime;
308 bool bEstablishing;
309 u8 TimeSlotCount;
310 u8 DialogToken;
311 struct wmm_tspec TSpec;
312 struct wmm_tspec OutStandingTSpec;
313 u8 NominalPhyRate;
314 } QOS_TSTREAM, *PQOS_TSTREAM;
316 typedef struct _STA_QOS{
317 u8 WMMIEBuf[MAX_WMMELE_LENGTH];
318 u8* WMMIE;
320 QOS_MODE QosCapability;
321 QOS_MODE CurrentQosMode;
323 AC_UAPSD b4ac_Uapsd;
324 AC_UAPSD Curr4acUapsd;
325 u8 bInServicePeriod;
326 u8 MaxSPLength;
327 int NumBcnBeforeTrigger;
329 u8 * pWMMInfoEle;
330 u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
332 ACM acm[4];
333 ACM_METHOD AcmMethod;
335 QOS_TSTREAM StaTsArray[MAX_STA_TS_COUNT];
336 u8 DialogToken;
337 struct wmm_tspec TSpec;
339 u8 QBssWirelessMode;
341 bool bNoAck;
343 bool bEnableRxImmBA;
345 }STA_QOS, *PSTA_QOS;
347 #define QBSS_LOAD_SIZE 5
348 #define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart)
349 #define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value)
350 #define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2)
351 #define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value)
352 #define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3)
353 #define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value)
355 struct bss_qos {
357 QOS_MODE bdQoSMode;
358 u8 bdWMMIEBuf[MAX_WMMELE_LENGTH];
359 OCTET_STRING bdWMMIE;
361 QOS_ELE_SUBTYPE EleSubType;
363 u8* pWMMInfoEle;
364 u8* pWMMParamEle;
366 u8 QBssLoad[QBSS_LOAD_SIZE];
367 bool bQBssLoadValid;
368 };//, *struct bss_qos *;
370 #define sQoSCtlLng 2
371 #define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 )
374 #define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false )
377 typedef union _ACI_AIFSN{
378 u8 charData;
380 struct
382 u8 AIFSN:4;
383 u8 ACM:1;
384 u8 ACI:2;
385 u8 Reserved:1;
387 }ACI_AIFSN, *PACI_AIFSN;
389 typedef union _ECW{
390 u8 charData;
391 struct
393 u8 ECWmin:4;
394 u8 ECWmax:4;
396 }ECW, *PECW;
398 typedef union _AC_PARAM{
399 u32 longData;
400 u8 charData[4];
402 struct
404 ACI_AIFSN AciAifsn;
405 ECW Ecw;
406 u16 TXOPLimit;
408 }AC_PARAM, *PAC_PARAM;
414 #endif