• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
51 typedef u32 QOS_MODE, *PQOS_MODE;
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,
68 	eAckPlc1_NoACK		= 0x01,
69 } ACK_POLICY, *PACK_POLICY;
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{
80 	u8	charData[2];
81 	u16	shortData;
82 
83 	// WMM spec
84 	struct {
85 		u8		UP:3;
86 		u8		usRsvd1:1;
87 		u8		EOSP:1;
88 		u8		AckPolicy:2;
89 		u8		usRsvd2:1;
90 		u8		ucRsvdByte;
91 	}WMM;
92 
93 	// 802.11e: QoS data type frame sent by non-AP QSTAs.
94 	struct {
95 		u8		TID:4;
96 		u8		bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
97 		u8		AckPolicy:2;
98 		u8		usRsvd:1;
99 		u8		TxopOrQsize;	// (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
100 	}BySta;
101 
102 	// 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
103 	struct {
104 		u8		TID:4;
105 		u8		EOSP:1;
106 		u8		AckPolicy:2;
107 		u8		usRsvd:1;
108 		u8		PSBufState;		// QAP PS Buffer State.
109 	}ByHc_Data;
110 
111 	// 802.11e: QoS (+) CF-Poll frames sent by HC.
112 	struct {
113 		u8		TID:4;
114 		u8		EOSP:1;
115 		u8		AckPolicy:2;
116 		u8		usRsvd:1;
117 		u8		TxopLimit;		// TXOP Limit.
118 	}ByHc_CFP;
119 
120 }QOS_CTRL_FIELD, *PQOS_CTRL_FIELD;
121 
122 
123 //
124 // QoS Info Field
125 // Ref:
126 //	1. WMM spec 2.2.1: WME Information Element, p.11.
127 //	2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
128 //
129 typedef	union _QOS_INFO_FIELD{
130 	u8	charData;
131 
132 	struct {
133 		u8		ucParameterSetCount:4;
134 		u8		ucReserved:4;
135 	}WMM;
136 
137 	struct {
138 		//Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
139 		u8		ucAC_VO_UAPSD:1;
140 		u8		ucAC_VI_UAPSD:1;
141 		u8		ucAC_BE_UAPSD:1;
142 		u8		ucAC_BK_UAPSD:1;
143 		u8		ucReserved1:1;
144 		u8		ucMaxSPLen:2;
145 		u8		ucReserved2:1;
146 
147 	}ByWmmPsSta;
148 
149 	struct {
150 		//Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
151 		u8		ucParameterSetCount:4;
152 		u8		ucReserved:3;
153 		u8		ucApUapsd:1;
154 	}ByWmmPsAp;
155 
156 	struct {
157 		u8		ucAC3_UAPSD:1;
158 		u8		ucAC2_UAPSD:1;
159 		u8		ucAC1_UAPSD:1;
160 		u8		ucAC0_UAPSD:1;
161 		u8		ucQAck:1;
162 		u8		ucMaxSPLen:2;
163 		u8		ucMoreDataAck:1;
164 	} By11eSta;
165 
166 	struct {
167 		u8		ucParameterSetCount:4;
168 		u8		ucQAck:1;
169 		u8		ucQueueReq:1;
170 		u8		ucTXOPReq:1;
171 		u8		ucReserved:1;
172 	} By11eAp;
173 
174 	struct {
175 		u8		ucReserved1:4;
176 		u8		ucQAck:1;
177 		u8		ucReserved2:2;
178 		u8		ucMoreDataAck:1;
179 	} ByWmmsaSta;
180 
181 	struct {
182 		u8		ucReserved1:4;
183 		u8		ucQAck:1;
184 		u8		ucQueueReq:1;
185 		u8		ucTXOPReq:1;
186 		u8		ucReserved2:1;
187 	} ByWmmsaAp;
188 
189 	struct {
190 		u8		ucAC3_UAPSD:1;
191 		u8		ucAC2_UAPSD:1;
192 		u8		ucAC1_UAPSD:1;
193 		u8		ucAC0_UAPSD:1;
194 		u8		ucQAck:1;
195 		u8		ucMaxSPLen:2;
196 		u8		ucMoreDataAck:1;
197 	} ByAllSta;
198 
199 	struct {
200 		u8		ucParameterSetCount:4;
201 		u8		ucQAck:1;
202 		u8		ucQueueReq:1;
203 		u8		ucTXOPReq:1;
204 		u8		ucApUapsd:1;
205 	} ByAllAp;
206 
207 }QOS_INFO_FIELD, *PQOS_INFO_FIELD;
208 
209 //
210 // ACI to AC coding.
211 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
212 //
213 // AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
214 //typedef	enum _AC_CODING{
215 //	AC0_BE	= 0,		// ACI: 0x00	// Best Effort
216 //	AC1_BK	= 1,		// ACI: 0x01	// Background
217 //	AC2_VI	= 2,		// ACI: 0x10	// Video
218 //	AC3_VO	= 3,		// ACI: 0x11	// Voice
219 //	AC_MAX = 4,		// Max: define total number; Should not to be used as a real enum.
220 //}AC_CODING,*PAC_CODING;
221 //
222 typedef u32 AC_CODING;
223 #define AC0_BE	0		// ACI: 0x00	// Best Effort
224 #define AC1_BK	1		// ACI: 0x01	// Background
225 #define AC2_VI	2		// ACI: 0x10	// Video
226 #define AC3_VO	3		// ACI: 0x11	// Voice
227 #define AC_MAX	4		// Max: define total number; Should not to be used as a real enum.
228 
229 //
230 // ACI/AIFSN Field.
231 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
232 //
233 typedef	union _ACI_AIFSN{
234 	u8	charData;
235 
236 	struct {
237 		u8	AIFSN:4;
238 		u8	ACM:1;
239 		u8	ACI:2;
240 		u8	Reserved:1;
241 	}f;	// Field
242 }ACI_AIFSN, *PACI_AIFSN;
243 
244 //
245 // ECWmin/ECWmax field.
246 // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
247 //
248 typedef	union _ECW{
249 	u8	charData;
250 	struct {
251 		u8	ECWmin:4;
252 		u8	ECWmax:4;
253 	}f;	// Field
254 }ECW, *PECW;
255 
256 //
257 // AC Parameters Record Format.
258 // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
259 //
260 typedef	union _AC_PARAM{
261 	u32	longData;
262 	u8	charData[4];
263 
264 	struct {
265 		ACI_AIFSN	AciAifsn;
266 		ECW		Ecw;
267 		u16		TXOPLimit;
268 	}f;	// Field
269 }AC_PARAM, *PAC_PARAM;
270 
271 
272 
273 //
274 // QoS element subtype
275 //
276 typedef	enum _QOS_ELE_SUBTYPE{
277 	QOSELE_TYPE_INFO	= 0x00,		// 0x00: Information element
278 	QOSELE_TYPE_PARAM	= 0x01,		// 0x01: parameter element
279 } QOS_ELE_SUBTYPE, *PQOS_ELE_SUBTYPE;
280 
281 
282 //
283 // Direction Field Values.
284 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
285 //
286 typedef	enum _DIRECTION_VALUE{
287 	DIR_UP			= 0,		// 0x00	// UpLink
288 	DIR_DOWN		= 1,		// 0x01	// DownLink
289 	DIR_DIRECT		= 2,		// 0x10	// DirectLink
290 	DIR_BI_DIR		= 3,		// 0x11	// Bi-Direction
291 } DIRECTION_VALUE, *PDIRECTION_VALUE;
292 
293 
294 //
295 // TS Info field in WMM TSPEC Element.
296 // Ref:
297 //	1. WMM spec 2.2.11: WME TSPEC Element, p.18.
298 //	2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
299 //
300 typedef union _QOS_TSINFO{
301 	u8		charData[3];
302 	struct {
303 		u8		ucTrafficType:1;			//WMM is reserved
304 		u8		ucTSID:4;
305 		u8		ucDirection:2;
306 		u8		ucAccessPolicy:2;	//WMM: bit8=0, bit7=1
307 		u8		ucAggregation:1;		//WMM is reserved
308 		u8		ucPSB:1;				//WMMSA is APSD
309 		u8		ucUP:3;
310 		u8		ucTSInfoAckPolicy:2;		//WMM is reserved
311 		u8		ucSchedule:1;			//WMM is reserved
312 		u8		ucReserved:7;
313 	}field;
314 }QOS_TSINFO, *PQOS_TSINFO;
315 
316 //
317 // WMM TSPEC Body.
318 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
319 //
320 typedef union _TSPEC_BODY{
321 	u8		charData[55];
322 
323 	struct {
324 		QOS_TSINFO	TSInfo;	//u8	TSInfo[3];
325 		u16	NominalMSDUsize;
326 		u16	MaxMSDUsize;
327 		u32	MinServiceItv;
328 		u32	MaxServiceItv;
329 		u32	InactivityItv;
330 		u32	SuspenItv;
331 		u32	ServiceStartTime;
332 		u32	MinDataRate;
333 		u32	MeanDataRate;
334 		u32	PeakDataRate;
335 		u32	MaxBurstSize;
336 		u32	DelayBound;
337 		u32	MinPhyRate;
338 		u16	SurplusBandwidthAllowance;
339 		u16	MediumTime;
340 	} f;	// Field
341 }TSPEC_BODY, *PTSPEC_BODY;
342 
343 
344 //
345 // WMM TSPEC Element.
346 // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
347 //
348 typedef struct _WMM_TSPEC{
349 	u8		ID;
350 	u8		Length;
351 	u8		OUI[3];
352 	u8		OUI_Type;
353 	u8		OUI_SubType;
354 	u8		Version;
355 	TSPEC_BODY	Body;
356 } WMM_TSPEC, *PWMM_TSPEC;
357 
358 //
359 // ACM implementation method.
360 // Annie, 2005-12-13.
361 //
362 typedef	enum _ACM_METHOD{
363 	eAcmWay0_SwAndHw		= 0,		// By SW and HW.
364 	eAcmWay1_HW			= 1,		// By HW.
365 	eAcmWay2_SW			= 2,		// By SW.
366 } ACM_METHOD, *PACM_METHOD;
367 
368 
369 typedef struct _ACM{
370 //	u8		RegEnableACM;
371 	u64		UsedTime;
372 	u64		MediumTime;
373 	u8		HwAcmCtl;	// TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
374 }ACM, *PACM;
375 
376 typedef	u8		AC_UAPSD, *PAC_UAPSD;
377 
378 #define	GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
379 #define	SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
380 
381 #define	GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
382 #define	SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
383 
384 #define	GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
385 #define	SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
386 
387 #define	GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
388 #define	SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
389 
390 
391 //typedef struct _TCLASS{
392 // TODO
393 //} TCLASS, *PTCLASS;
394 typedef union _QOS_TCLAS{
395 
396 	struct _TYPE_GENERAL{
397 		u8		Priority;
398 		u8		ClassifierType;
399 		u8		Mask;
400 	} TYPE_GENERAL;
401 
402 	struct _TYPE0_ETH{
403 		u8		Priority;
404 		u8		ClassifierType;
405 		u8		Mask;
406 		u8		SrcAddr[6];
407 		u8		DstAddr[6];
408 		u16		Type;
409 	} TYPE0_ETH;
410 
411 	struct _TYPE1_IPV4{
412 		u8		Priority;
413 		u8		ClassifierType;
414 		u8		Mask;
415 		u8		Version;
416 		u8		SrcIP[4];
417 		u8		DstIP[4];
418 		u16		SrcPort;
419 		u16		DstPort;
420 		u8		DSCP;
421 		u8		Protocol;
422 		u8		Reserved;
423 	} TYPE1_IPV4;
424 
425 	struct _TYPE1_IPV6{
426 		u8		Priority;
427 		u8		ClassifierType;
428 		u8		Mask;
429 		u8		Version;
430 		u8		SrcIP[16];
431 		u8		DstIP[16];
432 		u16		SrcPort;
433 		u16		DstPort;
434 		u8		FlowLabel[3];
435 	} TYPE1_IPV6;
436 
437 	struct _TYPE2_8021Q{
438 		u8		Priority;
439 		u8		ClassifierType;
440 		u8		Mask;
441 		u16		TagType;
442 	} TYPE2_8021Q;
443 } QOS_TCLAS, *PQOS_TCLAS;
444 
445 //typedef struct _WMM_TSTREAM{
446 //
447 //- TSPEC
448 //- AC (which to mapping)
449 //} WMM_TSTREAM, *PWMM_TSTREAM;
450 typedef struct _QOS_TSTREAM{
451 	u8			AC;
452 	WMM_TSPEC		TSpec;
453 	QOS_TCLAS		TClass;
454 } QOS_TSTREAM, *PQOS_TSTREAM;
455 
456 //typedef struct _U_APSD{
457 //- TriggerEnable [4]
458 //- MaxSPLength
459 //- HighestAcBuffered
460 //} U_APSD, *PU_APSD;
461 
462 //joseph TODO:
463 //	UAPSD function should be implemented by 2 data structure
464 //	"Qos control field" and "Qos info field"
465 //typedef struct _QOS_UAPSD{
466 //	u8			bTriggerEnable[4];
467 //	u8			MaxSPLength;
468 //	u8			HighestBufAC;
469 //} QOS_UAPSD, *PQOS_APSD;
470 
471 //----------------------------------------------------------------------------
472 //      802.11 Management frame Status Code field
473 //----------------------------------------------------------------------------
474 typedef struct _OCTET_STRING{
475 	u8		*Octet;
476 	u16             Length;
477 }OCTET_STRING, *POCTET_STRING;
478 
479 //
480 // STA QoS data.
481 // Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
482 //
483 typedef struct _STA_QOS{
484 	//DECLARE_RT_OBJECT(STA_QOS);
485 	u8				WMMIEBuf[MAX_WMMELE_LENGTH];
486 	u8				*WMMIE;
487 
488 	// Part 1. Self QoS Mode.
489 	QOS_MODE			QosCapability; //QoS Capability, 2006-06-14 Isaiah
490 	QOS_MODE			CurrentQosMode;
491 
492 	// For WMM Power Save Mode :
493 	// ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
494 	AC_UAPSD			b4ac_Uapsd;  //VoUapsd(bit0), ViUapsd(bit1),  BkUapsd(bit2), BeUapsd(bit3),
495 	AC_UAPSD			Curr4acUapsd;
496 	u8				bInServicePeriod;
497 	u8				MaxSPLength;
498 	int				NumBcnBeforeTrigger;
499 
500 	// Part 2. EDCA Parameter (perAC)
501 	u8				*pWMMInfoEle;
502 	u8				WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
503 	u8				WMMPELength;
504 
505 	// <Bruce_Note>
506 	//2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
507 	// By Bruce, 2008-01-30.
508 	// Part 2. EDCA Parameter (perAC)
509 	QOS_INFO_FIELD			QosInfoField_STA;	// Maintained by STA
510 	QOS_INFO_FIELD			QosInfoField_AP;	// Retrieved from AP
511 
512 	AC_PARAM			CurAcParameters[4];
513 
514 	// Part 3. ACM
515 	ACM				acm[4];
516 	ACM_METHOD			AcmMethod;
517 
518 	// Part 4. Per TID (Part 5: TCLASS will be described by TStream)
519 	QOS_TSTREAM			TStream[16];
520 	WMM_TSPEC			TSpec;
521 
522 	u32				QBssWirelessMode;
523 
524 	// No Ack Setting
525 	u8				bNoAck;
526 
527 	// Enable/Disable Rx immediate BA capability.
528 	u8				bEnableRxImmBA;
529 
530 }STA_QOS, *PSTA_QOS;
531 
532 //
533 // BSS QOS data.
534 // Ref: BssDscr in 8185 code. [def. in BssDscr.h]
535 //
536 typedef struct _BSS_QOS{
537 	QOS_MODE		bdQoSMode;
538 
539 	u8			bdWMMIEBuf[MAX_WMMELE_LENGTH];
540 	u8		*bdWMMIE;
541 
542 	QOS_ELE_SUBTYPE		EleSubType;
543 
544 	u8			*pWMMInfoEle;
545 	u8			*pWMMParamEle;
546 
547 	QOS_INFO_FIELD		QosInfoField;
548 	AC_PARAM		AcParameter[4];
549 }BSS_QOS, *PBSS_QOS;
550 
551 
552 //
553 // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code.
554 //#define QoSCtl   ((	(Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA))	  )  ?sQoSCtlLng:0)
555 //
556 #define sQoSCtlLng			2
557 #define	QOS_CTRL_LEN(_QosMode)		((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)
558 
559 
560 //Added by joseph
561 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
562 //#define UP2AC(up)			((up<3)?((up==0)?1:0):(up>>1))
563 #define IsACValid(ac)			((ac<=7 )?true:false )
564 
565 #endif // #ifndef __INC_QOS_TYPE_H
566