blob: 0d2f8bff4748a34512de29f5c3176a36aca9dbab [file] [log] [blame]
Larry Finger94a79942011-08-23 19:00:42 -05001/******************************************************************************
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
Larry Finger42c53e72011-07-19 10:24:09 -050057union qos_tsinfo {
Larry Finger94a79942011-08-23 19:00:42 -050058 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;
Larry Finger42c53e72011-07-19 10:24:09 -050071};
72
Larry Fingered306e42011-07-19 10:25:55 -050073union tspec_body {
Larry Finger94a79942011-08-23 19:00:42 -050074 u8 charData[55];
75
76 struct
77 {
Larry Finger42c53e72011-07-19 10:24:09 -050078 union qos_tsinfo TSInfo;
Larry Finger94a79942011-08-23 19:00:42 -050079 u16 NominalMSDUsize;
80 u16 MaxMSDUsize;
81 u32 MinServiceItv;
82 u32 MaxServiceItv;
83 u32 InactivityItv;
84 u32 SuspenItv;
85 u32 ServiceStartTime;
86 u32 MinDataRate;
87 u32 MeanDataRate;
88 u32 PeakDataRate;
89 u32 MaxBurstSize;
90 u32 DelayBound;
91 u32 MinPhyRate;
92 u16 SurplusBandwidthAllowance;
93 u16 MediumTime;
94 } f;
Larry Fingered306e42011-07-19 10:25:55 -050095};
Larry Finger94a79942011-08-23 19:00:42 -050096
Larry Finger95ce5fc2011-07-18 21:55:05 -050097struct wmm_tspec {
Larry Finger94a79942011-08-23 19:00:42 -050098 u8 ID;
99 u8 Length;
100 u8 OUI[3];
101 u8 OUI_Type;
102 u8 OUI_SubType;
103 u8 Version;
Larry Fingered306e42011-07-19 10:25:55 -0500104 union tspec_body Body;
Larry Finger95ce5fc2011-07-18 21:55:05 -0500105};
Larry Finger94a79942011-08-23 19:00:42 -0500106
Larry Finger8310b6c02011-07-18 21:57:13 -0500107struct octet_string {
Larry Finger94a79942011-08-23 19:00:42 -0500108 u8 *Octet;
109 u16 Length;
Larry Fingerd3b2c172011-07-19 12:50:41 -0500110};
Larry Finger94a79942011-08-23 19:00:42 -0500111#define MAX_WMMELE_LENGTH 64
112
Larry Finger9de9f962011-07-19 21:17:25 -0500113#define QOS_MODE u32
114
Larry Finger94a79942011-08-23 19:00:42 -0500115#define QOS_DISABLE 0
116#define QOS_WMM 1
117#define QOS_WMMSA 2
118#define QOS_EDCA 4
119#define QOS_HCCA 8
120#define QOS_WMM_UAPSD 16
121
122#define WMM_PARAM_ELE_BODY_LEN 18
123
124#define MAX_STA_TS_COUNT 16
125#define MAX_AP_TS_COUNT 32
126#define QOS_TSTREAM_KEY_SIZE 13
127
128#define WMM_ACTION_CATEGORY_CODE 17
129#define WMM_PARAM_ELE_BODY_LEN 18
130
131#define MAX_TSPEC_TSID 15
132#define SESSION_REJECT_TSID 0xfe
133#define DEFAULT_TSID 0xff
134
135#define ADDTS_TIME_SLOT 100
136
137#define ACM_TIMEOUT 1000
138#define SESSION_REJECT_TIMEOUT 60000
139
Larry Finger4164e4d2011-07-19 19:24:06 -0500140enum ack_policy {
Larry Finger94a79942011-08-23 19:00:42 -0500141 eAckPlc0_ACK = 0x00,
142 eAckPlc1_NoACK = 0x01,
Larry Finger4164e4d2011-07-19 19:24:06 -0500143};
Larry Finger94a79942011-08-23 19:00:42 -0500144
145
146#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val)
147
148#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4)
149#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val)
150
151#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1)
152#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val)
153
154#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1)
155#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val)
156
157#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1)
158#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val)
159
160#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1)
161#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val)
162
163#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1)
164#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val)
165
166#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2)
167#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val)
168
Larry Fingerf58a1cd2011-07-19 19:27:05 -0500169enum qos_ie_source {
Larry Finger94a79942011-08-23 19:00:42 -0500170 QOSIE_SRC_ADDTSREQ,
171 QOSIE_SRC_ADDTSRSP,
172 QOSIE_SRC_REASOCREQ,
173 QOSIE_SRC_REASOCRSP,
174 QOSIE_SRC_DELTS,
Larry Fingerf58a1cd2011-07-19 19:27:05 -0500175};
Larry Finger94a79942011-08-23 19:00:42 -0500176
177
Larry Finger9de9f962011-07-19 21:17:25 -0500178#define AC_CODING u32
179
Larry Finger94a79942011-08-23 19:00:42 -0500180#define AC0_BE 0
181#define AC1_BK 1
182#define AC2_VI 2
183#define AC3_VO 3
184#define AC_MAX 4
185
186
187#define AC_PARAM_SIZE 4
188
189#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) )
190#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val)
191
192#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) )
193#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val)
194
195#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) )
196#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val)
197
198#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) )
199#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val)
200
201#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) )
202#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val)
203
204#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) )
205#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val)
206
207#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) )
208#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val)
209
210
211
212#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE))
213
Larry Fingerf58a1cd2011-07-19 19:27:05 -0500214enum qos_ele_subtype {
Larry Finger94a79942011-08-23 19:00:42 -0500215 QOSELE_TYPE_INFO = 0x00,
216 QOSELE_TYPE_PARAM = 0x01,
Larry Fingerf58a1cd2011-07-19 19:27:05 -0500217};
Larry Finger94a79942011-08-23 19:00:42 -0500218
219
Larry Fingerf12dfcb2011-07-19 19:28:39 -0500220enum direction_value {
Larry Finger94a79942011-08-23 19:00:42 -0500221 DIR_UP = 0,
222 DIR_DOWN = 1,
223 DIR_DIRECT = 2,
224 DIR_BI_DIR = 3,
Larry Fingerf12dfcb2011-07-19 19:28:39 -0500225};
Larry Finger94a79942011-08-23 19:00:42 -0500226
Larry Finger379a20f2011-07-19 19:30:04 -0500227enum acm_method {
Larry Finger94a79942011-08-23 19:00:42 -0500228 eAcmWay0_SwAndHw = 0,
229 eAcmWay1_HW = 1,
230 eAcmWay2_SW = 2,
Larry Finger379a20f2011-07-19 19:30:04 -0500231};
Larry Finger94a79942011-08-23 19:00:42 -0500232
233
Larry Fingerb0d7de72011-07-18 22:21:17 -0500234struct acm {
Larry Finger94a79942011-08-23 19:00:42 -0500235 u64 UsedTime;
236 u64 MediumTime;
237 u8 HwAcmCtl;
Larry Fingerd3b2c172011-07-19 12:50:41 -0500238};
Larry Finger94a79942011-08-23 19:00:42 -0500239
240
241
Larry Finger9de9f962011-07-19 21:17:25 -0500242#define AC_UAPSD u8
Larry Finger94a79942011-08-23 19:00:42 -0500243
244#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
245#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
246
247#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
248#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
249
250#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
251#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
252
253#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
254#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
255
Larry Finger626f9512011-07-19 10:27:46 -0500256union qos_tclas {
Larry Finger94a79942011-08-23 19:00:42 -0500257
258 struct _TYPE_GENERAL{
259 u8 Priority;
260 u8 ClassifierType;
261 u8 Mask;
262 } TYPE_GENERAL;
263
264 struct _TYPE0_ETH{
265 u8 Priority;
266 u8 ClassifierType;
267 u8 Mask;
268 u8 SrcAddr[6];
269 u8 DstAddr[6];
270 u16 Type;
271 } TYPE0_ETH;
272
273 struct _TYPE1_IPV4{
274 u8 Priority;
275 u8 ClassifierType;
276 u8 Mask;
277 u8 Version;
278 u8 SrcIP[4];
279 u8 DstIP[4];
280 u16 SrcPort;
281 u16 DstPort;
282 u8 DSCP;
283 u8 Protocol;
284 u8 Reserved;
285 } TYPE1_IPV4;
286
287 struct _TYPE1_IPV6{
288 u8 Priority;
289 u8 ClassifierType;
290 u8 Mask;
291 u8 Version;
292 u8 SrcIP[16];
293 u8 DstIP[16];
294 u16 SrcPort;
295 u16 DstPort;
296 u8 FlowLabel[3];
297 } TYPE1_IPV6;
298
299 struct _TYPE2_8021Q{
300 u8 Priority;
301 u8 ClassifierType;
302 u8 Mask;
303 u16 TagType;
304 } TYPE2_8021Q;
Larry Finger626f9512011-07-19 10:27:46 -0500305};
Larry Finger94a79942011-08-23 19:00:42 -0500306
Larry Finger1d2a55f2011-07-18 21:58:49 -0500307struct qos_tstream {
Larry Finger94a79942011-08-23 19:00:42 -0500308
309 bool bUsed;
310 u16 MsduLifetime;
311 bool bEstablishing;
312 u8 TimeSlotCount;
313 u8 DialogToken;
Larry Finger95ce5fc2011-07-18 21:55:05 -0500314 struct wmm_tspec TSpec;
315 struct wmm_tspec OutStandingTSpec;
Larry Finger94a79942011-08-23 19:00:42 -0500316 u8 NominalPhyRate;
Larry Finger1d2a55f2011-07-18 21:58:49 -0500317};
Larry Finger94a79942011-08-23 19:00:42 -0500318
Larry Finger0db42792011-07-18 22:01:50 -0500319struct sta_qos {
Larry Finger94a79942011-08-23 19:00:42 -0500320 u8 WMMIEBuf[MAX_WMMELE_LENGTH];
321 u8* WMMIE;
322
323 QOS_MODE QosCapability;
324 QOS_MODE CurrentQosMode;
325
326 AC_UAPSD b4ac_Uapsd;
327 AC_UAPSD Curr4acUapsd;
328 u8 bInServicePeriod;
329 u8 MaxSPLength;
330 int NumBcnBeforeTrigger;
331
332 u8 * pWMMInfoEle;
333 u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
334
Larry Fingerb0d7de72011-07-18 22:21:17 -0500335 struct acm acm[4];
Larry Finger379a20f2011-07-19 19:30:04 -0500336 enum acm_method AcmMethod;
Larry Finger94a79942011-08-23 19:00:42 -0500337
Larry Finger1d2a55f2011-07-18 21:58:49 -0500338 struct qos_tstream StaTsArray[MAX_STA_TS_COUNT];
Larry Finger94a79942011-08-23 19:00:42 -0500339 u8 DialogToken;
Larry Finger95ce5fc2011-07-18 21:55:05 -0500340 struct wmm_tspec TSpec;
Larry Finger94a79942011-08-23 19:00:42 -0500341
342 u8 QBssWirelessMode;
343
344 bool bNoAck;
345
346 bool bEnableRxImmBA;
347
Larry Fingerd3b2c172011-07-19 12:50:41 -0500348};
Larry Finger94a79942011-08-23 19:00:42 -0500349
350#define QBSS_LOAD_SIZE 5
351#define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart)
352#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value)
353#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2)
354#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value)
355#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3)
356#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value)
357
Larry Finger0157d2e2011-07-18 20:04:31 -0500358struct bss_qos {
Larry Finger94a79942011-08-23 19:00:42 -0500359
360 QOS_MODE bdQoSMode;
361 u8 bdWMMIEBuf[MAX_WMMELE_LENGTH];
Larry Finger8310b6c02011-07-18 21:57:13 -0500362 struct octet_string bdWMMIE;
Larry Finger94a79942011-08-23 19:00:42 -0500363
Larry Fingerf58a1cd2011-07-19 19:27:05 -0500364 enum qos_ele_subtype EleSubType;
Larry Finger94a79942011-08-23 19:00:42 -0500365
366 u8* pWMMInfoEle;
367 u8* pWMMParamEle;
368
369 u8 QBssLoad[QBSS_LOAD_SIZE];
370 bool bQBssLoadValid;
Larry Fingerd3b2c172011-07-19 12:50:41 -0500371};
Larry Finger94a79942011-08-23 19:00:42 -0500372
373#define sQoSCtlLng 2
374#define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 )
375
376
377#define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false )
378
379
Larry Finger44a40042011-07-19 10:29:41 -0500380union aci_aifsn {
Larry Finger94a79942011-08-23 19:00:42 -0500381 u8 charData;
382
383 struct
384 {
385 u8 AIFSN:4;
Larry Fingerb0d7de72011-07-18 22:21:17 -0500386 u8 acm:1;
Larry Finger94a79942011-08-23 19:00:42 -0500387 u8 ACI:2;
388 u8 Reserved:1;
389 }f;
Larry Finger44a40042011-07-19 10:29:41 -0500390};
Larry Finger94a79942011-08-23 19:00:42 -0500391
Larry Fingera33be1e2011-07-19 10:31:43 -0500392union ecw {
Larry Finger94a79942011-08-23 19:00:42 -0500393 u8 charData;
394 struct
395 {
396 u8 ECWmin:4;
397 u8 ECWmax:4;
398 }f;
Larry Fingera33be1e2011-07-19 10:31:43 -0500399};
Larry Finger94a79942011-08-23 19:00:42 -0500400
Larry Fingereb85e462011-07-19 10:35:19 -0500401union ac_param {
Larry Finger94a79942011-08-23 19:00:42 -0500402 u32 longData;
403 u8 charData[4];
404
405 struct
406 {
Larry Finger44a40042011-07-19 10:29:41 -0500407 union aci_aifsn AciAifsn;
Larry Fingera33be1e2011-07-19 10:31:43 -0500408 union ecw Ecw;
Larry Finger94a79942011-08-23 19:00:42 -0500409 u16 TXOPLimit;
410 }f;
Larry Fingereb85e462011-07-19 10:35:19 -0500411};
Larry Finger94a79942011-08-23 19:00:42 -0500412
413#endif