summaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
blob: 928062f357136585fc3b5987b98ddcfe187b9f77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
/******************************************************************************
 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
******************************************************************************/
#ifndef __INC_QOS_TYPE_H
#define __INC_QOS_TYPE_H

#define BIT0                    0x00000001
#define BIT1                    0x00000002
#define BIT2                    0x00000004
#define BIT3                    0x00000008
#define BIT4                    0x00000010
#define BIT5                    0x00000020
#define BIT6                    0x00000040
#define BIT7                    0x00000080
#define BIT8                    0x00000100
#define BIT9                    0x00000200
#define BIT10                   0x00000400
#define BIT11                   0x00000800
#define BIT12                   0x00001000
#define BIT13                   0x00002000
#define BIT14                   0x00004000
#define BIT15                   0x00008000
#define BIT16                   0x00010000
#define BIT17                   0x00020000
#define BIT18                   0x00040000
#define BIT19                   0x00080000
#define BIT20                   0x00100000
#define BIT21                   0x00200000
#define BIT22                   0x00400000
#define BIT23                   0x00800000
#define BIT24                   0x01000000
#define BIT25                   0x02000000
#define BIT26                   0x04000000
#define BIT27                   0x08000000
#define BIT28                   0x10000000
#define BIT29                   0x20000000
#define BIT30                   0x40000000
#define BIT31                   0x80000000

#define	MAX_WMMELE_LENGTH	64

typedef u32 QOS_MODE, *PQOS_MODE;
#define QOS_DISABLE		0
#define QOS_WMM			1
#define QOS_WMMSA		2
#define QOS_EDCA		4
#define QOS_HCCA		8
#define QOS_WMM_UAPSD		16   //WMM Power Save, 2006-06-14 Isaiah

#define AC_PARAM_SIZE	4
#define WMM_PARAM_ELE_BODY_LEN	18

//
// QoS ACK Policy Field Values
// Ref: WMM spec 2.1.6: QoS Control Field, p.10.
//
typedef	enum _ACK_POLICY{
	eAckPlc0_ACK		= 0x00,
	eAckPlc1_NoACK		= 0x01,
}ACK_POLICY,*PACK_POLICY;

#define WMM_PARAM_ELEMENT_SIZE	(8+(4*AC_PARAM_SIZE))

//
// QoS Control Field
// Ref:
//	1. WMM spec 2.1.6: QoS Control Field, p.9.
//	2. 802.11e/D13.0 7.1.3.5, p.26.
//
typedef	union _QOS_CTRL_FIELD{
	u8	charData[2];
	u16	shortData;

	// WMM spec
	struct
	{
		u8		UP:3;
		u8		usRsvd1:1;
		u8		EOSP:1;
		u8		AckPolicy:2;
		u8		usRsvd2:1;
		u8		ucRsvdByte;
	}WMM;

	// 802.11e: QoS data type frame sent by non-AP QSTAs.
	struct
	{
		u8		TID:4;
		u8		bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
		u8		AckPolicy:2;
		u8		usRsvd:1;
		u8		TxopOrQsize;	// (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
	}BySta;

	// 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
	struct
	{
		u8		TID:4;
		u8		EOSP:1;
		u8		AckPolicy:2;
		u8		usRsvd:1;
		u8		PSBufState;		// QAP PS Buffer State.
	}ByHc_Data;

	// 802.11e: QoS (+) CF-Poll frames sent by HC.
	struct
	{
		u8		TID:4;
		u8		EOSP:1;
		u8		AckPolicy:2;
		u8		usRsvd:1;
		u8		TxopLimit;		// TXOP Limit.
	}ByHc_CFP;

}QOS_CTRL_FIELD, *PQOS_CTRL_FIELD;


//
// QoS Info Field
// Ref:
//	1. WMM spec 2.2.1: WME Information Element, p.11.
//	2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
//
typedef	union _QOS_INFO_FIELD{
	u8	charData;

	struct
	{
		u8		ucParameterSetCount:4;
		u8		ucReserved:4;
	}WMM;

	struct
	{
		//Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
		u8		ucAC_VO_UAPSD:1;
		u8		ucAC_VI_UAPSD:1;
		u8		ucAC_BE_UAPSD:1;
		u8		ucAC_BK_UAPSD:1;
		u8		ucReserved1:1;
		u8		ucMaxSPLen:2;
		u8		ucReserved2:1;

	}ByWmmPsSta;

	struct
	{
		//Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
		u8		ucParameterSetCount:4;
		u8		ucReserved:3;
		u8		ucApUapsd:1;
	}ByWmmPsAp;

	struct
	{
		u8		ucAC3_UAPSD:1;
		u8		ucAC2_UAPSD:1;
		u8		ucAC1_UAPSD:1;
		u8		ucAC0_UAPSD:1;
		u8		ucQAck:1;
		u8		ucMaxSPLen:2;
		u8		ucMoreDataAck:1;
	} By11eSta;

	struct
	{
		u8		ucParameterSetCount:4;
		u8		ucQAck:1;
		u8		ucQueueReq:1;
		u8		ucTXOPReq:1;
		u8		ucReserved:1;
	} By11eAp;

	struct
	{
		u8		ucReserved1:4;
		u8		ucQAck:1;
		u8		ucReserved2:2;
		u8		ucMoreDataAck:1;
	} ByWmmsaSta;

	struct
	{
		u8		ucReserved1:4;
		u8		ucQAck:1;
		u8		ucQueueReq:1;
		u8		ucTXOPReq:1;
		u8		ucReserved2:1;
	} ByWmmsaAp;

	struct
	{
		u8		ucAC3_UAPSD:1;
		u8		ucAC2_UAPSD:1;
		u8		ucAC1_UAPSD:1;
		u8		ucAC0_UAPSD:1;
		u8		ucQAck:1;
		u8		ucMaxSPLen:2;
		u8		ucMoreDataAck:1;
	} ByAllSta;

	struct
	{
		u8		ucParameterSetCount:4;
		u8		ucQAck:1;
		u8		ucQueueReq:1;
		u8		ucTXOPReq:1;
		u8		ucApUapsd:1;
	} ByAllAp;

}QOS_INFO_FIELD, *PQOS_INFO_FIELD;

typedef u32 AC_CODING;
#define AC0_BE	0		// ACI: 0x00	// Best Effort
#define AC1_BK	1		// ACI: 0x01	// Background
#define AC2_VI	2		// ACI: 0x10	// Video
#define AC3_VO	3		// ACI: 0x11	// Voice
#define AC_MAX	4		// Max: define total number; Should not to be used as a real enum.

//
// ACI/AIFSN Field.
// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
//
typedef	union _ACI_AIFSN{
	u8	charData;

	struct
	{
		u8	AIFSN:4;
		u8	ACM:1;
		u8	ACI:2;
		u8	Reserved:1;
	}f;
}ACI_AIFSN, *PACI_AIFSN;

//
// ECWmin/ECWmax field.
// Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
//
typedef	union _ECW{
	u8	charData;
	struct
	{
		u8	ECWmin:4;
		u8	ECWmax:4;
	}f;
}ECW, *PECW;

//
// AC Parameters Record Format.
// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
//
typedef	union _AC_PARAM{
	u32	longData;
	u8	charData[4];

	struct
	{
		ACI_AIFSN	AciAifsn;
		ECW		Ecw;
		u16		TXOPLimit;
	}f;
}AC_PARAM, *PAC_PARAM;



//
// QoS element subtype
//
typedef	enum _QOS_ELE_SUBTYPE{
	QOSELE_TYPE_INFO	= 0x00,		// 0x00: Information element
	QOSELE_TYPE_PARAM	= 0x01,		// 0x01: parameter element
}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;


//
// Direction Field Values.
// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
//
typedef	enum _DIRECTION_VALUE{
	DIR_UP			= 0,		// 0x00	// UpLink
	DIR_DOWN		= 1,		// 0x01	// DownLink
	DIR_DIRECT		= 2,		// 0x10	// DirectLink
	DIR_BI_DIR		= 3,		// 0x11	// Bi-Direction
}DIRECTION_VALUE,*PDIRECTION_VALUE;


//
// TS Info field in WMM TSPEC Element.
// Ref:
//	1. WMM spec 2.2.11: WME TSPEC Element, p.18.
//	2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
//
typedef union _QOS_TSINFO{
	u8		charData[3];
	struct {
		u8		ucTrafficType:1;			//WMM is reserved
		u8		ucTSID:4;
		u8		ucDirection:2;
		u8		ucAccessPolicy:2;	//WMM: bit8=0, bit7=1
		u8		ucAggregation:1;		//WMM is reserved
		u8		ucPSB:1;				//WMMSA is APSD
		u8		ucUP:3;
		u8		ucTSInfoAckPolicy:2;		//WMM is reserved
		u8		ucSchedule:1;			//WMM is reserved
		u8		ucReserved:7;
	}field;
}QOS_TSINFO, *PQOS_TSINFO;

//
// WMM TSPEC Body.
// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
//
typedef union _TSPEC_BODY{
	u8		charData[55];

	struct
	{
		QOS_TSINFO	TSInfo;	//u8	TSInfo[3];
		u16	NominalMSDUsize;
		u16	MaxMSDUsize;
		u32	MinServiceItv;
		u32	MaxServiceItv;
		u32	InactivityItv;
		u32	SuspenItv;
		u32	ServiceStartTime;
		u32	MinDataRate;
		u32	MeanDataRate;
		u32	PeakDataRate;
		u32	MaxBurstSize;
		u32	DelayBound;
		u32	MinPhyRate;
		u16	SurplusBandwidthAllowance;
		u16	MediumTime;
	} f;
}TSPEC_BODY, *PTSPEC_BODY;


//
// WMM TSPEC Element.
// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
//
typedef struct _WMM_TSPEC{
	u8		ID;
	u8		Length;
	u8		OUI[3];
	u8		OUI_Type;
	u8		OUI_SubType;
	u8		Version;
	TSPEC_BODY	Body;
} WMM_TSPEC, *PWMM_TSPEC;

//
// ACM implementation method.
// Annie, 2005-12-13.
//
typedef	enum _ACM_METHOD{
	eAcmWay0_SwAndHw		= 0,		// By SW and HW.
	eAcmWay1_HW			= 1,		// By HW.
	eAcmWay2_SW			= 2,		// By SW.
}ACM_METHOD,*PACM_METHOD;


typedef struct _ACM{
	u64		UsedTime;
	u64		MediumTime;
	u8		HwAcmCtl;	// TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
}ACM, *PACM;

typedef	u8		AC_UAPSD, *PAC_UAPSD;

#define	GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
#define	SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)

#define	GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
#define	SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)

#define	GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
#define	SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)

#define	GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
#define	SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)

typedef union _QOS_TCLAS{

	struct _TYPE_GENERAL{
		u8		Priority;
		u8 		ClassifierType;
		u8 		Mask;
	} TYPE_GENERAL;

	struct _TYPE0_ETH{
		u8		Priority;
		u8 		ClassifierType;
		u8 		Mask;
		u8		SrcAddr[6];
		u8		DstAddr[6];
		u16		Type;
	} TYPE0_ETH;

	struct _TYPE1_IPV4{
		u8		Priority;
		u8 		ClassifierType;
		u8 		Mask;
		u8 		Version;
		u8		SrcIP[4];
		u8		DstIP[4];
		u16		SrcPort;
		u16		DstPort;
		u8		DSCP;
		u8		Protocol;
		u8		Reserved;
	} TYPE1_IPV4;

	struct _TYPE1_IPV6{
		u8		Priority;
		u8 		ClassifierType;
		u8 		Mask;
		u8 		Version;
		u8		SrcIP[16];
		u8		DstIP[16];
		u16		SrcPort;
		u16		DstPort;
		u8		FlowLabel[3];
	} TYPE1_IPV6;

	struct _TYPE2_8021Q{
		u8		Priority;
		u8 		ClassifierType;
		u8 		Mask;
		u16		TagType;
	} TYPE2_8021Q;
} QOS_TCLAS, *PQOS_TCLAS;

typedef struct _QOS_TSTREAM{
	u8			AC;
	WMM_TSPEC		TSpec;
	QOS_TCLAS		TClass;
} QOS_TSTREAM, *PQOS_TSTREAM;

//----------------------------------------------------------------------------
//      802.11 Management frame Status Code field
//----------------------------------------------------------------------------
typedef struct _OCTET_STRING{
        u8        	*Octet;
        u16             Length;
}OCTET_STRING, *POCTET_STRING;

//
// STA QoS data.
// Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
//
typedef struct _STA_QOS{
	u8				WMMIEBuf[MAX_WMMELE_LENGTH];
	u8*				WMMIE;

	// Part 1. Self QoS Mode.
	QOS_MODE			QosCapability; //QoS Capability, 2006-06-14 Isaiah
	QOS_MODE			CurrentQosMode;

	// For WMM Power Save Mode :
	// ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
	AC_UAPSD			b4ac_Uapsd;  //VoUapsd(bit0), ViUapsd(bit1),  BkUapsd(bit2), BeUapsd(bit3),
	AC_UAPSD			Curr4acUapsd;
	u8				bInServicePeriod;
	u8				MaxSPLength;
	int 				NumBcnBeforeTrigger;

	// Part 2. EDCA Parameter (perAC)
	u8 *				pWMMInfoEle;
	u8				WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
	u8				WMMPELength;

	// <Bruce_Note>
	//2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
	// By Bruce, 2008-01-30.
	// Part 2. EDCA Parameter (perAC)
	QOS_INFO_FIELD			QosInfoField_STA; 	// Maintained by STA
	QOS_INFO_FIELD			QosInfoField_AP;	// Retrieved from AP

	AC_PARAM			CurAcParameters[4];

	// Part 3. ACM
	ACM				acm[4];
	ACM_METHOD			AcmMethod;

	// Part 4. Per TID (Part 5: TCLASS will be described by TStream)
	QOS_TSTREAM			TStream[16];
	WMM_TSPEC			TSpec;

	u32				QBssWirelessMode;

	// No Ack Setting
	u8				bNoAck;

	// Enable/Disable Rx immediate BA capability.
	u8				bEnableRxImmBA;

}STA_QOS, *PSTA_QOS;

//
// BSS QOS data.
// Ref: BssDscr in 8185 code. [def. in BssDscr.h]
//
typedef struct _BSS_QOS{
	QOS_MODE		bdQoSMode;

	u8			bdWMMIEBuf[MAX_WMMELE_LENGTH];
	u8*		bdWMMIE;

	QOS_ELE_SUBTYPE		EleSubType;

	u8 *			pWMMInfoEle;
	u8 *			pWMMParamEle;

	QOS_INFO_FIELD		QosInfoField;
	AC_PARAM		AcParameter[4];
}BSS_QOS, *PBSS_QOS;

#define sQoSCtlLng			2
#define	QOS_CTRL_LEN(_QosMode)		((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)

#define IsACValid(ac)			((ac<=7 )?true:false )

#endif
OpenPOWER on IntegriCloud