que_mgt.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/que_mgt.h#2
  3. */
  4. /*! \file "que_mgt.h"
  5. * \brief TX/RX queues management header file
  6. *
  7. * The main tasks of queue management include TC-based HIF TX flow control,
  8. * adaptive TC quota adjustment, HIF TX grant scheduling, Power-Save
  9. * forwarding control, RX packet reordering, and RX BA agreement management.
  10. */
  11. /*
  12. ** Log: que_mgt.h
  13. **
  14. ** 07 25 2014 eason.tsai
  15. ** AOSP
  16. **
  17. ** 08 23 2013 terry.wu
  18. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  19. ** 1. Reset MSDU_INFO for data packet to avoid unexpected Tx status
  20. ** 2. Drop Tx packet to non-associated STA in driver
  21. **
  22. ** 08 19 2013 terry.wu
  23. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  24. ** 1. Enable TC resource adjust feature
  25. ** 2. Set Non-QoS data frame to TC5
  26. **
  27. ** 07 26 2013 terry.wu
  28. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  29. ** 1. Reduce extra Tx frame header parsing
  30. ** 2. Add TX port control
  31. ** 3. Add net interface to BSS binding
  32. **
  33. ** 07 18 2013 terry.wu
  34. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  35. ** 1. Update TxDesc PF bit setting rule
  36. ** 2. Remove unnecessary QM function
  37. **
  38. ** 06 25 2013 terry.wu
  39. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  40. ** Update for 1st connection
  41. **
  42. ** 03 13 2013 terry.wu
  43. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  44. ** .
  45. **
  46. ** 03 12 2013 terry.wu
  47. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  48. ** Update Tx utility function for management frame
  49. **
  50. ** 01 28 2013 cm.chang
  51. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  52. ** Sync CMD format
  53. **
  54. ** 01 21 2013 terry.wu
  55. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  56. ** Update TX path based on new ucBssIndex modifications.
  57. **
  58. ** 01 17 2013 cm.chang
  59. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  60. ** Use ucBssIndex to replace eNetworkTypeIndex
  61. **
  62. ** 12 27 2012 terry.wu
  63. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  64. ** Update MQM index mapping mechanism
  65. ** 1. TID to ACI
  66. ** 2. ACI to SW TxQ
  67. ** 3. ACI to network TC resource
  68. **
  69. ** 12 18 2012 terry.wu
  70. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  71. ** Page count resource management.
  72. **
  73. ** 09 17 2012 cm.chang
  74. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  75. ** Duplicate source from MT6620 v2.3 driver branch
  76. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  77. *
  78. * 08 15 2011 cp.wu
  79. * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
  80. * add MT6628-specific definitions.
  81. *
  82. * 07 26 2011 eddie.chen
  83. * [WCXRP00000874] [MT5931][DRV] API for query the RX reorder queued packets counter
  84. * API for query the RX reorder queued packets counter.
  85. *
  86. * 06 14 2011 eddie.chen
  87. * [WCXRP00000753] [MT5931 Wi-Fi][DRV] Adjust QM for MT5931
  88. * Change the parameter for WMM pass.
  89. *
  90. * 05 31 2011 eddie.chen
  91. * [WCXRP00000753] [MT5931 Wi-Fi][DRV] Adjust QM for MT5931
  92. * Fix the QM quota in MT5931.
  93. *
  94. * 05 09 2011 eddie.chen
  95. * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
  96. * Check free number before copying broadcast packet.
  97. *
  98. * 04 14 2011 eddie.chen
  99. * [WCXRP00000603] [MT6620 Wi-Fi][DRV] Fix Klocwork warning
  100. * Check the SW RFB free. Fix the compile warning..
  101. *
  102. * 04 08 2011 eddie.chen
  103. * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
  104. * Fix for sigma
  105. *
  106. * 03 28 2011 eddie.chen
  107. * [WCXRP00000602] [MT6620 Wi-Fi][DRV] Fix wmm parameters in beacon for BOW
  108. * Fix wmm parameters in beacon for BOW.
  109. *
  110. * 03 15 2011 eddie.chen
  111. * [WCXRP00000554] [MT6620 Wi-Fi][DRV] Add sw control debug counter
  112. * Add sw debug counter for QM.
  113. *
  114. * 02 17 2011 eddie.chen
  115. * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
  116. * 1) Chnange GetFrameAction decision when BSS is absent.
  117. * 2) Check channel and resource in processing ProbeRequest
  118. *
  119. * 01 12 2011 eddie.chen
  120. * [WCXRP00000322] Add WMM IE in beacon,
  121. *
  122. * Add per station flow control when STA is in PS
  123. *
  124. *
  125. * 1) Check Bss if support QoS before adding WMMIE
  126. * 2) Check if support prAdapter->rWifiVar QoS and uapsd in flow control
  127. *
  128. * 12 29 2010 eddie.chen
  129. * [WCXRP00000322] Add WMM IE in beacon,
  130. *
  131. * Add per station flow control when STA is in PS
  132. *
  133. *
  134. * 1) PS flow control event
  135. *
  136. * 2) WMM IE in beacon, assoc resp, probe resp
  137. *
  138. * 12 23 2010 george.huang
  139. * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
  140. * 1. update WMM IE parsing, with ASSOC REQ handling
  141. * 2. extend U-APSD parameter passing from driver to FW
  142. *
  143. * 10 04 2010 cp.wu
  144. * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by
  145. *ENUM_NETWORK_TYPE_INDEX_T only
  146. * remove ENUM_NETWORK_TYPE_T definitions
  147. *
  148. * 09 21 2010 kevin.huang
  149. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  150. * Eliminate Linux Compile Warning
  151. *
  152. * 08 04 2010 yarco.yang
  153. * NULL
  154. * Add TX_AMPDU and ADDBA_REJECT command
  155. *
  156. * 07 22 2010 george.huang
  157. *
  158. * Update fgIsQoS information in BSS INFO by CMD
  159. *
  160. * 07 16 2010 yarco.yang
  161. *
  162. * 1. Support BSS Absence/Presence Event
  163. * 2. Support STA change PS mode Event
  164. * 3. Support BMC forwarding for AP mode.
  165. *
  166. * 07 14 2010 yarco.yang
  167. *
  168. * 1. Remove CFG_MQM_MIGRATION
  169. * 2. Add CMD_UPDATE_WMM_PARMS command
  170. *
  171. * 07 13 2010 yarco.yang
  172. *
  173. * [WPD00003849]
  174. * [MT6620 and MT5931] SW Migration, add qmGetFrameAction() API for CMD Queue Processing
  175. *
  176. * 07 09 2010 yarco.yang
  177. *
  178. * [MT6620 and MT5931] SW Migration: Add ADDBA support
  179. *
  180. * 07 08 2010 cp.wu
  181. *
  182. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  183. *
  184. * 06 29 2010 yarco.yang
  185. * [WPD00003837][MT6620]Data Path Refine
  186. * replace g_rQM with Adpater->rQM
  187. *
  188. * 06 25 2010 cp.wu
  189. * [WPD00003833][MT6620 and MT5931] Driver migration
  190. * add API in que_mgt to retrieve sta-rec index for security frames.
  191. *
  192. * 06 23 2010 yarco.yang
  193. * [WPD00003837][MT6620]Data Path Refine
  194. * Merge g_arStaRec[] into adapter->arStaRec[]
  195. *
  196. * 06 21 2010 yarco.yang
  197. * [WPD00003837][MT6620]Data Path Refine
  198. * Support CFG_MQM_MIGRATION flag
  199. *
  200. * 06 18 2010 cm.chang
  201. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  202. * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
  203. *
  204. * 06 08 2010 cp.wu
  205. * [WPD00003833][MT6620 and MT5931] Driver migration
  206. * add hem_mbox.c and cnm_mem.h (but disabled some feature) for further migration
  207. *
  208. * 06 06 2010 kevin.huang
  209. * [WPD00003832][MT6620 5931] Create driver base
  210. * [MT6620 5931] Create driver base
  211. *
  212. * 03 30 2010 tehuang.liu
  213. * [WPD00001943]Create WiFi test driver framework on WinXP
  214. * Enabled adaptive TC resource control
  215. *
  216. * 03 24 2010 jeffrey.chang
  217. * [WPD00003826]Initial import for Linux port
  218. * initial import for Linux port
  219. *
  220. * 03 19 2010 tehuang.liu
  221. * [WPD00001943]Create WiFi test driver framework on WinXP
  222. * By default enabling dynamic STA_REC activation and decactivation
  223. *
  224. * 03 17 2010 tehuang.liu
  225. * [WPD00001943]Create WiFi test driver framework on WinXP
  226. * Changed STA_REC index determination rules (DA=BMCAST always --> STA_REC_INDEX_BMCAST)
  227. *
  228. * 03 11 2010 tehuang.liu
  229. * [WPD00001943]Create WiFi test driver framework on WinXP
  230. * Fixed buffer leak when processing BAR frames
  231. *
  232. * 02 25 2010 tehuang.liu
  233. * [WPD00001943]Create WiFi test driver framework on WinXP
  234. * Enabled multi-STA TX path with fairness
  235. *
  236. * 02 24 2010 tehuang.liu
  237. * [WPD00001943]Create WiFi test driver framework on WinXP
  238. * Enabled dynamically activating and deactivating STA_RECs
  239. *
  240. * 02 24 2010 tehuang.liu
  241. * [WPD00001943]Create WiFi test driver framework on WinXP
  242. * Added code for dynamic activating and deactivating STA_RECs.
  243. *
  244. * 01 13 2010 tehuang.liu
  245. * [WPD00001943]Create WiFi test driver framework on WinXP
  246. * Enabled the Burst_End Indication mechanism
  247. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-12-09 14:04:53 GMT MTK02468
  248. ** Added RX buffer reordering function prototypes
  249. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-12-02 22:08:44 GMT MTK02468
  250. ** Added macro QM_INIT_STA_REC for initialize a STA_REC
  251. ** \main\maintrunk.MT6620WiFiDriver_Prj\1 2009-11-23 21:58:43 GMT mtk02468
  252. ** Initial version
  253. **
  254. */
  255. #ifndef _QUE_MGT_H
  256. #define _QUE_MGT_H
  257. /*******************************************************************************
  258. * C O M P I L E R F L A G S
  259. ********************************************************************************
  260. */
  261. /*******************************************************************************
  262. * E X T E R N A L R E F E R E N C E S
  263. ********************************************************************************
  264. */
  265. extern UINT_8 g_arTdlsLink[MAXNUM_TDLS_PEER];
  266. /*******************************************************************************
  267. * C O N S T A N T S
  268. ********************************************************************************
  269. */
  270. /* Queue Manager Features */
  271. #define QM_BURST_END_INFO_ENABLED 0 /* 1: Indicate the last TX packet to the FW for each burst */
  272. #define QM_FORWARDING_FAIRNESS 1 /* 1: To fairly share TX resource among active STAs */
  273. #define QM_ADAPTIVE_TC_RESOURCE_CTRL 1 /* 1: To adaptively adjust resource for each TC */
  274. #define QM_FAST_TC_RESOURCE_CTRL 1 /* 1: To fast adjust resource for EMPTY TC (assigned resource is 0) */
  275. #define QM_PRINT_TC_RESOURCE_CTRL 0 /* 1: To print TC resource adjustment results */
  276. #define QM_RX_WIN_SSN_AUTO_ADVANCING 1 /* 1: If pkt with SSN is missing, auto advance the RX reordering window
  277. **/
  278. #define QM_RX_INIT_FALL_BEHIND_PASS 1 /* 1: Indicate the packets falling behind to OS before the frame with
  279. *SSN is received */
  280. #define QM_TC_RESOURCE_EMPTY_COUNTER 1 /* 1: Count times of TC resource empty happened */
  281. /* Parameters */
  282. #define QM_INIT_TIME_TO_UPDATE_QUE_LEN 60 /* p: Update queue lengths when p TX packets are enqueued */
  283. #define QM_INIT_TIME_TO_ADJUST_TC_RSC 3 /* s: Adjust the TC resource every s updates of queue lengths */
  284. #define QM_QUE_LEN_MOVING_AVE_FACTOR 3 /* Factor for Que Len averaging */
  285. #define QM_MIN_RESERVED_TC0_RESOURCE 0
  286. #define QM_MIN_RESERVED_TC1_RESOURCE 1
  287. #define QM_MIN_RESERVED_TC2_RESOURCE 0
  288. #define QM_MIN_RESERVED_TC3_RESOURCE 0
  289. #define QM_MIN_RESERVED_TC4_RESOURCE 2 /* Resource for TC4 is not adjustable */
  290. #define QM_MIN_RESERVED_TC5_RESOURCE 0
  291. #define QM_GUARANTEED_TC0_RESOURCE 4
  292. #define QM_GUARANTEED_TC1_RESOURCE 4
  293. #define QM_GUARANTEED_TC2_RESOURCE 9
  294. #define QM_GUARANTEED_TC3_RESOURCE 11
  295. #define QM_GUARANTEED_TC4_RESOURCE 2 /* Resource for TC4 is not adjustable */
  296. #define QM_GUARANTEED_TC5_RESOURCE 4
  297. #define QM_EXTRA_RESERVED_RESOURCE_WHEN_BUSY 0
  298. #define QM_AVERAGE_TC_RESOURCE 6
  299. #define QM_ACTIVE_TC_NUM TC_NUM
  300. #define QM_MGMT_QUEUED_THRESHOLD 6
  301. #define QM_CMD_RESERVED_THRESHOLD 4
  302. #define QM_MGMT_QUEUED_TIMEOUT 1000 /* ms */
  303. #define QM_TEST_MODE 0
  304. #define QM_TEST_TRIGGER_TX_COUNT 50
  305. #define QM_TEST_STA_REC_DETERMINATION 0
  306. #define QM_TEST_STA_REC_DEACTIVATION 0
  307. #define QM_TEST_FAIR_FORWARDING 0
  308. #define QM_DEBUG_COUNTER 0
  309. /* Per-STA Queues: [0] AC0, [1] AC1, [2] AC2, [3] AC3, [4] MGMT, [5] non-QoS */
  310. /* Per-Type Queues: [0] BMCAST */
  311. #define NUM_OF_PER_STA_TX_QUEUES 6
  312. #define NUM_OF_PER_TYPE_TX_QUEUES 1
  313. /* TX Queue Index */
  314. /* Per-Type */
  315. #define TX_QUEUE_INDEX_BMCAST 0
  316. #define TX_QUEUE_INDEX_NO_STA_REC 0
  317. /* Per-STA */
  318. #define TX_QUEUE_INDEX_AC0 0
  319. #define TX_QUEUE_INDEX_AC1 1
  320. #define TX_QUEUE_INDEX_AC2 2
  321. #define TX_QUEUE_INDEX_AC3 3
  322. #define TX_QUEUE_INDEX_MGMT 4
  323. #define TX_QUEUE_INDEX_NON_QOS 5
  324. #define QM_DEFAULT_USER_PRIORITY 0
  325. #define QM_STA_FORWARD_COUNT_UNLIMITED 0xFFFFFFFF
  326. #define QM_FWD_PKT_QUE_THRESHOLD 128
  327. /* 1 WMM-related */
  328. /* WMM FLAGS */
  329. #define WMM_FLAG_SUPPORT_WMM BIT(0)
  330. #define WMM_FLAG_SUPPORT_WMMSA BIT(1)
  331. #define WMM_FLAG_AC_PARAM_PRESENT BIT(2)
  332. #define WMM_FLAG_SUPPORT_UAPSD BIT(3)
  333. /* WMM Admission Control Mandatory FLAGS */
  334. #define ACM_FLAG_ADM_NOT_REQUIRED 0
  335. #define ACM_FLAG_ADM_GRANTED BIT(0)
  336. #define ACM_FLAG_ADM_REQUIRED BIT(1)
  337. /* WMM Power Saving FLAGS */
  338. #define AC_FLAG_TRIGGER_ENABLED BIT(1)
  339. #define AC_FLAG_DELIVERY_ENABLED BIT(2)
  340. /* WMM-2.2.1 WMM Information Element */
  341. #define ELEM_MAX_LEN_WMM_INFO 7
  342. /* WMM-2.2.2 WMM Parameter Element */
  343. #define ELEM_MAX_LEN_WMM_PARAM 24
  344. /* WMM-2.2.1 WMM QoS Info field */
  345. #define WMM_QOS_INFO_PARAM_SET_CNT BITS(0, 3) /* Sent by AP */
  346. #define WMM_QOS_INFO_UAPSD BIT(7)
  347. #define WMM_QOS_INFO_VO_UAPSD BIT(0) /* Sent by non-AP STA */
  348. #define WMM_QOS_INFO_VI_UAPSD BIT(1)
  349. #define WMM_QOS_INFO_BK_UAPSD BIT(2)
  350. #define WMM_QOS_INFO_BE_UAPSD BIT(3)
  351. #define WMM_QOS_INFO_MAX_SP_LEN_MASK BITS(5, 6)
  352. #define WMM_QOS_INFO_MAX_SP_ALL 0
  353. #define WMM_QOS_INFO_MAX_SP_2 BIT(5)
  354. #define WMM_QOS_INFO_MAX_SP_4 BIT(6)
  355. #define WMM_QOS_INFO_MAX_SP_6 BITS(5, 6)
  356. /* -- definitions for Max SP length field */
  357. #define WMM_MAX_SP_LENGTH_ALL 0
  358. #define WMM_MAX_SP_LENGTH_2 2
  359. #define WMM_MAX_SP_LENGTH_4 4
  360. #define WMM_MAX_SP_LENGTH_6 6
  361. /* WMM-2.2.2 WMM ACI/AIFSN field */
  362. /* -- subfields in the ACI/AIFSN field */
  363. #define WMM_ACIAIFSN_AIFSN BITS(0, 3)
  364. #define WMM_ACIAIFSN_ACM BIT(4)
  365. #define WMM_ACIAIFSN_ACI BITS(5, 6)
  366. #define WMM_ACIAIFSN_ACI_OFFSET 5
  367. /* -- definitions for ACI field */
  368. #define WMM_ACI_AC_BE 0
  369. #define WMM_ACI_AC_BK BIT(5)
  370. #define WMM_ACI_AC_VI BIT(6)
  371. #define WMM_ACI_AC_VO BITS(5, 6)
  372. #define WMM_ACI(_AC) (_AC << WMM_ACIAIFSN_ACI_OFFSET)
  373. /* -- definitions for ECWmin/ECWmax field */
  374. #define WMM_ECW_WMIN_MASK BITS(0, 3)
  375. #define WMM_ECW_WMAX_MASK BITS(4, 7)
  376. #define WMM_ECW_WMAX_OFFSET 4
  377. #define TXM_DEFAULT_FLUSH_QUEUE_GUARD_TIME 0 /* Unit: 64 us */
  378. #define QM_RX_BA_ENTRY_MISS_TIMEOUT_MS (1000)
  379. #if CFG_M0VE_BA_TO_DRIVER
  380. /* MQM internal control bitmap per-bit usage (for operations on g_prMqm->u4FlagBitmap) */
  381. #define MQM_FLAG_TSPEC_NEGO_ADD_IN_PROGRESS 0
  382. #define MQM_FLAG_IDLE_TX_BA_TIMER_STARTED 1
  383. #define MQM_FLAG_IDLE_RX_BA_TIMER_STARTED 2
  384. #define MQM_IDLE_RX_BA_DETECTION 0
  385. #define MQM_IDLE_RX_BA_CHECK_INTERVAL 5000 /* in msec */
  386. #define MQM_DEL_IDLE_RXBA_THRESHOLD_BK 6
  387. #define MQM_DEL_IDLE_RXBA_THRESHOLD_BE 12
  388. #define MQM_DEL_IDLE_RXBA_THRESHOLD_VI 6
  389. #define MQM_DEL_IDLE_RXBA_THRESHOLD_VO 6
  390. /* For indicating whether the role when generating a DELBA message */
  391. #define DELBA_ROLE_INITIATOR TRUE
  392. #define DELBA_ROLE_RECIPIENT FALSE
  393. #define MQM_SET_FLAG(_Bitmap, _flag) { (_Bitmap) |= (BIT((_flag))); }
  394. #define MQM_CLEAR_FLAG(_Bitmap, _flag) { (_Bitmap) &= (~BIT((_flag))); }
  395. #define MQM_CHECK_FLAG(_Bitmap, _flag) ((_Bitmap) & (BIT((_flag))))
  396. typedef enum _ENUM_BA_RESET_SEL_T {
  397. MAC_ADDR_TID_MATCH = 0,
  398. MAC_ADDR_MATCH,
  399. ALWAYS_MATCH,
  400. MATCH_NUM
  401. } ENUM_BA_RESET_SEL_T;
  402. #endif
  403. /*******************************************************************************
  404. * D A T A T Y P E S
  405. ********************************************************************************
  406. */
  407. enum {
  408. QM_DBG_CNT_00 = 0,
  409. QM_DBG_CNT_01,
  410. QM_DBG_CNT_02,
  411. QM_DBG_CNT_03,
  412. QM_DBG_CNT_04,
  413. QM_DBG_CNT_05,
  414. QM_DBG_CNT_06,
  415. QM_DBG_CNT_07,
  416. QM_DBG_CNT_08,
  417. QM_DBG_CNT_09,
  418. QM_DBG_CNT_10,
  419. QM_DBG_CNT_11,
  420. QM_DBG_CNT_12,
  421. QM_DBG_CNT_13,
  422. QM_DBG_CNT_14,
  423. QM_DBG_CNT_15,
  424. QM_DBG_CNT_16,
  425. QM_DBG_CNT_17,
  426. QM_DBG_CNT_18,
  427. QM_DBG_CNT_19,
  428. QM_DBG_CNT_20,
  429. QM_DBG_CNT_21,
  430. QM_DBG_CNT_22,
  431. QM_DBG_CNT_23,
  432. QM_DBG_CNT_24,
  433. QM_DBG_CNT_25,
  434. QM_DBG_CNT_26,
  435. QM_DBG_CNT_27,
  436. QM_DBG_CNT_28,
  437. QM_DBG_CNT_29,
  438. QM_DBG_CNT_30,
  439. QM_DBG_CNT_31,
  440. QM_DBG_CNT_NUM
  441. };
  442. /* Used for MAC TX */
  443. typedef enum _ENUM_MAC_TX_QUEUE_INDEX_T {
  444. MAC_TX_QUEUE_AC0_INDEX = 0,
  445. MAC_TX_QUEUE_AC1_INDEX,
  446. MAC_TX_QUEUE_AC2_INDEX,
  447. MAC_TX_QUEUE_AC3_INDEX,
  448. MAC_TX_QUEUE_AC4_INDEX,
  449. MAC_TX_QUEUE_AC5_INDEX,
  450. MAC_TX_QUEUE_AC6_INDEX,
  451. MAC_TX_QUEUE_BCN_INDEX,
  452. MAC_TX_QUEUE_BMC_INDEX,
  453. MAC_TX_QUEUE_NUM
  454. } ENUM_MAC_TX_QUEUE_INDEX_T;
  455. typedef struct _RX_BA_ENTRY_T {
  456. BOOLEAN fgIsValid;
  457. QUE_T rReOrderQue;
  458. UINT_16 u2WinStart;
  459. UINT_16 u2WinEnd;
  460. UINT_16 u2WinSize;
  461. /* For identifying the RX BA agreement */
  462. UINT_8 ucStaRecIdx;
  463. UINT_8 ucTid;
  464. BOOLEAN fgIsWaitingForPktWithSsn;
  465. TIMER_T rReorderBubbleTimer;
  466. UINT_16 u2FirstBubbleSn;
  467. BOOLEAN fgHasBubble;
  468. #if CFG_M0VE_BA_TO_DRIVER
  469. UINT_8 ucStatus;
  470. UINT_8 ucIdleCount;
  471. UINT_16 u2SnapShotSN;
  472. #endif
  473. /* UINT_8 ucTxBufferSize; */
  474. /* BOOL fgIsAcConstrain; */
  475. /* BOOL fgIsBaEnabled; */
  476. } RX_BA_ENTRY_T, *P_RX_BA_ENTRY_T;
  477. typedef UINT_32(*PFN_DEQUEUE_FUNCTION) (IN P_ADAPTER_T prAdapter, OUT P_QUE_T prQue, IN UINT_8 ucTC, IN UINT_32
  478. u4CurrentQuota, IN UINT_32 u4TotalQuota);
  479. /* The mailbox message (could be used for Host-To-Device or Device-To-Host Mailbox) */
  480. typedef struct _MAILBOX_MSG_T {
  481. UINT_32 u4Msg[2]; /* [0]: D2HRM0R or H2DRM0R, [1]: D2HRM1R or H2DRM1R */
  482. } MAILBOX_MSG_T, *P_MAILBOX_MSG_T;
  483. /* Used for adaptively adjusting TC resources */
  484. typedef struct _TC_RESOURCE_CTRL_T {
  485. /* TC0, TC1, TC2, TC3, TC5 */
  486. UINT_32 au4AverageQueLen[TC_NUM - 1];
  487. } TC_RESOURCE_CTRL_T, *P_TC_RESOURCE_CTRL_T;
  488. typedef struct _QUE_MGT_T { /* Queue Management Control Info */
  489. /* Per-Type Queues: [0] BMCAST or UNKNOWN-STA packets */
  490. QUE_T arTxQueue[NUM_OF_PER_TYPE_TX_QUEUES];
  491. #if 0
  492. /* For TX Scheduling */
  493. UINT_8 arRemainingTxOppt[NUM_OF_PER_STA_TX_QUEUES];
  494. UINT_8 arCurrentTxStaIndex[NUM_OF_PER_STA_TX_QUEUES];
  495. #endif
  496. /* Reordering Queue Parameters */
  497. RX_BA_ENTRY_T arRxBaTable[CFG_NUM_OF_RX_BA_AGREEMENTS];
  498. /* Current number of activated RX BA agreements <= CFG_NUM_OF_RX_BA_AGREEMENTS */
  499. UINT_8 ucRxBaCount;
  500. #if QM_TEST_MODE
  501. UINT_32 u4PktCount;
  502. P_ADAPTER_T prAdapter;
  503. #if QM_TEST_FAIR_FORWARDING
  504. UINT_32 u4CurrentStaRecIndexToEnqueue;
  505. #endif
  506. #endif
  507. #if QM_FORWARDING_FAIRNESS
  508. /* The current resource used count for a STA with respect to a TC index */
  509. UINT_32 au4ResourceUsedCount[NUM_OF_PER_STA_TX_QUEUES];
  510. /* The current serving STA with respect to a TC index */
  511. UINT_32 au4HeadStaRecIndex[NUM_OF_PER_STA_TX_QUEUES];
  512. /* For TC5 only */
  513. BOOLEAN fgGlobalQFirst;
  514. UINT_32 u4GlobalResourceUsedCount;
  515. #endif
  516. #if QM_ADAPTIVE_TC_RESOURCE_CTRL
  517. UINT_32 au4AverageQueLen[TC_NUM];
  518. UINT_32 au4CurrentTcResource[TC_NUM];
  519. UINT_32 au4MinReservedTcResource[TC_NUM]; /* The minimum amount of resource no matter busy or idle */
  520. UINT_32 au4GuaranteedTcResource[TC_NUM]; /* The minimum amount of resource when extremely busy */
  521. UINT_32 u4TimeToAdjustTcResource;
  522. UINT_32 u4TimeToUpdateQueLen;
  523. UINT_32 u4QueLenMovingAverage;
  524. UINT_32 u4ExtraReservedTcResource;
  525. UINT_32 u4ResidualTcResource;
  526. /* Set to TRUE if the last TC adjustment has not been completely applied (i.e., waiting more TX-Done events
  527. * to align the TC quotas to the TC resource assignment) */
  528. BOOLEAN fgTcResourcePostAnnealing;
  529. #if QM_FAST_TC_RESOURCE_CTRL
  530. BOOLEAN fgTcResourceFastReaction;
  531. #endif
  532. #endif
  533. #if QM_DEBUG_COUNTER
  534. UINT_32 au4QmDebugCounters[QM_DBG_CNT_NUM];
  535. #endif
  536. UINT_32 u4TxAllowedStaCount;
  537. #if QM_TC_RESOURCE_EMPTY_COUNTER
  538. UINT_32 au4QmTcResourceEmptyCounter[MAX_BSS_INDEX][TC_NUM];
  539. #endif
  540. UINT_32 u4MaxForwardBufferCount;
  541. OS_SYSTIME rLastTxPktDumpTime;
  542. } QUE_MGT_T, *P_QUE_MGT_T;
  543. typedef struct _EVENT_RX_ADDBA_T {
  544. /* Event header */
  545. UINT_16 u2Length;
  546. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  547. UINT_8 ucEID;
  548. UINT_8 ucSeqNum;
  549. UINT_8 aucReserved2[2];
  550. /* Fields not present in the received ADDBA_REQ */
  551. UINT_8 ucStaRecIdx;
  552. /* Fields that are present in the received ADDBA_REQ */
  553. UINT_8 ucDialogToken; /* Dialog Token chosen by the sender */
  554. UINT_16 u2BAParameterSet; /* BA policy, TID, buffer size */
  555. UINT_16 u2BATimeoutValue;
  556. UINT_16 u2BAStartSeqCtrl; /* SSN */
  557. } EVENT_RX_ADDBA_T, *P_EVENT_RX_ADDBA_T;
  558. typedef struct _EVENT_RX_DELBA_T {
  559. /* Event header */
  560. UINT_16 u2Length;
  561. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  562. UINT_8 ucEID;
  563. UINT_8 ucSeqNum;
  564. UINT_8 aucReserved2[2];
  565. /* Fields not present in the received ADDBA_REQ */
  566. UINT_8 ucStaRecIdx;
  567. UINT_8 ucTid;
  568. } EVENT_RX_DELBA_T, *P_EVENT_RX_DELBA_T;
  569. typedef struct _EVENT_BSS_ABSENCE_PRESENCE_T {
  570. /* Event header */
  571. UINT_16 u2Length;
  572. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  573. UINT_8 ucEID;
  574. UINT_8 ucSeqNum;
  575. UINT_8 aucReserved2[2];
  576. /* Event Body */
  577. UINT_8 ucBssIndex;
  578. UINT_8 ucIsAbsent;
  579. UINT_8 ucBssFreeQuota;
  580. UINT_8 aucReserved[1];
  581. } EVENT_BSS_ABSENCE_PRESENCE_T, *P_EVENT_BSS_ABSENCE_PRESENCE_T;
  582. typedef struct _EVENT_STA_CHANGE_PS_MODE_T {
  583. /* Event header */
  584. UINT_16 u2Length;
  585. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  586. UINT_8 ucEID;
  587. UINT_8 ucSeqNum;
  588. UINT_8 aucReserved2[2];
  589. /* Event Body */
  590. UINT_8 ucStaRecIdx;
  591. UINT_8 ucIsInPs;
  592. UINT_8 ucUpdateMode;
  593. UINT_8 ucFreeQuota;
  594. } EVENT_STA_CHANGE_PS_MODE_T, *P_EVENT_STA_CHANGE_PS_MODE_T;
  595. /* The free quota is used by PS only now */
  596. /* The event may be used by per STA flow conttrol in general */
  597. typedef struct _EVENT_STA_UPDATE_FREE_QUOTA_T {
  598. /* Event header */
  599. UINT_16 u2Length;
  600. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  601. UINT_8 ucEID;
  602. UINT_8 ucSeqNum;
  603. UINT_8 aucReserved2[2];
  604. /* Event Body */
  605. UINT_8 ucStaRecIdx;
  606. UINT_8 ucUpdateMode;
  607. UINT_8 ucFreeQuota;
  608. UINT_8 aucReserved[1];
  609. } EVENT_STA_UPDATE_FREE_QUOTA_T, *P_EVENT_STA_UPDATE_FREE_QUOTA_T;
  610. typedef struct _EVENT_CHECK_REORDER_BUBBLE_T {
  611. /* Event header */
  612. UINT_16 u2Length;
  613. UINT_16 u2Reserved1; /* Must be filled with 0x0001 (EVENT Packet) */
  614. UINT_8 ucEID;
  615. UINT_8 ucSeqNum;
  616. UINT_8 aucReserved2[2];
  617. /* Event Body */
  618. UINT_8 ucStaRecIdx;
  619. UINT_8 ucTid;
  620. } EVENT_CHECK_REORDER_BUBBLE_T, *P_EVENT_CHECK_REORDER_BUBBLE_T;
  621. /* WMM-2.2.1 WMM Information Element */
  622. typedef struct _IE_WMM_INFO_T {
  623. UINT_8 ucId; /* Element ID */
  624. UINT_8 ucLength; /* Length */
  625. UINT_8 aucOui[3]; /* OUI */
  626. UINT_8 ucOuiType; /* OUI Type */
  627. UINT_8 ucOuiSubtype; /* OUI Subtype */
  628. UINT_8 ucVersion; /* Version */
  629. UINT_8 ucQosInfo; /* QoS Info field */
  630. UINT_8 ucDummy[3]; /* Dummy for pack */
  631. } IE_WMM_INFO_T, *P_IE_WMM_INFO_T;
  632. typedef struct _WMM_AC_PARAM_T {
  633. UINT_8 ucAciAifsn;
  634. UINT_8 ucEcw;
  635. UINT_16 u2TxopLimit;
  636. } WMM_AC_PARAM_T, *P_WMM_AC_PARAM_T;
  637. /* WMM-2.2.2 WMM Parameter Element */
  638. typedef struct _IE_WMM_PARAM_T {
  639. UINT_8 ucId; /* Element ID */
  640. UINT_8 ucLength; /* Length */
  641. /* IE Body */
  642. UINT_8 aucOui[3]; /* OUI */
  643. UINT_8 ucOuiType; /* OUI Type */
  644. UINT_8 ucOuiSubtype; /* OUI Subtype */
  645. UINT_8 ucVersion; /* Version */
  646. /* WMM IE Body */
  647. UINT_8 ucQosInfo; /* QoS Info field */
  648. UINT_8 ucReserved;
  649. /* AC Parameters */
  650. #if 1
  651. WMM_AC_PARAM_T arAcParam[4];
  652. #else
  653. UINT_8 ucAciAifsn_BE;
  654. UINT_8 ucEcw_BE;
  655. UINT_8 aucTxopLimit_BE[2];
  656. UINT_8 ucAciAifsn_BG;
  657. UINT_8 ucEcw_BG;
  658. UINT_8 aucTxopLimit_BG[2];
  659. UINT_8 ucAciAifsn_VI;
  660. UINT_8 ucEcw_VI;
  661. UINT_8 aucTxopLimit_VI[2];
  662. UINT_8 ucAciAifsn_VO;
  663. UINT_8 ucEcw_VO;
  664. UINT_8 aucTxopLimit_VO[2];
  665. #endif
  666. } IE_WMM_PARAM_T, *P_IE_WMM_PARAM_T;
  667. typedef struct _IE_WMM_TSPEC_T {
  668. UINT_8 ucId; /* Element ID */
  669. UINT_8 ucLength; /* Length */
  670. UINT_8 aucOui[3]; /* OUI */
  671. UINT_8 ucOuiType; /* OUI Type */
  672. UINT_8 ucOuiSubtype; /* OUI Subtype */
  673. UINT_8 ucVersion; /* Version */
  674. /* WMM TSPEC body */
  675. UINT_8 aucTsInfo[3]; /* TS Info */
  676. UINT_8 aucTspecBodyPart[1]; /* Note: Utilize PARAM_QOS_TSPEC to fill (memory copy) */
  677. } IE_WMM_TSPEC_T, *P_IE_WMM_TSPEC_T;
  678. typedef struct _IE_WMM_HDR_T {
  679. UINT_8 ucId; /* Element ID */
  680. UINT_8 ucLength; /* Length */
  681. UINT_8 aucOui[3]; /* OUI */
  682. UINT_8 ucOuiType; /* OUI Type */
  683. UINT_8 ucOuiSubtype; /* OUI Subtype */
  684. UINT_8 ucVersion; /* Version */
  685. UINT_8 aucBody[1]; /* IE body */
  686. } IE_WMM_HDR_T, *P_IE_WMM_HDR_T;
  687. typedef struct _AC_QUE_PARMS_T {
  688. UINT_16 u2CWmin; /*!< CWmin */
  689. UINT_16 u2CWmax; /*!< CWmax */
  690. UINT_16 u2TxopLimit; /*!< TXOP limit */
  691. UINT_16 u2Aifsn; /*!< AIFSN */
  692. UINT_8 ucGuradTime; /*!< GuardTime for STOP/FLUSH. */
  693. UINT_8 ucIsACMSet;
  694. } AC_QUE_PARMS_T, *P_AC_QUE_PARMS_T;
  695. /* WMM ACI (AC index) */
  696. typedef enum _ENUM_WMM_ACI_T {
  697. WMM_AC_BE_INDEX = 0,
  698. WMM_AC_BK_INDEX,
  699. WMM_AC_VI_INDEX,
  700. WMM_AC_VO_INDEX,
  701. WMM_AC_INDEX_NUM
  702. } ENUM_WMM_ACI_T, *P_ENUM_WMM_ACI_T;
  703. /* Used for CMD Queue Operation */
  704. typedef enum _ENUM_FRAME_ACTION_T {
  705. FRAME_ACTION_DROP_PKT = 0,
  706. FRAME_ACTION_QUEUE_PKT,
  707. FRAME_ACTION_TX_PKT,
  708. FRAME_ACTION_NUM
  709. } ENUM_FRAME_ACTION_T;
  710. typedef enum _ENUM_FRAME_TYPE_IN_CMD_Q_T {
  711. FRAME_TYPE_802_1X = 0,
  712. FRAME_TYPE_MMPDU,
  713. FRAME_TYPE_NUM
  714. } ENUM_FRAME_TYPE_IN_CMD_Q_T;
  715. typedef enum _ENUM_FREE_QUOTA_MODET_T {
  716. FREE_QUOTA_UPDATE_MODE_INIT = 0,
  717. FREE_QUOTA_UPDATE_MODE_OVERWRITE,
  718. FREE_QUOTA_UPDATE_MODE_INCREASE,
  719. FREE_QUOTA_UPDATE_MODE_DECREASE
  720. } ENUM_FREE_QUOTA_MODET_T, *P_ENUM_FREE_QUOTA_MODET_T;
  721. typedef struct _CMD_UPDATE_WMM_PARMS_T {
  722. AC_QUE_PARMS_T arACQueParms[AC_NUM];
  723. UINT_8 ucBssIndex;
  724. UINT_8 fgIsQBSS;
  725. UINT_8 aucReserved[2];
  726. } CMD_UPDATE_WMM_PARMS_T, *P_CMD_UPDATE_WMM_PARMS_T;
  727. typedef struct _CMD_TX_AMPDU_T {
  728. BOOLEAN fgEnable;
  729. UINT_8 aucReserved[3];
  730. } CMD_TX_AMPDU_T, *P_CMD_TX_AMPDU_T;
  731. typedef struct _CMD_ADDBA_REJECT {
  732. BOOLEAN fgEnable;
  733. UINT_8 aucReserved[3];
  734. } CMD_ADDBA_REJECT_T, *P_CMD_ADDBA_REJECT_T;
  735. #if CFG_M0VE_BA_TO_DRIVER
  736. /* The status of an TX/RX BA entry in FW (NEGO means the negotiation process is in progress) */
  737. typedef enum _ENUM_BA_ENTRY_STATUS_T {
  738. BA_ENTRY_STATUS_INVALID = 0,
  739. BA_ENTRY_STATUS_NEGO,
  740. BA_ENTRY_STATUS_ACTIVE,
  741. BA_ENTRY_STATUS_DELETING
  742. } ENUM_BA_ENTRY_STATUS_T, *P_ENUM_BA_ENTRY_STATUS_T;
  743. #endif
  744. /*******************************************************************************
  745. * P U B L I C D A T A
  746. ********************************************************************************
  747. */
  748. /*******************************************************************************
  749. * P R I V A T E D A T A
  750. ********************************************************************************
  751. */
  752. /*******************************************************************************
  753. * M A C R O S
  754. ********************************************************************************
  755. */
  756. #define QM_TX_SET_NEXT_MSDU_INFO(_prMsduInfoPreceding, _prMsduInfoNext) \
  757. ((((_prMsduInfoPreceding)->rQueEntry).prNext) = (P_QUE_ENTRY_T)(_prMsduInfoNext))
  758. #define QM_TX_SET_NEXT_SW_RFB(_prSwRfbPreceding, _prSwRfbNext) \
  759. ((((_prSwRfbPreceding)->rQueEntry).prNext) = (P_QUE_ENTRY_T)(_prSwRfbNext))
  760. #define QM_TX_GET_NEXT_MSDU_INFO(_prMsduInfo) \
  761. ((P_MSDU_INFO_T)(((_prMsduInfo)->rQueEntry).prNext))
  762. #define QM_RX_SET_NEXT_SW_RFB(_prSwRfbPreceding, _prSwRfbNext) \
  763. ((((_prSwRfbPreceding)->rQueEntry).prNext) = (P_QUE_ENTRY_T)(_prSwRfbNext))
  764. #define QM_RX_GET_NEXT_SW_RFB(_prSwRfb) \
  765. ((P_SW_RFB_T)(((_prSwRfb)->rQueEntry).prNext))
  766. #if 0
  767. #define QM_GET_STA_REC_PTR_FROM_INDEX(_prAdapter, _ucIndex) \
  768. ((((_ucIndex) != STA_REC_INDEX_BMCAST) && ((_ucIndex) != STA_REC_INDEX_NOT_FOUND)) ? \
  769. &(_prAdapter->arStaRec[_ucIndex]) : NULL)
  770. #endif
  771. #define QM_GET_STA_REC_PTR_FROM_INDEX(_prAdapter, _ucIndex) \
  772. cnmGetStaRecByIndex(_prAdapter, _ucIndex)
  773. #if 0
  774. #define QM_TX_SET_MSDU_INFO_FOR_DATA_PACKET( \
  775. _prMsduInfo, \
  776. _ucTC, \
  777. _ucPacketType, \
  778. _ucFormatID, \
  779. _fgIs802_1x, \
  780. _fgIs802_11, \
  781. _u2PalLLH, \
  782. _u2AclSN, \
  783. _ucPsForwardingType, \
  784. _ucPsSessionID \
  785. ) \
  786. { \
  787. ASSERT(_prMsduInfo); \
  788. (_prMsduInfo)->ucTC = (_ucTC); \
  789. (_prMsduInfo)->ucPacketType = (_ucPacketType); \
  790. (_prMsduInfo)->ucFormatID = (_ucFormatID); \
  791. (_prMsduInfo)->fgIs802_1x = (_fgIs802_1x); \
  792. (_prMsduInfo)->fgIs802_11 = (_fgIs802_11); \
  793. (_prMsduInfo)->u2PalLLH = (_u2PalLLH); \
  794. (_prMsduInfo)->u2AclSN = (_u2AclSN); \
  795. (_prMsduInfo)->ucPsForwardingType = (_ucPsForwardingType); \
  796. (_prMsduInfo)->ucPsSessionID = (_ucPsSessionID); \
  797. (_prMsduInfo)->fgIsBurstEnd = (FALSE); \
  798. }
  799. #else
  800. #define QM_TX_SET_MSDU_INFO_FOR_DATA_PACKET( \
  801. _prMsduInfo, \
  802. _ucTC, \
  803. _ucPacketType, \
  804. _ucFormatID, \
  805. _fgIs802_1x, \
  806. _fgIs802_11, \
  807. _ucPsForwardingType \
  808. ) \
  809. { \
  810. ASSERT(_prMsduInfo); \
  811. (_prMsduInfo)->ucTC = (_ucTC); \
  812. (_prMsduInfo)->ucPacketType = (_ucPacketType); \
  813. (_prMsduInfo)->ucFormatID = (_ucFormatID); \
  814. (_prMsduInfo)->fgIs802_1x = (_fgIs802_1x); \
  815. (_prMsduInfo)->fgIs802_11 = (_fgIs802_11); \
  816. (_prMsduInfo)->ucPsForwardingType = (_ucPsForwardingType); \
  817. }
  818. #endif
  819. #define QM_INIT_STA_REC( \
  820. _prStaRec, \
  821. _fgIsValid, \
  822. _fgIsQoS, \
  823. _pucMacAddr \
  824. ) \
  825. { \
  826. ASSERT(_prStaRec); \
  827. (_prStaRec)->fgIsValid = (_fgIsValid); \
  828. (_prStaRec)->fgIsQoS = (_fgIsQoS); \
  829. (_prStaRec)->fgIsInPS = FALSE; \
  830. (_prStaRec)->ucPsSessionID = 0xFF; \
  831. COPY_MAC_ADDR((_prStaRec)->aucMacAddr, (_pucMacAddr)); \
  832. }
  833. #if QM_ADAPTIVE_TC_RESOURCE_CTRL
  834. #define QM_GET_TX_QUEUE_LEN(_prAdapter, _u4QueIdx) \
  835. (((_prAdapter)->rQM.au4AverageQueLen[(_u4QueIdx)] >> (_prAdapter)->rQM.u4QueLenMovingAverage))
  836. #endif
  837. #define WMM_IE_OUI_TYPE(fp) (((P_IE_WMM_HDR_T)(fp))->ucOuiType)
  838. #define WMM_IE_OUI_SUBTYPE(fp) (((P_IE_WMM_HDR_T)(fp))->ucOuiSubtype)
  839. #define WMM_IE_OUI(fp) (((P_IE_WMM_HDR_T)(fp))->aucOui)
  840. #if QM_DEBUG_COUNTER
  841. #define QM_DBG_CNT_INC(_prQM, _index) { (_prQM)->au4QmDebugCounters[(_index)]++; }
  842. #else
  843. #define QM_DBG_CNT_INC(_prQM, _index) {}
  844. #endif
  845. /*******************************************************************************
  846. * F U N C T I O N D E C L A R A T I O N S
  847. ********************************************************************************
  848. */
  849. /*----------------------------------------------------------------------------*/
  850. /* Queue Management and STA_REC Initialization */
  851. /*----------------------------------------------------------------------------*/
  852. VOID qmInit(IN P_ADAPTER_T prAdapter);
  853. #if QM_TEST_MODE
  854. VOID qmTestCases(IN P_ADAPTER_T prAdapter);
  855. #endif
  856. VOID qmActivateStaRec(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec);
  857. VOID qmDeactivateStaRec(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec);
  858. VOID qmUpdateStaRec(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec);
  859. /*----------------------------------------------------------------------------*/
  860. /* TX-Related Queue Management */
  861. /*----------------------------------------------------------------------------*/
  862. P_MSDU_INFO_T qmFlushTxQueues(IN P_ADAPTER_T prAdapter);
  863. P_MSDU_INFO_T qmFlushStaTxQueues(IN P_ADAPTER_T prAdapter, IN UINT_32 u4StaRecIdx);
  864. P_MSDU_INFO_T qmEnqueueTxPackets(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfoListHead);
  865. P_MSDU_INFO_T qmDequeueTxPackets(IN P_ADAPTER_T prAdapter, IN P_TX_TCQ_STATUS_T prTcqStatus);
  866. #if CFG_SUPPORT_MULTITHREAD
  867. P_MSDU_INFO_T qmDequeueTxPacketsMthread(IN P_ADAPTER_T prAdapter, IN P_TX_TCQ_STATUS_T prTcqStatus);
  868. BOOLEAN
  869. qmAdjustTcQuotasMthread(IN P_ADAPTER_T prAdapter, OUT P_TX_TCQ_ADJUST_T prTcqAdjust, IN P_TX_TCQ_STATUS_T prTcqStatus);
  870. #endif
  871. BOOLEAN qmAdjustTcQuotas(IN P_ADAPTER_T prAdapter, OUT P_TX_TCQ_ADJUST_T prTcqAdjust, IN P_TX_TCQ_STATUS_T prTcqStatus);
  872. #if QM_ADAPTIVE_TC_RESOURCE_CTRL
  873. VOID qmReassignTcResource(IN P_ADAPTER_T prAdapter);
  874. VOID qmUpdateAverageTxQueLen(IN P_ADAPTER_T prAdapter);
  875. VOID qmDoAdaptiveTcResourceCtrl(IN P_ADAPTER_T prAdapter);
  876. VOID qmCheckForFastTcResourceCtrl(IN P_ADAPTER_T prAdapter, IN UINT_8 ucTc);
  877. #endif
  878. VOID qmDetermineStaRecIndex(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo);
  879. UINT_32
  880. qmDequeueTxPacketsFromPerStaQueues(IN P_ADAPTER_T prAdapter, OUT P_QUE_T prQue, IN UINT_8 ucTC, IN UINT_32
  881. u4CurrentQuota, IN UINT_32 u4TotalQuota);
  882. VOID
  883. qmDequeueTxPacketsFromPerTypeQueues(IN P_ADAPTER_T prAdapter, OUT P_QUE_T prQue, IN UINT_8 ucTC, IN UINT_32
  884. u4CurrentQuota, IN UINT_32 u4TotalQuota);
  885. UINT_32
  886. qmDequeueTxPacketsFromGlobalQueue(IN P_ADAPTER_T prAdapter, OUT P_QUE_T prQue, IN UINT_8 ucTC, IN UINT_32
  887. u4CurrentQuota, IN UINT_32 u4TotalQuota);
  888. VOID
  889. qmSetStaRecTxAllowed(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN BOOLEAN fgIsTxAllowed);
  890. /*----------------------------------------------------------------------------*/
  891. /* RX-Related Queue Management */
  892. /*----------------------------------------------------------------------------*/
  893. VOID qmInitRxQueues(IN P_ADAPTER_T prAdapter);
  894. P_SW_RFB_T qmFlushRxQueues(IN P_ADAPTER_T prAdapter);
  895. P_SW_RFB_T qmHandleRxPackets(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfbListHead);
  896. VOID qmProcessPktWithReordering(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT P_QUE_T prReturnedQue);
  897. VOID qmProcessBarFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT P_QUE_T prReturnedQue);
  898. VOID
  899. qmInsertFallWithinReorderPkt(IN P_SW_RFB_T prSwRfb, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
  900. VOID qmInsertFallAheadReorderPkt(IN P_SW_RFB_T prSwRfb, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
  901. VOID qmPopOutDueToFallWithin(IN P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
  902. VOID qmPopOutDueToFallAhead(IN P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
  903. VOID qmHandleReorderBubbleTimeout(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr);
  904. VOID qmHandleEventCheckReorderBubble(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  905. VOID qmHandleMailboxRxMessage(IN MAILBOX_MSG_T prMailboxRxMsg);
  906. BOOLEAN qmCompareSnIsLessThan(IN UINT_32 u4SnLess, IN UINT_32 u4SnGreater);
  907. VOID qmHandleEventRxAddBa(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  908. VOID qmHandleEventRxDelBa(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  909. P_RX_BA_ENTRY_T qmLookupRxBaEntry(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx, IN UINT_8 ucTid);
  910. BOOL
  911. qmAddRxBaEntry(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx, IN UINT_8 ucTid, IN UINT_16 u2WinStart, IN UINT_16
  912. u2WinSize);
  913. VOID qmDelRxBaEntry(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx, IN UINT_8 ucTid, IN BOOLEAN fgFlushToHost);
  914. VOID mqmProcessAssocRsp(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, IN PUINT_8 pucIE, IN UINT_16 u2IELength);
  915. VOID mqmProcessBcn(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, IN PUINT_8 pucIE, IN UINT_16 u2IELength);
  916. BOOLEAN
  917. mqmParseEdcaParameters(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, IN PUINT_8 pucIE, IN UINT_16 u2IELength, IN
  918. BOOLEAN fgForceOverride);
  919. BOOLEAN mqmCompareEdcaParameters(IN P_IE_WMM_PARAM_T prIeWmmParam, IN P_BSS_INFO_T prBssInfo);
  920. VOID mqmFillAcQueParam(IN P_IE_WMM_PARAM_T prIeWmmParam, IN UINT_32 u4AcOffset, OUT P_AC_QUE_PARMS_T prAcQueParams);
  921. VOID mqmProcessScanResult(IN P_ADAPTER_T prAdapter, IN P_BSS_DESC_T prScanResult, OUT P_STA_RECORD_T prStaRec);
  922. UINT_32
  923. mqmFillWmmInfoIE(P_UINT_8 pucOutBuf, BOOLEAN fgSupportUAPSD, UINT_8 ucBmpDeliveryAC, UINT_8 ucBmpTriggerAC, UINT_8
  924. ucUapsdSp);
  925. UINT_32
  926. mqmGenerateWmmInfoIEByStaRec(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_STA_RECORD_T prStaRec, P_UINT_8
  927. pucOutBuf);
  928. VOID mqmGenerateWmmInfoIE(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo);
  929. VOID mqmGenerateWmmParamIE(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo);
  930. #if CFG_SUPPORT_TDLS
  931. UINT_32 mqmGenerateWmmParamIEByParam(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, PUINT_8 pOutBuf);
  932. #endif
  933. ENUM_FRAME_ACTION_T qmGetFrameAction(IN P_ADAPTER_T prAdapter,
  934. IN UINT_8 ucBssIndex, IN UINT_8 ucStaRecIdx, IN P_MSDU_INFO_T prMsduInfo,
  935. IN ENUM_FRAME_TYPE_IN_CMD_Q_T eFrameType, IN UINT_16 u2FrameLength);
  936. VOID qmHandleEventBssAbsencePresence(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  937. VOID qmHandleEventStaChangePsMode(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  938. VOID mqmProcessAssocReq(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, IN PUINT_8 pucIE, IN UINT_16 u2IELength);
  939. VOID qmHandleEventStaUpdateFreeQuota(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
  940. VOID
  941. qmUpdateFreeQuota(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN UINT_8 ucUpdateMode, IN UINT_8 ucFreeQuota);
  942. VOID qmFreeAllByBssIdx(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex);
  943. UINT_32 qmGetRxReorderQueuedBufferCount(IN P_ADAPTER_T prAdapter);
  944. VOID qmDumpQueueStatus(IN P_ADAPTER_T prAdapter);
  945. #if CFG_M0VE_BA_TO_DRIVER
  946. VOID
  947. mqmSendDelBaFrame(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgIsInitiator, IN P_STA_RECORD_T prStaRec, IN UINT_32 u4Tid, IN
  948. UINT_32 u4ReasonCode);
  949. WLAN_STATUS
  950. mqmCallbackAddBaRspSent(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus);
  951. VOID mqmTimeoutCheckIdleRxBa(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr);
  952. VOID
  953. mqmRxModifyBaEntryStatus(IN P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prRxBaEntry, IN ENUM_BA_ENTRY_STATUS_T eStatus);
  954. VOID mqmHandleAddBaReq(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
  955. VOID mqmHandleBaActionFrame(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb);
  956. #endif
  957. /*******************************************************************************
  958. * F U N C T I O N S
  959. ********************************************************************************
  960. */
  961. #if QM_TEST_MODE
  962. extern QUE_MGT_T g_rQM;
  963. #endif
  964. extern const UINT_8 aucTid2ACI[TX_DESC_TID_NUM];
  965. extern const UINT_8 arNetwork2TcResource[HW_BSSID_NUM + 1][NET_TC_NUM];
  966. #endif /* _QUE_MGT_H */