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