nic_cmd_event.c 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic_cmd_event.c#3
  3. */
  4. /*! \file nic_cmd_event.c
  5. \brief Callback functions for Command packets.
  6. Various Event packet handlers which will be setup in the callback function of
  7. a command packet.
  8. */
  9. /*
  10. ** Log: nic_cmd_event.c
  11. **
  12. ** 06 12 2014 eason.tsai
  13. ** [ALPS01070904] [Need Patch] [Volunteer Patch]
  14. ** update BLBIST dump burst mode
  15. **
  16. ** Review: http://mtksap20:8080/go?page=NewReview&reviewid=110351
  17. **
  18. ** 04 08 2014 eason.tsai
  19. ** [ALPS01070904] [Need Patch] [Volunteer Patch]
  20. ** add for BLBIST dump index
  21. **
  22. ** 01 15 2014 eason.tsai
  23. ** [ALPS01070904] [Need Patch] [Volunteer Patch][MT6630][Driver]MT6630 Wi-Fi Patch
  24. ** Merging
  25. **
  26. ** //ALPS_SW/DEV/ALPS.JB2.MT6630.DEV/alps/mediatek/kernel/drivers/combo/drv_wlan/mt6630/wlan/...
  27. **
  28. ** to //ALPS_SW/TRUNK/KK/alps/mediatek/kernel/drivers/combo/drv_wlan/mt6630/wlan/...
  29. **
  30. ** 12 27 2013 eason.tsai
  31. ** [ALPS01070904] [Need Patch] [Volunteer Patch][MT6630][Driver]MT6630 Wi-Fi Patch
  32. ** update code for ICAP & nvram
  33. **
  34. ** 08 20 2013 eason.tsai
  35. ** [BORA00002255] [MT6630 Wi-Fi][Driver] develop
  36. ** Icap function
  37. **
  38. ** 08 20 2013 eason.tsai
  39. ** [BORA00002255] [MT6630 Wi-Fi][Driver] develop
  40. ** ICAP part for win32
  41. **
  42. ** 08 09 2013 cp.wu
  43. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  44. ** 1. integrate scheduled scan functionality
  45. ** 2. condition compilation for linux-3.4 & linux-3.8 compatibility
  46. ** 3. correct CMD queue access to reduce lock scope
  47. **
  48. ** 06 19 2013 cp.wu
  49. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  50. ** update MAC address handling logic
  51. **
  52. ** 06 18 2013 cm.chang
  53. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  54. ** Get MAC address by NIC_CAPABILITY command
  55. **
  56. ** 06 18 2013 terry.wu
  57. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  58. ** Update for 1st connection
  59. **
  60. ** 02 19 2013 cp.wu
  61. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  62. ** enable build for nic_rx.c & nic_cmd_event.c
  63. **
  64. ** 01 22 2013 cp.wu
  65. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  66. ** modification for ucBssIndex migration
  67. **
  68. ** 10 25 2012 cp.wu
  69. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  70. ** sync with MT6630 HIFSYS update.
  71. **
  72. ** 09 17 2012 cm.chang
  73. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  74. ** Duplicate source from MT6620 v2.3 driver branch
  75. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  76. **
  77. ** 09 04 2012 cp.wu
  78. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  79. ** sync RSSI ignoring when BSS is disconnected
  80. **
  81. ** 08 24 2012 cp.wu
  82. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  83. ** .
  84. **
  85. ** 08 24 2012 cp.wu
  86. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  87. ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
  88. *
  89. * 04 10 2012 yuche.tsai
  90. * NULL
  91. * Update address for wifi direct connection issue.
  92. *
  93. * 06 15 2011 cm.chang
  94. * [WCXRP00000785] [MT6620 Wi-Fi][Driver][FW] P2P/BOW MAC address is XOR with AIS MAC address
  95. * P2P/BOW mac address XOR with local bit instead of OR
  96. *
  97. * 03 05 2011 wh.su
  98. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  99. * add the code to get the check rsponse and indicate to app.
  100. *
  101. * 03 02 2011 wh.su
  102. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  103. * Add security check code.
  104. *
  105. * 02 24 2011 cp.wu
  106. * [WCXRP00000493] [MT6620 Wi-Fi][Driver] Do not indicate redundant
  107. * disconnection to host when entering into RF test mode
  108. * only indicate DISCONNECTION to host when entering RF test if necessary (connected -> disconnected cases)
  109. *
  110. * 01 20 2011 eddie.chen
  111. * [WCXRP00000374] [MT6620 Wi-Fi][DRV] SW debug control
  112. * Add Oid for sw control debug command
  113. *
  114. * 12 31 2010 cp.wu
  115. * [WCXRP00000335] [MT6620 Wi-Fi][Driver] change to use milliseconds sleep
  116. * instead of delay to avoid blocking to system scheduling
  117. * change to use msleep() and shorten waiting interval to reduce
  118. * blocking to other task while Wi-Fi driver is being loaded
  119. *
  120. * 12 01 2010 cp.wu
  121. * [WCXRP00000223] MT6620 Wi-Fi][Driver][FW] Adopt NVRAM parameters when enter/exit RF test mode
  122. * reload NVRAM settings before entering RF test mode and leaving from RF test mode.
  123. *
  124. * 11 01 2010 cp.wu
  125. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation
  126. * with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add
  127. * implementation for querying current TX rate from firmware auto rate module
  128. * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
  129. * 2) Remove CNM CH-RECOVER event handling
  130. * 3) cfg read/write API renamed with kal prefix for unified naming rules.
  131. *
  132. * 10 20 2010 cp.wu
  133. * [WCXRP00000117] [MT6620 Wi-Fi][Driver] Add logic for suspending driver when MT6620 is not responding anymore
  134. * use OID_CUSTOM_TEST_MODE as indication for driver reset
  135. * by dropping pending TX packets
  136. *
  137. * 10 18 2010 cp.wu
  138. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation
  139. * with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
  140. * complete implementation of Android NVRAM access
  141. *
  142. * 09 21 2010 cp.wu
  143. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete
  144. * and might leads to BSOD when entering RF test with AIS associated
  145. * Do a complete reset with STA-REC null checking for RF test re-entry
  146. *
  147. * 09 15 2010 yuche.tsai
  148. * NULL
  149. * Start to test AT GO only when P2P state is not IDLE.
  150. *
  151. * 09 09 2010 yuche.tsai
  152. * NULL
  153. * Add AT GO Test mode after MAC address available.
  154. *
  155. * 09 03 2010 kevin.huang
  156. * NULL
  157. * Refine #include sequence and solve recursive/nested #include issue
  158. *
  159. * 08 30 2010 cp.wu
  160. * NULL
  161. * eliminate klockwork errors
  162. *
  163. * 08 16 2010 cp.wu
  164. * NULL
  165. * Replace CFG_SUPPORT_BOW by CFG_ENABLE_BT_OVER_WIFI.
  166. * There is no CFG_SUPPORT_BOW in driver domain source.
  167. *
  168. * 08 12 2010 cp.wu
  169. * NULL
  170. * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
  171. *
  172. * 08 11 2010 yuche.tsai
  173. * NULL
  174. * Add support for P2P Device Address query from FW.
  175. *
  176. * 08 03 2010 cp.wu
  177. * NULL
  178. * Centralize mgmt/system service procedures into independent calls.
  179. *
  180. * 08 02 2010 cp.wu
  181. * NULL
  182. * reset FSMs before entering RF test mode.
  183. *
  184. * 07 22 2010 cp.wu
  185. *
  186. * 1) refine AIS-FSM indent.
  187. * 2) when entering RF Test mode, flush 802.1X frames as well
  188. * 3) when entering D3 state, flush 802.1X frames as well
  189. *
  190. * 07 08 2010 cp.wu
  191. *
  192. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  193. *
  194. * 07 05 2010 cp.wu
  195. * [WPD00003833][MT6620 and MT5931] Driver migration
  196. * 1) change fake BSS_DESC from channel 6 to channel 1 due to channel switching is not done yet.
  197. * 2) after MAC address is queried from firmware, all related variables in driver domain should be updated as well
  198. *
  199. * 06 21 2010 wh.su
  200. * [WPD00003840][MT6620 5931] Security migration
  201. * remove duplicate variable for migration.
  202. *
  203. * 06 06 2010 kevin.huang
  204. * [WPD00003832][MT6620 5931] Create driver base
  205. * [MT6620 5931] Create driver base
  206. *
  207. * 05 29 2010 cp.wu
  208. * [WPD00001943]Create WiFi test driver framework on WinXP
  209. * change upon request: indicate as disconnected in driver domain when leaving from RF test mode
  210. *
  211. * 05 24 2010 cp.wu
  212. * [WPD00001943]Create WiFi test driver framework on WinXP
  213. * do not clear scanning list array after disassociation
  214. *
  215. * 05 22 2010 cp.wu
  216. * [WPD00001943]Create WiFi test driver framework on WinXP
  217. * 1) disable NETWORK_LAYER_ADDRESSES handling temporally.
  218. * 2) finish statistics OIDs
  219. *
  220. * 05 22 2010 cp.wu
  221. * [WPD00001943]Create WiFi test driver framework on WinXP
  222. * change OID behavior to meet WHQL requirement.
  223. *
  224. * 05 20 2010 cp.wu
  225. * [WPD00001943]Create WiFi test driver framework on WinXP
  226. * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
  227. * 2) buffer statistics data for 2 seconds
  228. * 3) use default value for adhoc parameters instead of 0
  229. *
  230. * 05 19 2010 cp.wu
  231. * [WPD00001943]Create WiFi test driver framework on WinXP
  232. * 1) do not take timeout mechanism for power mode oids
  233. * 2) retrieve network type from connection status
  234. * 3) after disassciation, set radio state to off
  235. * 4) TCP option over IPv6 is supported
  236. *
  237. * 05 17 2010 cp.wu
  238. * [WPD00001943]Create WiFi test driver framework on WinXP
  239. * correct OID_802_11_DISASSOCIATE handling.
  240. *
  241. * 05 17 2010 cp.wu
  242. * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
  243. * 1) add timeout handler mechanism for pending command packets
  244. * 2) add p2p add/removal key
  245. *
  246. * 04 16 2010 cp.wu
  247. * [WPD00001943]Create WiFi test driver framework on WinXP
  248. * treat BUS access failure as kind of card removal.
  249. *
  250. * 04 14 2010 cp.wu
  251. * [WPD00001943]Create WiFi test driver framework on WinXP
  252. * information buffer for query oid/ioctl is now buffered in prCmdInfo
  253. * * * * * * instead of glue-layer variable to improve multiple oid/ioctl capability
  254. *
  255. * 04 13 2010 cp.wu
  256. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  257. * add framework for BT-over-Wi-Fi support.
  258. * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
  259. * * * * * * * * * * * * * * 2) command sequence number is now increased atomically
  260. * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
  261. *
  262. * 04 07 2010 cp.wu
  263. * [WPD00001943]Create WiFi test driver framework on WinXP
  264. * accessing to firmware load/start address, and access to OID handling information
  265. * are now handled in glue layer
  266. *
  267. * 04 07 2010 cp.wu
  268. * [WPD00001943]Create WiFi test driver framework on WinXP
  269. * rWlanInfo should be placed at adapter rather than glue due to most operations
  270. * * * * are done in adapter layer.
  271. *
  272. * 04 06 2010 cp.wu
  273. * [WPD00001943]Create WiFi test driver framework on WinXP
  274. * add KAL API: kalFlushPendingTxPackets(), and take use of the API
  275. *
  276. * 04 06 2010 cp.wu
  277. * [WPD00001943]Create WiFi test driver framework on WinXP
  278. * eliminate direct access to prGlueInfo->rWlanInfo.eLinkAttr.ucMediaStreamMode from non-glue layer.
  279. *
  280. * 04 06 2010 jeffrey.chang
  281. * [WPD00003826]Initial import for Linux port
  282. * improve none-glude code portability
  283. *
  284. * 04 06 2010 cp.wu
  285. * [WPD00001943]Create WiFi test driver framework on WinXP
  286. * sync statistics data structure definition with firmware implementation
  287. *
  288. * 04 06 2010 cp.wu
  289. * [WPD00001943]Create WiFi test driver framework on WinXP
  290. * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
  291. *
  292. * 04 06 2010 cp.wu
  293. * [WPD00001943]Create WiFi test driver framework on WinXP
  294. * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
  295. *
  296. * 03 30 2010 cp.wu
  297. * [WPD00001943]Create WiFi test driver framework on WinXP
  298. * statistics information OIDs are now handled by querying from firmware domain
  299. *
  300. * 03 26 2010 cp.wu
  301. * [WPD00001943]Create WiFi test driver framework on WinXP
  302. * indicate media stream mode after set is done
  303. *
  304. * 03 24 2010 jeffrey.chang
  305. * [WPD00003826]Initial import for Linux port
  306. * initial import for Linux port
  307. *
  308. * 03 03 2010 cp.wu
  309. * [WPD00001943]Create WiFi test driver framework on WinXP
  310. * implement custom OID: EEPROM read/write access
  311. *
  312. * 03 03 2010 cp.wu
  313. * [WPD00001943]Create WiFi test driver framework on WinXP
  314. * implement OID_802_3_MULTICAST_LIST oid handling
  315. *
  316. * 02 25 2010 cp.wu
  317. * [WPD00001943]Create WiFi test driver framework on WinXP
  318. * limit RSSI return value to microsoft defined range.
  319. *
  320. * 02 09 2010 cp.wu
  321. * [WPD00001943]Create WiFi test driver framework on WinXP
  322. * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
  323. * * * * * * * 2. follow MSDN defined behavior when associates to another AP
  324. * * * * * * * 3. for firmware download, packet size could be up to 2048 bytes
  325. *
  326. * 01 29 2010 cp.wu
  327. * [WPD00001943]Create WiFi test driver framework on WinXP
  328. * block until firmware finished RF test enter/leave then indicate completion to upper layer
  329. *
  330. * 01 29 2010 cp.wu
  331. * [WPD00001943]Create WiFi test driver framework on WinXP
  332. * when entering RF test mode and leaving from RF test mode,
  333. * wait for W_FUNC_RDY bit to be asserted forever until it is set or card is removed.
  334. *
  335. * 01 27 2010 cp.wu
  336. * [WPD00001943]Create WiFi test driver framework on WinXP
  337. * 1. eliminate improper variable in rHifInfo
  338. * * * * * * * * 2. block TX/ordinary OID when RF test mode is engaged
  339. * * * * * * * * 3. wait until firmware finish operation when entering into and leaving from RF test mode
  340. * * * * * * * * 4. correct some HAL implementation
  341. *
  342. * 01 26 2010 cp.wu
  343. * [WPD00001943]Create WiFi test driver framework on WinXP
  344. * Under WinXP with SDIO, use prGlueInfo->rHifInfo.pvInformationBuffer instead of prGlueInfo->pvInformationBuffer
  345. *
  346. * 01 22 2010 cp.wu
  347. * [WPD00001943]Create WiFi test driver framework on WinXP
  348. * implement following 802.11 OIDs:
  349. * * * * * OID_802_11_RSSI,
  350. * * * * * OID_802_11_RSSI_TRIGGER,
  351. * * * * * OID_802_11_STATISTICS,
  352. * * * * * OID_802_11_DISASSOCIATE,
  353. * * * * * OID_802_11_POWER_MODE
  354. *
  355. * 01 21 2010 cp.wu
  356. * [WPD00001943]Create WiFi test driver framework on WinXP
  357. * implement OID_802_11_MEDIA_STREAM_MODE
  358. *
  359. * 12 30 2009 cp.wu
  360. * [WPD00001943]Create WiFi test driver framework on WinXP
  361. * 1) According to CMD/EVENT documentation v0.8,
  362. * * * * * * * * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
  363. * * * * * * * * and result is retrieved by get ATInfo instead
  364. * * * * * * * * 2) add 4 counter for recording aggregation statistics
  365. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-12-10 16:47:47 GMT mtk02752
  366. ** only handle MCR read when accessing FW domain register
  367. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-12-08 17:37:28 GMT mtk02752
  368. ** * refine nicCmdEventQueryMcrRead
  369. ** + add TxStatus/RxStatus for RF test QueryInformation OIDs
  370. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-12-02 22:05:45 GMT mtk02752
  371. ** kalOidComplete() will decrease i4OidPendingCount
  372. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-12-01 23:02:57 GMT mtk02752
  373. ** remove unnecessary spin locks
  374. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-12-01 22:51:18 GMT mtk02752
  375. ** maintein i4OidPendingCount
  376. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-11-30 10:55:03 GMT mtk02752
  377. ** modify for compatibility
  378. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-11-23 14:46:32 GMT mtk02752
  379. ** add another version of command-done handler upon new event structure
  380. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-29 15:42:33 GMT mtk01461
  381. ** Add comment
  382. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-04-21 19:32:42 GMT mtk01461
  383. ** Add nicCmdEventSetCommon() for general set OID
  384. ** \main\maintrunk.MT6620WiFiDriver_Prj\1 2009-04-21 01:40:35 GMT mtk01461
  385. ** Command Done Handler
  386. */
  387. /*******************************************************************************
  388. * C O M P I L E R F L A G S
  389. ********************************************************************************
  390. */
  391. /*******************************************************************************
  392. * E X T E R N A L R E F E R E N C E S
  393. ********************************************************************************
  394. */
  395. #include "precomp.h"
  396. /*******************************************************************************
  397. * C O N S T A N T S
  398. ********************************************************************************
  399. */
  400. /*******************************************************************************
  401. * D A T A T Y P E S
  402. ********************************************************************************
  403. */
  404. /*******************************************************************************
  405. * P U B L I C D A T A
  406. ********************************************************************************
  407. */
  408. VOID nicCmdEventQueryMcrRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  409. {
  410. UINT_32 u4QueryInfoLen;
  411. P_PARAM_CUSTOM_MCR_RW_STRUCT_T prMcrRdInfo;
  412. P_GLUE_INFO_T prGlueInfo;
  413. P_CMD_ACCESS_REG prCmdAccessReg;
  414. ASSERT(prAdapter);
  415. ASSERT(prCmdInfo);
  416. ASSERT(pucEventBuf);
  417. /* 4 <2> Update information of OID */
  418. if (prCmdInfo->fgIsOid) {
  419. prGlueInfo = prAdapter->prGlueInfo;
  420. prCmdAccessReg = (P_CMD_ACCESS_REG) (pucEventBuf);
  421. u4QueryInfoLen = sizeof(PARAM_CUSTOM_MCR_RW_STRUCT_T);
  422. prMcrRdInfo = (P_PARAM_CUSTOM_MCR_RW_STRUCT_T) prCmdInfo->pvInformationBuffer;
  423. prMcrRdInfo->u4McrOffset = prCmdAccessReg->u4Address;
  424. prMcrRdInfo->u4McrData = prCmdAccessReg->u4Data;
  425. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  426. }
  427. return;
  428. }
  429. VOID nicCmdEventQuerySwCtrlRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  430. {
  431. UINT_32 u4QueryInfoLen;
  432. P_PARAM_CUSTOM_SW_CTRL_STRUCT_T prSwCtrlInfo;
  433. P_GLUE_INFO_T prGlueInfo;
  434. P_CMD_SW_DBG_CTRL_T prCmdSwCtrl;
  435. ASSERT(prAdapter);
  436. ASSERT(prCmdInfo);
  437. ASSERT(pucEventBuf);
  438. /* 4 <2> Update information of OID */
  439. if (prCmdInfo->fgIsOid) {
  440. prGlueInfo = prAdapter->prGlueInfo;
  441. prCmdSwCtrl = (P_CMD_SW_DBG_CTRL_T) (pucEventBuf);
  442. u4QueryInfoLen = sizeof(PARAM_CUSTOM_SW_CTRL_STRUCT_T);
  443. prSwCtrlInfo = (P_PARAM_CUSTOM_SW_CTRL_STRUCT_T) prCmdInfo->pvInformationBuffer;
  444. prSwCtrlInfo->u4Id = prCmdSwCtrl->u4Id;
  445. prSwCtrlInfo->u4Data = prCmdSwCtrl->u4Data;
  446. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  447. }
  448. return;
  449. }
  450. VOID nicCmdEventQueryChipConfig(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  451. {
  452. UINT_32 u4QueryInfoLen;
  453. P_PARAM_CUSTOM_CHIP_CONFIG_STRUCT_T prChipConfigInfo;
  454. P_GLUE_INFO_T prGlueInfo;
  455. P_CMD_CHIP_CONFIG_T prCmdChipConfig;
  456. ASSERT(prAdapter);
  457. ASSERT(prCmdInfo);
  458. ASSERT(pucEventBuf);
  459. /* 4 <2> Update information of OID */
  460. if (prCmdInfo->fgIsOid) {
  461. prGlueInfo = prAdapter->prGlueInfo;
  462. prCmdChipConfig = (P_CMD_CHIP_CONFIG_T) (pucEventBuf);
  463. u4QueryInfoLen = sizeof(PARAM_CUSTOM_CHIP_CONFIG_STRUCT_T);
  464. if (prCmdInfo->u4InformationBufferLength < sizeof(PARAM_CUSTOM_CHIP_CONFIG_STRUCT_T)) {
  465. DBGLOG(REQ, INFO,
  466. "Chip config u4InformationBufferLength %u is not valid (event)\n",
  467. prCmdInfo->u4InformationBufferLength);
  468. }
  469. prChipConfigInfo = (P_PARAM_CUSTOM_CHIP_CONFIG_STRUCT_T) prCmdInfo->pvInformationBuffer;
  470. prChipConfigInfo->ucRespType = prCmdChipConfig->ucRespType;
  471. prChipConfigInfo->u2MsgSize = prCmdChipConfig->u2MsgSize;
  472. DBGLOG(REQ, INFO, "%s: RespTyep %u\n", __func__, prChipConfigInfo->ucRespType);
  473. DBGLOG(REQ, INFO, "%s: u2MsgSize %u\n", __func__, prChipConfigInfo->u2MsgSize);
  474. if (prChipConfigInfo->u2MsgSize > CHIP_CONFIG_RESP_SIZE) {
  475. DBGLOG(REQ, INFO,
  476. "Chip config Msg Size %u is not valid (event)\n", prChipConfigInfo->u2MsgSize);
  477. prChipConfigInfo->u2MsgSize = CHIP_CONFIG_RESP_SIZE;
  478. }
  479. kalMemCopy(prChipConfigInfo->aucCmd, prCmdChipConfig->aucCmd, prChipConfigInfo->u2MsgSize);
  480. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  481. }
  482. return;
  483. }
  484. VOID nicCmdEventSetCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  485. {
  486. ASSERT(prAdapter);
  487. ASSERT(prCmdInfo);
  488. if (prCmdInfo->fgIsOid) {
  489. /* Update Set Information Length */
  490. kalOidComplete(prAdapter->prGlueInfo,
  491. prCmdInfo->fgSetQuery, prCmdInfo->u4InformationBufferLength, WLAN_STATUS_SUCCESS);
  492. }
  493. }
  494. VOID nicCmdEventSetDisassociate(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  495. {
  496. ASSERT(prAdapter);
  497. ASSERT(prCmdInfo);
  498. if (prCmdInfo->fgIsOid) {
  499. /* Update Set Information Length */
  500. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  501. }
  502. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  503. #if !defined(LINUX)
  504. prAdapter->fgIsRadioOff = TRUE;
  505. #endif
  506. }
  507. VOID nicCmdEventSetIpAddress(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  508. {
  509. UINT_32 u4Count;
  510. ASSERT(prAdapter);
  511. ASSERT(prCmdInfo);
  512. u4Count = (prCmdInfo->u4SetInfoLen - OFFSET_OF(CMD_SET_NETWORK_ADDRESS_LIST, arNetAddress))
  513. / sizeof(IPV4_NETWORK_ADDRESS);
  514. if (prCmdInfo->fgIsOid) {
  515. /* Update Set Information Length */
  516. kalOidComplete(prAdapter->prGlueInfo,
  517. prCmdInfo->fgSetQuery,
  518. OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress) + u4Count *
  519. (OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) +
  520. sizeof(PARAM_NETWORK_ADDRESS_IP)), WLAN_STATUS_SUCCESS);
  521. }
  522. }
  523. VOID nicCmdEventQueryRfTestATInfo(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  524. {
  525. P_EVENT_TEST_STATUS prTestStatus, prQueryBuffer;
  526. P_GLUE_INFO_T prGlueInfo;
  527. UINT_32 u4QueryInfoLen;
  528. ASSERT(prAdapter);
  529. ASSERT(prCmdInfo);
  530. prTestStatus = (P_EVENT_TEST_STATUS) pucEventBuf;
  531. if (prCmdInfo->fgIsOid) {
  532. prGlueInfo = prAdapter->prGlueInfo;
  533. prQueryBuffer = (P_EVENT_TEST_STATUS) prCmdInfo->pvInformationBuffer;
  534. /*Memory copy length is depended on upper-layer*/
  535. kalMemCopy(prQueryBuffer, prTestStatus, prCmdInfo->u4InformationBufferLength);
  536. u4QueryInfoLen = sizeof(EVENT_TEST_STATUS);
  537. /* Update Query Information Length */
  538. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  539. }
  540. }
  541. VOID nicCmdEventQueryLinkQuality(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  542. {
  543. PARAM_RSSI rRssi, *prRssi;
  544. P_EVENT_LINK_QUALITY prLinkQuality;
  545. P_GLUE_INFO_T prGlueInfo;
  546. UINT_32 u4QueryInfoLen;
  547. ASSERT(prAdapter);
  548. ASSERT(prCmdInfo);
  549. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  550. rRssi = (PARAM_RSSI) prLinkQuality->cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
  551. if (prAdapter->prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  552. if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
  553. rRssi = PARAM_WHQL_RSSI_MAX_DBM;
  554. else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
  555. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  556. } else {
  557. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  558. }
  559. if (prCmdInfo->fgIsOid) {
  560. prGlueInfo = prAdapter->prGlueInfo;
  561. prRssi = (PARAM_RSSI *) prCmdInfo->pvInformationBuffer;
  562. kalMemCopy(prRssi, &rRssi, sizeof(PARAM_RSSI));
  563. u4QueryInfoLen = sizeof(PARAM_RSSI);
  564. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  565. }
  566. }
  567. /*----------------------------------------------------------------------------*/
  568. /*!
  569. * @brief This routine is in response of OID_GEN_LINK_SPEED query request
  570. *
  571. * @param prAdapter Pointer to the Adapter structure.
  572. * @param prCmdInfo Pointer to the pending command info
  573. * @param pucEventBuf
  574. *
  575. * @retval none
  576. */
  577. /*----------------------------------------------------------------------------*/
  578. VOID nicCmdEventQueryLinkSpeed(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  579. {
  580. P_EVENT_LINK_QUALITY prLinkQuality;
  581. P_GLUE_INFO_T prGlueInfo;
  582. UINT_32 u4QueryInfoLen;
  583. PUINT_32 pu4LinkSpeed;
  584. ASSERT(prAdapter);
  585. ASSERT(prCmdInfo);
  586. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  587. if (prCmdInfo->fgIsOid) {
  588. prGlueInfo = prAdapter->prGlueInfo;
  589. pu4LinkSpeed = (PUINT_32) (prCmdInfo->pvInformationBuffer);
  590. *pu4LinkSpeed = prLinkQuality->u2LinkSpeed * 5000;
  591. u4QueryInfoLen = sizeof(UINT_32);
  592. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  593. }
  594. }
  595. VOID nicCmdEventQueryStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  596. {
  597. P_PARAM_802_11_STATISTICS_STRUCT_T prStatistics;
  598. P_EVENT_STATISTICS prEventStatistics;
  599. P_GLUE_INFO_T prGlueInfo;
  600. UINT_32 u4QueryInfoLen;
  601. ASSERT(prAdapter);
  602. ASSERT(prCmdInfo);
  603. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  604. if (prCmdInfo->fgIsOid) {
  605. prGlueInfo = prAdapter->prGlueInfo;
  606. u4QueryInfoLen = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  607. prStatistics = (P_PARAM_802_11_STATISTICS_STRUCT_T) prCmdInfo->pvInformationBuffer;
  608. prStatistics->u4Length = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  609. prStatistics->rTransmittedFragmentCount = prEventStatistics->rTransmittedFragmentCount;
  610. prStatistics->rMulticastTransmittedFrameCount = prEventStatistics->rMulticastTransmittedFrameCount;
  611. prStatistics->rFailedCount = prEventStatistics->rFailedCount;
  612. prStatistics->rRetryCount = prEventStatistics->rRetryCount;
  613. prStatistics->rMultipleRetryCount = prEventStatistics->rMultipleRetryCount;
  614. prStatistics->rRTSSuccessCount = prEventStatistics->rRTSSuccessCount;
  615. prStatistics->rRTSFailureCount = prEventStatistics->rRTSFailureCount;
  616. prStatistics->rACKFailureCount = prEventStatistics->rACKFailureCount;
  617. prStatistics->rFrameDuplicateCount = prEventStatistics->rFrameDuplicateCount;
  618. prStatistics->rReceivedFragmentCount = prEventStatistics->rReceivedFragmentCount;
  619. prStatistics->rMulticastReceivedFrameCount = prEventStatistics->rMulticastReceivedFrameCount;
  620. prStatistics->rFCSErrorCount = prEventStatistics->rFCSErrorCount;
  621. prStatistics->rTKIPLocalMICFailures.QuadPart = 0;
  622. prStatistics->rTKIPICVErrors.QuadPart = 0;
  623. prStatistics->rTKIPCounterMeasuresInvoked.QuadPart = 0;
  624. prStatistics->rTKIPReplays.QuadPart = 0;
  625. prStatistics->rCCMPFormatErrors.QuadPart = 0;
  626. prStatistics->rCCMPReplays.QuadPart = 0;
  627. prStatistics->rCCMPDecryptErrors.QuadPart = 0;
  628. prStatistics->rFourWayHandshakeFailures.QuadPart = 0;
  629. prStatistics->rWEPUndecryptableCount.QuadPart = 0;
  630. prStatistics->rWEPICVErrorCount.QuadPart = 0;
  631. prStatistics->rDecryptSuccessCount.QuadPart = 0;
  632. prStatistics->rDecryptFailureCount.QuadPart = 0;
  633. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  634. }
  635. }
  636. VOID nicCmdEventEnterRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  637. {
  638. UINT_32 u4WHISR = 0, u4Value = 0;
  639. UINT_16 au2TxCount[16];
  640. ASSERT(prAdapter);
  641. ASSERT(prCmdInfo);
  642. /* [driver-land] */
  643. /* prAdapter->fgTestMode = TRUE; */
  644. if (prAdapter->fgTestMode)
  645. prAdapter->fgTestMode = FALSE;
  646. else
  647. prAdapter->fgTestMode = TRUE;
  648. /* 0. always indicate disconnection */
  649. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED)
  650. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  651. /* 1. Remove pending TX */
  652. nicTxRelease(prAdapter, TRUE);
  653. /* 1.1 clear pending Security / Management Frames */
  654. kalClearSecurityFrames(prAdapter->prGlueInfo);
  655. kalClearMgmtFrames(prAdapter->prGlueInfo);
  656. /* 1.2 clear pending TX packet queued in glue layer */
  657. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  658. /* 2. Reset driver-domain FSMs */
  659. nicUninitMGMT(prAdapter);
  660. nicResetSystemService(prAdapter);
  661. nicInitMGMT(prAdapter, NULL);
  662. /* 3. Disable Interrupt */
  663. HAL_INTR_DISABLE(prAdapter);
  664. /* 4. Block til firmware completed entering into RF test mode */
  665. kalMsleep(500);
  666. while (1) {
  667. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  668. if (u4Value & WCIR_WLAN_READY) {
  669. break;
  670. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  671. if (prCmdInfo->fgIsOid) {
  672. /* Update Set Information Length */
  673. kalOidComplete(prAdapter->prGlueInfo,
  674. prCmdInfo->fgSetQuery,
  675. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  676. }
  677. return;
  678. }
  679. kalMsleep(10);
  680. }
  681. /* 5. Clear Interrupt Status */
  682. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  683. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  684. HAL_READ_TX_RELEASED_COUNT(prAdapter, au2TxCount);
  685. /* 6. Reset TX Counter */
  686. nicTxResetResource(prAdapter);
  687. /* 7. Re-enable Interrupt */
  688. HAL_INTR_ENABLE(prAdapter);
  689. /* 8. completion indication */
  690. if (prCmdInfo->fgIsOid) {
  691. /* Update Set Information Length */
  692. kalOidComplete(prAdapter->prGlueInfo,
  693. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  694. }
  695. #if CFG_SUPPORT_NVRAM
  696. /* 9. load manufacture data */
  697. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE)
  698. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  699. else
  700. DBGLOG(REQ, WARN, "%s: load manufacture data fail\n", __func__);
  701. #endif
  702. }
  703. VOID nicCmdEventLeaveRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  704. {
  705. UINT_32 u4WHISR = 0, u4Value = 0;
  706. UINT_16 au2TxCount[16];
  707. ASSERT(prAdapter);
  708. ASSERT(prCmdInfo);
  709. /* 1. Disable Interrupt */
  710. HAL_INTR_DISABLE(prAdapter);
  711. /* 2. Block til firmware completed leaving from RF test mode */
  712. kalMsleep(500);
  713. while (1) {
  714. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  715. if (u4Value & WCIR_WLAN_READY) {
  716. break;
  717. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  718. if (prCmdInfo->fgIsOid) {
  719. /* Update Set Information Length */
  720. kalOidComplete(prAdapter->prGlueInfo,
  721. prCmdInfo->fgSetQuery,
  722. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  723. }
  724. return;
  725. }
  726. kalMsleep(10);
  727. }
  728. /* 3. Clear Interrupt Status */
  729. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  730. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  731. HAL_READ_TX_RELEASED_COUNT(prAdapter, au2TxCount);
  732. /* 4. Reset TX Counter */
  733. nicTxResetResource(prAdapter);
  734. /* 5. Re-enable Interrupt */
  735. HAL_INTR_ENABLE(prAdapter);
  736. /* 6. set driver-land variable */
  737. prAdapter->fgTestMode = FALSE;
  738. prAdapter->fgIcapMode = FALSE;
  739. /* 7. completion indication */
  740. if (prCmdInfo->fgIsOid) {
  741. /* Update Set Information Length */
  742. kalOidComplete(prAdapter->prGlueInfo,
  743. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  744. }
  745. /* 8. Indicate as disconnected */
  746. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
  747. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  748. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  749. }
  750. #if CFG_SUPPORT_NVRAM
  751. /* 9. load manufacture data */
  752. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE)
  753. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  754. else
  755. DBGLOG(REQ, WARN, "%s: load manufacture data fail\n", __func__);
  756. #endif
  757. /* 10. Override network address */
  758. wlanUpdateNetworkAddress(prAdapter);
  759. }
  760. VOID nicCmdEventQueryMcastAddr(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  761. {
  762. UINT_32 u4QueryInfoLen;
  763. P_GLUE_INFO_T prGlueInfo;
  764. P_EVENT_MAC_MCAST_ADDR prEventMacMcastAddr;
  765. ASSERT(prAdapter);
  766. ASSERT(prCmdInfo);
  767. ASSERT(pucEventBuf);
  768. /* 4 <2> Update information of OID */
  769. if (prCmdInfo->fgIsOid) {
  770. prGlueInfo = prAdapter->prGlueInfo;
  771. prEventMacMcastAddr = (P_EVENT_MAC_MCAST_ADDR) (pucEventBuf);
  772. u4QueryInfoLen = prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN;
  773. /* buffer length check */
  774. if (prCmdInfo->u4InformationBufferLength < u4QueryInfoLen) {
  775. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_BUFFER_TOO_SHORT);
  776. } else {
  777. kalMemCopy(prCmdInfo->pvInformationBuffer,
  778. prEventMacMcastAddr->arAddress,
  779. prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN);
  780. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  781. }
  782. }
  783. }
  784. VOID nicCmdEventQueryEepromRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  785. {
  786. UINT_32 u4QueryInfoLen;
  787. P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T prEepromRdInfo;
  788. P_GLUE_INFO_T prGlueInfo;
  789. P_EVENT_ACCESS_EEPROM prEventAccessEeprom;
  790. ASSERT(prAdapter);
  791. ASSERT(prCmdInfo);
  792. ASSERT(pucEventBuf);
  793. /* 4 <2> Update information of OID */
  794. if (prCmdInfo->fgIsOid) {
  795. prGlueInfo = prAdapter->prGlueInfo;
  796. prEventAccessEeprom = (P_EVENT_ACCESS_EEPROM) (pucEventBuf);
  797. u4QueryInfoLen = sizeof(PARAM_CUSTOM_EEPROM_RW_STRUCT_T);
  798. prEepromRdInfo = (P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T) prCmdInfo->pvInformationBuffer;
  799. prEepromRdInfo->ucEepromIndex = (UINT_8) (prEventAccessEeprom->u2Offset);
  800. prEepromRdInfo->u2EepromData = prEventAccessEeprom->u2Data;
  801. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  802. }
  803. return;
  804. }
  805. VOID nicCmdEventSetMediaStreamMode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  806. {
  807. PARAM_MEDIA_STREAMING_INDICATION rParamMediaStreamIndication;
  808. ASSERT(prAdapter);
  809. ASSERT(prCmdInfo);
  810. if (prCmdInfo->fgIsOid) {
  811. /* Update Set Information Length */
  812. kalOidComplete(prAdapter->prGlueInfo,
  813. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  814. }
  815. rParamMediaStreamIndication.rStatus.eStatusType = ENUM_STATUS_TYPE_MEDIA_STREAM_MODE;
  816. rParamMediaStreamIndication.eMediaStreamMode =
  817. prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode == 0 ? ENUM_MEDIA_STREAM_OFF : ENUM_MEDIA_STREAM_ON;
  818. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  819. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  820. (PVOID)&rParamMediaStreamIndication, sizeof(PARAM_MEDIA_STREAMING_INDICATION));
  821. }
  822. VOID nicCmdEventSetStopSchedScan(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  823. {
  824. /*
  825. DBGLOG(SCN, INFO, "--->nicCmdEventSetStopSchedScan\n" ));
  826. */
  827. ASSERT(prAdapter);
  828. ASSERT(prCmdInfo);
  829. /*
  830. DBGLOG(SCN, INFO, "<--kalSchedScanStopped\n" );
  831. */
  832. if (prCmdInfo->fgIsOid) {
  833. /* Update Set Information Length */
  834. kalOidComplete(prAdapter->prGlueInfo,
  835. prCmdInfo->fgSetQuery, prCmdInfo->u4InformationBufferLength, WLAN_STATUS_SUCCESS);
  836. }
  837. DBGLOG(SCN, INFO, "nicCmdEventSetStopSchedScan OID done, release lock and send event to uplayer\n");
  838. /*Due to dead lock issue, need to release the IO control before calling kernel APIs */
  839. kalSchedScanStopped(prAdapter->prGlueInfo);
  840. }
  841. /* Statistics responder */
  842. VOID nicCmdEventQueryXmitOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  843. {
  844. P_EVENT_STATISTICS prEventStatistics;
  845. P_GLUE_INFO_T prGlueInfo;
  846. UINT_32 u4QueryInfoLen;
  847. PUINT_32 pu4Data;
  848. PUINT_64 pu8Data;
  849. ASSERT(prAdapter);
  850. ASSERT(prCmdInfo);
  851. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  852. if (prCmdInfo->fgIsOid) {
  853. prGlueInfo = prAdapter->prGlueInfo;
  854. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  855. u4QueryInfoLen = sizeof(UINT_32);
  856. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  857. *pu4Data = (UINT_32) prEventStatistics->rTransmittedFragmentCount.QuadPart;
  858. } else {
  859. u4QueryInfoLen = sizeof(UINT_64);
  860. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  861. *pu8Data = prEventStatistics->rTransmittedFragmentCount.QuadPart;
  862. }
  863. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  864. }
  865. }
  866. VOID nicCmdEventQueryRecvOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  867. {
  868. P_EVENT_STATISTICS prEventStatistics;
  869. P_GLUE_INFO_T prGlueInfo;
  870. UINT_32 u4QueryInfoLen;
  871. PUINT_32 pu4Data;
  872. PUINT_64 pu8Data;
  873. ASSERT(prAdapter);
  874. ASSERT(prCmdInfo);
  875. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  876. if (prCmdInfo->fgIsOid) {
  877. prGlueInfo = prAdapter->prGlueInfo;
  878. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  879. u4QueryInfoLen = sizeof(UINT_32);
  880. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  881. *pu4Data = (UINT_32) prEventStatistics->rReceivedFragmentCount.QuadPart;
  882. } else {
  883. u4QueryInfoLen = sizeof(UINT_64);
  884. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  885. *pu8Data = prEventStatistics->rReceivedFragmentCount.QuadPart;
  886. }
  887. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  888. }
  889. }
  890. VOID nicCmdEventQueryXmitError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  891. {
  892. P_EVENT_STATISTICS prEventStatistics;
  893. P_GLUE_INFO_T prGlueInfo;
  894. UINT_32 u4QueryInfoLen;
  895. PUINT_32 pu4Data;
  896. PUINT_64 pu8Data;
  897. ASSERT(prAdapter);
  898. ASSERT(prCmdInfo);
  899. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  900. if (prCmdInfo->fgIsOid) {
  901. prGlueInfo = prAdapter->prGlueInfo;
  902. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  903. u4QueryInfoLen = sizeof(UINT_32);
  904. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  905. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  906. } else {
  907. u4QueryInfoLen = sizeof(UINT_64);
  908. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  909. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  910. }
  911. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  912. }
  913. }
  914. VOID nicCmdEventQueryRecvError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  915. {
  916. P_EVENT_STATISTICS prEventStatistics;
  917. P_GLUE_INFO_T prGlueInfo;
  918. UINT_32 u4QueryInfoLen;
  919. PUINT_32 pu4Data;
  920. PUINT_64 pu8Data;
  921. ASSERT(prAdapter);
  922. ASSERT(prCmdInfo);
  923. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  924. if (prCmdInfo->fgIsOid) {
  925. prGlueInfo = prAdapter->prGlueInfo;
  926. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  927. u4QueryInfoLen = sizeof(UINT_32);
  928. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  929. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  930. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  931. } else {
  932. u4QueryInfoLen = sizeof(UINT_64);
  933. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  934. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  935. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  936. }
  937. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  938. }
  939. }
  940. VOID nicCmdEventQueryRecvNoBuffer(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  941. {
  942. P_GLUE_INFO_T prGlueInfo;
  943. UINT_32 u4QueryInfoLen;
  944. PUINT_32 pu4Data;
  945. PUINT_64 pu8Data;
  946. ASSERT(prAdapter);
  947. ASSERT(prCmdInfo);
  948. if (prCmdInfo->fgIsOid) {
  949. prGlueInfo = prAdapter->prGlueInfo;
  950. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  951. u4QueryInfoLen = sizeof(UINT_32);
  952. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  953. *pu4Data = 0; /* @FIXME? */
  954. } else {
  955. u4QueryInfoLen = sizeof(UINT_64);
  956. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  957. *pu8Data = 0; /* @FIXME? */
  958. }
  959. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  960. }
  961. }
  962. VOID nicCmdEventQueryRecvCrcError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  963. {
  964. P_EVENT_STATISTICS prEventStatistics;
  965. P_GLUE_INFO_T prGlueInfo;
  966. UINT_32 u4QueryInfoLen;
  967. PUINT_32 pu4Data;
  968. PUINT_64 pu8Data;
  969. ASSERT(prAdapter);
  970. ASSERT(prCmdInfo);
  971. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  972. if (prCmdInfo->fgIsOid) {
  973. prGlueInfo = prAdapter->prGlueInfo;
  974. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  975. u4QueryInfoLen = sizeof(UINT_32);
  976. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  977. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  978. } else {
  979. u4QueryInfoLen = sizeof(UINT_64);
  980. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  981. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  982. }
  983. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  984. }
  985. }
  986. VOID nicCmdEventQueryRecvErrorAlignment(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  987. {
  988. P_GLUE_INFO_T prGlueInfo;
  989. UINT_32 u4QueryInfoLen;
  990. PUINT_32 pu4Data;
  991. PUINT_64 pu8Data;
  992. ASSERT(prAdapter);
  993. ASSERT(prCmdInfo);
  994. if (prCmdInfo->fgIsOid) {
  995. prGlueInfo = prAdapter->prGlueInfo;
  996. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  997. u4QueryInfoLen = sizeof(UINT_32);
  998. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  999. *pu4Data = (UINT_32) 0; /* @FIXME */
  1000. } else {
  1001. u4QueryInfoLen = sizeof(UINT_64);
  1002. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1003. *pu8Data = 0; /* @FIXME */
  1004. }
  1005. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1006. }
  1007. }
  1008. VOID nicCmdEventQueryXmitOneCollision(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1009. {
  1010. P_EVENT_STATISTICS prEventStatistics;
  1011. P_GLUE_INFO_T prGlueInfo;
  1012. UINT_32 u4QueryInfoLen;
  1013. PUINT_32 pu4Data;
  1014. PUINT_64 pu8Data;
  1015. ASSERT(prAdapter);
  1016. ASSERT(prCmdInfo);
  1017. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1018. if (prCmdInfo->fgIsOid) {
  1019. prGlueInfo = prAdapter->prGlueInfo;
  1020. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1021. u4QueryInfoLen = sizeof(UINT_32);
  1022. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1023. *pu4Data =
  1024. (UINT_32) (prEventStatistics->rMultipleRetryCount.QuadPart -
  1025. prEventStatistics->rRetryCount.QuadPart);
  1026. } else {
  1027. u4QueryInfoLen = sizeof(UINT_64);
  1028. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1029. *pu8Data =
  1030. (UINT_64) (prEventStatistics->rMultipleRetryCount.QuadPart -
  1031. prEventStatistics->rRetryCount.QuadPart);
  1032. }
  1033. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1034. }
  1035. }
  1036. VOID nicCmdEventQueryXmitMoreCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1037. {
  1038. P_EVENT_STATISTICS prEventStatistics;
  1039. P_GLUE_INFO_T prGlueInfo;
  1040. UINT_32 u4QueryInfoLen;
  1041. PUINT_32 pu4Data;
  1042. PUINT_64 pu8Data;
  1043. ASSERT(prAdapter);
  1044. ASSERT(prCmdInfo);
  1045. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1046. if (prCmdInfo->fgIsOid) {
  1047. prGlueInfo = prAdapter->prGlueInfo;
  1048. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1049. u4QueryInfoLen = sizeof(UINT_32);
  1050. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1051. *pu4Data = (UINT_32) prEventStatistics->rMultipleRetryCount.QuadPart;
  1052. } else {
  1053. u4QueryInfoLen = sizeof(UINT_64);
  1054. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1055. *pu8Data = (UINT_64) prEventStatistics->rMultipleRetryCount.QuadPart;
  1056. }
  1057. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1058. }
  1059. }
  1060. VOID nicCmdEventQueryXmitMaxCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1061. {
  1062. P_EVENT_STATISTICS prEventStatistics;
  1063. P_GLUE_INFO_T prGlueInfo;
  1064. UINT_32 u4QueryInfoLen;
  1065. PUINT_32 pu4Data;
  1066. PUINT_64 pu8Data;
  1067. ASSERT(prAdapter);
  1068. ASSERT(prCmdInfo);
  1069. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1070. if (prCmdInfo->fgIsOid) {
  1071. prGlueInfo = prAdapter->prGlueInfo;
  1072. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1073. u4QueryInfoLen = sizeof(UINT_32);
  1074. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1075. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  1076. } else {
  1077. u4QueryInfoLen = sizeof(UINT_64);
  1078. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1079. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  1080. }
  1081. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1082. }
  1083. }
  1084. /*----------------------------------------------------------------------------*/
  1085. /*!
  1086. * @brief This function is called when command by OID/ioctl has been timeout
  1087. *
  1088. * @param prAdapter Pointer to the Adapter structure.
  1089. * @param prCmdInfo Pointer to the command information
  1090. *
  1091. * @return TRUE
  1092. * FALSE
  1093. */
  1094. /*----------------------------------------------------------------------------*/
  1095. VOID nicOidCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1096. {
  1097. ASSERT(prAdapter);
  1098. if (prCmdInfo->fgIsOid)
  1099. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1100. }
  1101. /*----------------------------------------------------------------------------*/
  1102. /*!
  1103. * @brief This function is a generic command timeout handler
  1104. *
  1105. * @param pfnOidHandler Pointer to the OID handler
  1106. *
  1107. * @return none
  1108. */
  1109. /*----------------------------------------------------------------------------*/
  1110. VOID nicCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1111. {
  1112. ASSERT(prAdapter);
  1113. }
  1114. /*----------------------------------------------------------------------------*/
  1115. /*!
  1116. * @brief This function is called when command for entering RF test has
  1117. * failed sending due to timeout (highly possibly by firmware crash)
  1118. *
  1119. * @param prAdapter Pointer to the Adapter structure.
  1120. * @param prCmdInfo Pointer to the command information
  1121. *
  1122. * @return none
  1123. *
  1124. */
  1125. /*----------------------------------------------------------------------------*/
  1126. VOID nicOidCmdEnterRFTestTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1127. {
  1128. ASSERT(prAdapter);
  1129. /* 1. Remove pending TX frames */
  1130. nicTxRelease(prAdapter, TRUE);
  1131. /* 1.1 clear pending Security / Management Frames */
  1132. kalClearSecurityFrames(prAdapter->prGlueInfo);
  1133. kalClearMgmtFrames(prAdapter->prGlueInfo);
  1134. /* 1.2 clear pending TX packet queued in glue layer */
  1135. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  1136. /* 2. indicate for OID failure */
  1137. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1138. }
  1139. /*----------------------------------------------------------------------------*/
  1140. /*!
  1141. * @brief This function is called to handle dump burst event
  1142. *
  1143. * @param prAdapter Pointer to the Adapter structure.
  1144. * @param prCmdInfo Pointer to the command information
  1145. * @param pucEventBuf Pointer to event buffer
  1146. *
  1147. * @return none
  1148. *
  1149. */
  1150. /*----------------------------------------------------------------------------*/
  1151. VOID nicEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucEventBuf)
  1152. {
  1153. static UINT_8 aucPath[256];
  1154. static UINT_8 aucPath_done[300];
  1155. static UINT_32 u4CurTimeTick;
  1156. P_EVENT_DUMP_MEM_T prEventDumpMem;
  1157. ASSERT(prAdapter);
  1158. ASSERT(pucEventBuf);
  1159. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1160. prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
  1161. if (kalCheckPath(aucPath) == -1) {
  1162. kalMemSet(aucPath, 0x00, 256);
  1163. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1164. }
  1165. if (prEventDumpMem->ucFragNum == 1) {
  1166. /* Store memory dump into sdcard,
  1167. * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
  1168. */
  1169. u4CurTimeTick = kalGetTimeTick();
  1170. #if defined(LINUX)
  1171. /*if blbist mkdir undre /data/blbist, the dump files wouls put on it */
  1172. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1173. if (kalCheckPath(aucPath) == -1) {
  1174. kalMemSet(aucPath, 0x00, 256);
  1175. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1176. }
  1177. #else
  1178. kal_sprintf_ddk(aucPath, sizeof(aucPath),
  1179. u4CurTimeTick,
  1180. prEventDumpMem->u4Address, prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1181. #endif
  1182. kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1183. } else {
  1184. /* Append current memory dump to the hex file */
  1185. kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1186. }
  1187. DBGLOG(INIT, INFO,
  1188. ": ==> (u4RemainLength = %x, u4Address=%x )\n", prEventDumpMem->u4RemainLength,
  1189. prEventDumpMem->u4Address);
  1190. if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
  1191. /* The request is finished or firmware response a error */
  1192. /* Reply time tick to iwpriv */
  1193. g_bIcapEnable = FALSE;
  1194. g_bCaptureDone = TRUE;
  1195. sprintf(aucPath_done, "/data/blbist/file_dump_done.txt");
  1196. if (kalCheckPath(aucPath_done) == -1) {
  1197. kalMemSet(aucPath_done, 0x00, 256);
  1198. sprintf(aucPath_done, "/data/file_dump_done.txt");
  1199. }
  1200. DBGLOG(INIT, INFO, ": ==> gen done_file\n");
  1201. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1202. g_u2DumpIndex++;
  1203. }
  1204. }
  1205. /*----------------------------------------------------------------------------*/
  1206. /*!
  1207. * @brief This function is called when command for memory dump has
  1208. * replied a event.
  1209. *
  1210. * @param prAdapter Pointer to the Adapter structure.
  1211. * @param prCmdInfo Pointer to the command information
  1212. * @param pucEventBuf Pointer to event buffer
  1213. *
  1214. * @return none
  1215. *
  1216. */
  1217. /*----------------------------------------------------------------------------*/
  1218. VOID nicCmdEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1219. {
  1220. static UINT_8 aucPath[256];
  1221. static UINT_8 aucPath_done[300];
  1222. static UINT_32 u4CurTimeTick;
  1223. P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T prMemDumpInfo;
  1224. P_GLUE_INFO_T prGlueInfo;
  1225. P_EVENT_DUMP_MEM_T prEventDumpMem;
  1226. UINT_32 u4QueryInfoLen;
  1227. ASSERT(prAdapter);
  1228. ASSERT(prCmdInfo);
  1229. ASSERT(pucEventBuf);
  1230. /* 4 <2> Update information of OID */
  1231. if (1) {
  1232. prGlueInfo = prAdapter->prGlueInfo;
  1233. prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
  1234. u4QueryInfoLen = sizeof(P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T);
  1235. prMemDumpInfo = (P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T) prCmdInfo->pvInformationBuffer;
  1236. prMemDumpInfo->u4Address = prEventDumpMem->u4Address;
  1237. prMemDumpInfo->u4Length = prEventDumpMem->u4Length;
  1238. prMemDumpInfo->u4RemainLength = prEventDumpMem->u4RemainLength;
  1239. prMemDumpInfo->ucFragNum = prEventDumpMem->ucFragNum;
  1240. #if 0
  1241. do {
  1242. UINT_32 i = 0;
  1243. DBGLOG(REQ, TRACE, "Rx dump address 0x%X, Length %d, FragNum %d, remain %d\n",
  1244. prEventDumpMem->u4Address,
  1245. prEventDumpMem->u4Length, prEventDumpMem->ucFragNum, prEventDumpMem->u4RemainLength);
  1246. #if 0
  1247. for (i = 0; i < prEventDumpMem->u4Length; i++) {
  1248. DBGLOG(REQ, TRACE, "%02X ", prEventDumpMem->aucBuffer[i]);
  1249. if (i % 32 == 31)
  1250. DBGLOG(REQ, TRACE, "\n");
  1251. }
  1252. #endif
  1253. } while (FALSE);
  1254. #endif
  1255. if (prEventDumpMem->ucFragNum == 1) {
  1256. /* Store memory dump into sdcard,
  1257. * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
  1258. */
  1259. u4CurTimeTick = kalGetTimeTick();
  1260. #if defined(LINUX)
  1261. #if 0
  1262. sprintf(aucPath, "/sdcard/dump_%ld_0x%08lX_%ld.hex",
  1263. u4CurTimeTick,
  1264. prEventDumpMem->u4Address, prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1265. #else
  1266. /*if blbist mkdir undre /data/blbist, the dump files wouls put on it */
  1267. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1268. if (kalCheckPath(aucPath) == -1) {
  1269. kalMemSet(aucPath, 0x00, 256);
  1270. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1271. }
  1272. #endif
  1273. #else
  1274. kal_sprintf_ddk(aucPath, sizeof(aucPath),
  1275. u4CurTimeTick,
  1276. prEventDumpMem->u4Address,
  1277. prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1278. /* strcpy(aucPath, "dump.hex"); */
  1279. #endif
  1280. kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1281. } else {
  1282. /* Append current memory dump to the hex file */
  1283. kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1284. }
  1285. if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
  1286. /* The request is finished or firmware response a error */
  1287. /* Reply time tick to iwpriv */
  1288. if (prCmdInfo->fgIsOid) {
  1289. /* the oid would be complete only in oid-trigger mode,
  1290. * that is no need to if the event-trigger */
  1291. if (g_bIcapEnable == FALSE) {
  1292. *((PUINT_32) prCmdInfo->pvInformationBuffer) = u4CurTimeTick;
  1293. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery,
  1294. u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1295. }
  1296. }
  1297. g_bIcapEnable = FALSE;
  1298. g_bCaptureDone = TRUE;
  1299. #if defined(LINUX)
  1300. sprintf(aucPath_done, "/data/blbist/file_dump_done.txt");
  1301. if (kalCheckPath(aucPath_done) == -1) {
  1302. kalMemSet(aucPath_done, 0x00, 256);
  1303. sprintf(aucPath_done, "/data/file_dump_done.txt");
  1304. }
  1305. DBGLOG(INIT, INFO, ": ==> gen done_file\n");
  1306. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1307. g_u2DumpIndex++;
  1308. #else
  1309. kal_sprintf_done_ddk(aucPath_done, sizeof(aucPath_done));
  1310. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1311. #endif
  1312. } else {
  1313. #if defined(LINUX)
  1314. #else /* 2013/05/26 fw would try to send the buffer successfully */
  1315. /* The memory dump request is not finished, Send next command */
  1316. wlanSendMemDumpCmd(prAdapter,
  1317. prCmdInfo->pvInformationBuffer, prCmdInfo->u4InformationBufferLength);
  1318. #endif
  1319. }
  1320. }
  1321. return;
  1322. }
  1323. #if CFG_SUPPORT_BATCH_SCAN
  1324. /*----------------------------------------------------------------------------*/
  1325. /*!
  1326. * @brief This function is called when event for SUPPORT_BATCH_SCAN
  1327. *
  1328. * @param prAdapter Pointer to the Adapter structure.
  1329. * @param prCmdInfo Pointer to the command information
  1330. * @param pucEventBuf Pointer to the event buffer
  1331. *
  1332. * @return none
  1333. *
  1334. */
  1335. /*----------------------------------------------------------------------------*/
  1336. VOID nicCmdEventBatchScanResult(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1337. {
  1338. UINT_32 u4QueryInfoLen;
  1339. P_EVENT_BATCH_RESULT_T prEventBatchResult;
  1340. P_GLUE_INFO_T prGlueInfo;
  1341. DBGLOG(SCN, TRACE, "nicCmdEventBatchScanResult");
  1342. ASSERT(prAdapter);
  1343. ASSERT(prCmdInfo);
  1344. ASSERT(pucEventBuf);
  1345. /* 4 <2> Update information of OID */
  1346. if (prCmdInfo->fgIsOid) {
  1347. prGlueInfo = prAdapter->prGlueInfo;
  1348. prEventBatchResult = (P_EVENT_BATCH_RESULT_T) pucEventBuf;
  1349. u4QueryInfoLen = sizeof(EVENT_BATCH_RESULT_T);
  1350. kalMemCopy(prCmdInfo->pvInformationBuffer, prEventBatchResult, sizeof(EVENT_BATCH_RESULT_T));
  1351. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1352. }
  1353. }
  1354. #endif
  1355. #if CFG_SUPPORT_BUILD_DATE_CODE
  1356. /*----------------------------------------------------------------------------*/
  1357. /*!
  1358. * @brief This function is called when event for build date code information
  1359. * has been retrieved
  1360. *
  1361. * @param prAdapter Pointer to the Adapter structure.
  1362. * @param prCmdInfo Pointer to the command information
  1363. * @param pucEventBuf Pointer to the event buffer
  1364. *
  1365. * @return none
  1366. *
  1367. */
  1368. /*----------------------------------------------------------------------------*/
  1369. VOID nicCmdEventBuildDateCode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1370. {
  1371. UINT_32 u4QueryInfoLen;
  1372. P_EVENT_BUILD_DATE_CODE prEvent;
  1373. P_GLUE_INFO_T prGlueInfo;
  1374. ASSERT(prAdapter);
  1375. ASSERT(prCmdInfo);
  1376. ASSERT(pucEventBuf);
  1377. /* 4 <2> Update information of OID */
  1378. if (prCmdInfo->fgIsOid) {
  1379. prGlueInfo = prAdapter->prGlueInfo;
  1380. prEvent = (P_EVENT_BUILD_DATE_CODE) pucEventBuf;
  1381. u4QueryInfoLen = sizeof(UINT_8) * 16;
  1382. kalMemCopy(prCmdInfo->pvInformationBuffer, prEvent->aucDateCode, sizeof(UINT_8) * 16);
  1383. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1384. }
  1385. }
  1386. #endif
  1387. /*----------------------------------------------------------------------------*/
  1388. /*!
  1389. * @brief This function is called when event for query STA link status
  1390. * has been retrieved
  1391. *
  1392. * @param prAdapter Pointer to the Adapter structure.
  1393. * @param prCmdInfo Pointer to the command information
  1394. * @param pucEventBuf Pointer to the event buffer
  1395. *
  1396. * @return none
  1397. *
  1398. */
  1399. /*----------------------------------------------------------------------------*/
  1400. VOID nicCmdEventQueryStaStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1401. {
  1402. UINT_32 u4QueryInfoLen;
  1403. P_EVENT_STA_STATISTICS_T prEvent;
  1404. P_GLUE_INFO_T prGlueInfo;
  1405. P_PARAM_GET_STA_STATISTICS prStaStatistics;
  1406. ENUM_WMM_ACI_T eAci;
  1407. P_STA_RECORD_T prStaRec;
  1408. ASSERT(prAdapter);
  1409. ASSERT(prCmdInfo);
  1410. ASSERT(pucEventBuf);
  1411. if (prCmdInfo->fgIsOid) {
  1412. prGlueInfo = prAdapter->prGlueInfo;
  1413. prEvent = (P_EVENT_STA_STATISTICS_T) pucEventBuf;
  1414. prStaStatistics = (P_PARAM_GET_STA_STATISTICS) prCmdInfo->pvInformationBuffer;
  1415. u4QueryInfoLen = sizeof(PARAM_GET_STA_STA_STATISTICS);
  1416. /* Statistics from FW is valid */
  1417. if (prEvent->u4Flags & BIT(0)) {
  1418. prStaStatistics->ucPer = prEvent->ucPer;
  1419. prStaStatistics->ucRcpi = prEvent->ucRcpi;
  1420. prStaStatistics->u4PhyMode = prEvent->u4PhyMode;
  1421. prStaStatistics->u2LinkSpeed = prEvent->u2LinkSpeed;
  1422. prStaStatistics->u4TxFailCount = prEvent->u4TxFailCount;
  1423. prStaStatistics->u4TxLifeTimeoutCount = prEvent->u4TxLifeTimeoutCount;
  1424. prStaRec = cnmGetStaRecByIndex(prAdapter, prEvent->ucStaRecIdx);
  1425. if (prStaRec) {
  1426. /*link layer statistics */
  1427. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  1428. prStaStatistics->arLinkStatistics[eAci].u4TxFailMsdu =
  1429. prEvent->arLinkStatistics[eAci].u4TxFailMsdu;
  1430. prStaStatistics->arLinkStatistics[eAci].u4TxRetryMsdu =
  1431. prEvent->arLinkStatistics[eAci].u4TxRetryMsdu;
  1432. /*for dump bss statistics */
  1433. prStaRec->arLinkStatistics[eAci].u4TxFailMsdu =
  1434. prEvent->arLinkStatistics[eAci].u4TxFailMsdu;
  1435. prStaRec->arLinkStatistics[eAci].u4TxRetryMsdu =
  1436. prEvent->arLinkStatistics[eAci].u4TxRetryMsdu;
  1437. }
  1438. }
  1439. if (prEvent->u4TxCount) {
  1440. UINT_32 u4TxDoneAirTimeMs = USEC_TO_MSEC(prEvent->u4TxDoneAirTime * 32);
  1441. prStaStatistics->u4TxAverageAirTime = (u4TxDoneAirTimeMs / prEvent->u4TxCount);
  1442. } else {
  1443. prStaStatistics->u4TxAverageAirTime = 0;
  1444. }
  1445. }
  1446. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1447. }
  1448. }
  1449. #if CFG_AUTO_CHANNEL_SEL_SUPPORT
  1450. /* 4 Auto Channel Selection */
  1451. /*----------------------------------------------------------------------------*/
  1452. /*!
  1453. * @brief This function is called when event for query STA link status
  1454. * has been retrieved
  1455. *
  1456. * @param prAdapter Pointer to the Adapter structure.
  1457. * @param prCmdInfo Pointer to the command information
  1458. * @param pucEventBuf Pointer to the event buffer
  1459. *
  1460. * @return none
  1461. *
  1462. */
  1463. /*----------------------------------------------------------------------------*/
  1464. VOID nicCmdEventQueryChannelLoad(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1465. {
  1466. UINT_32 u4QueryInfoLen;
  1467. P_EVENT_CHN_LOAD_T prEvent;
  1468. P_GLUE_INFO_T prGlueInfo;
  1469. P_PARAM_GET_CHN_LOAD prChnLoad;
  1470. ASSERT(prAdapter);
  1471. ASSERT(prCmdInfo);
  1472. ASSERT(pucEventBuf);
  1473. if (prCmdInfo->fgIsOid) {
  1474. prGlueInfo = prAdapter->prGlueInfo;
  1475. prEvent = (P_EVENT_CHN_LOAD_T) pucEventBuf; /* 4 The firmware responsed data */
  1476. /* 4 Fill the firmware data in and send it back to host */
  1477. prChnLoad = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1478. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1479. /* Statistics from FW is valid */
  1480. if (prEvent->u4Flags & BIT(0)) {
  1481. prChnLoad->rEachChnLoad[0].ucChannel = prEvent->ucChannel;
  1482. prChnLoad->rEachChnLoad[0].u2ChannelLoad = prEvent->u2ChannelLoad;
  1483. DBGLOG(P2P, INFO, "CHN[%d]=%d\n", prEvent->ucChannel, prEvent->u2ChannelLoad);
  1484. }
  1485. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1486. }
  1487. }
  1488. VOID nicCmdEventQueryLTESafeChn(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1489. {
  1490. UINT_32 u4QueryInfoLen;
  1491. P_EVENT_LTE_MODE_T prEvent;
  1492. P_GLUE_INFO_T prGlueInfo;
  1493. P_PARAM_GET_CHN_LOAD prLteSafeChnInfo;
  1494. ASSERT(prAdapter);
  1495. ASSERT(prCmdInfo);
  1496. ASSERT(pucEventBuf);
  1497. if (prCmdInfo->fgIsOid) {
  1498. prGlueInfo = prAdapter->prGlueInfo;
  1499. prEvent = (P_EVENT_LTE_MODE_T) pucEventBuf; /* 4 The firmware responsed data */
  1500. prLteSafeChnInfo = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1501. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1502. /* Statistics from FW is valid */
  1503. if (prEvent->u4Flags & BIT(0)) {
  1504. /* prLteSafeChnInfo->rLteSafeChnList.ucChannelHigh= prEvent->rLteSafeChn.ucChannelHigh; */
  1505. /* prLteSafeChnInfo->rLteSafeChnList.ucChannelLow= prEvent->rLteSafeChn.ucChannelLow; */
  1506. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[0] =
  1507. prEvent->rLteSafeChn.u4SafeChannelBitmask[0];
  1508. if (prEvent->ucVersion != 0) {
  1509. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[1] =
  1510. prEvent->rLteSafeChn.u4SafeChannelBitmask[1];
  1511. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[2] =
  1512. prEvent->rLteSafeChn.u4SafeChannelBitmask[2];
  1513. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[3] =
  1514. prEvent->rLteSafeChn.u4SafeChannelBitmask[3];
  1515. }
  1516. DBGLOG(P2P, INFO,
  1517. "[Query-info Auto Channel]LTE safe channels 0x%08x\n",
  1518. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[0]);
  1519. }
  1520. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1521. }
  1522. }
  1523. #endif