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