nic_cmd_event.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807
  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. kalMemCopy(prQueryBuffer, prTestStatus, sizeof(EVENT_TEST_STATUS));
  535. u4QueryInfoLen = sizeof(EVENT_TEST_STATUS);
  536. /* Update Query Information Length */
  537. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  538. }
  539. }
  540. VOID nicCmdEventQueryLinkQuality(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  541. {
  542. PARAM_RSSI rRssi, *prRssi;
  543. P_EVENT_LINK_QUALITY prLinkQuality;
  544. P_GLUE_INFO_T prGlueInfo;
  545. UINT_32 u4QueryInfoLen;
  546. ASSERT(prAdapter);
  547. ASSERT(prCmdInfo);
  548. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  549. rRssi = (PARAM_RSSI) prLinkQuality->cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
  550. if (prAdapter->prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  551. if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
  552. rRssi = PARAM_WHQL_RSSI_MAX_DBM;
  553. else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
  554. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  555. } else {
  556. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  557. }
  558. if (prCmdInfo->fgIsOid) {
  559. prGlueInfo = prAdapter->prGlueInfo;
  560. prRssi = (PARAM_RSSI *) prCmdInfo->pvInformationBuffer;
  561. kalMemCopy(prRssi, &rRssi, sizeof(PARAM_RSSI));
  562. u4QueryInfoLen = sizeof(PARAM_RSSI);
  563. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  564. }
  565. }
  566. /*----------------------------------------------------------------------------*/
  567. /*!
  568. * @brief This routine is in response of OID_GEN_LINK_SPEED query request
  569. *
  570. * @param prAdapter Pointer to the Adapter structure.
  571. * @param prCmdInfo Pointer to the pending command info
  572. * @param pucEventBuf
  573. *
  574. * @retval none
  575. */
  576. /*----------------------------------------------------------------------------*/
  577. VOID nicCmdEventQueryLinkSpeed(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  578. {
  579. P_EVENT_LINK_QUALITY prLinkQuality;
  580. P_GLUE_INFO_T prGlueInfo;
  581. UINT_32 u4QueryInfoLen;
  582. PUINT_32 pu4LinkSpeed;
  583. ASSERT(prAdapter);
  584. ASSERT(prCmdInfo);
  585. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  586. if (prCmdInfo->fgIsOid) {
  587. prGlueInfo = prAdapter->prGlueInfo;
  588. pu4LinkSpeed = (PUINT_32) (prCmdInfo->pvInformationBuffer);
  589. *pu4LinkSpeed = prLinkQuality->u2LinkSpeed * 5000;
  590. u4QueryInfoLen = sizeof(UINT_32);
  591. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  592. }
  593. }
  594. VOID nicCmdEventQueryStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  595. {
  596. P_PARAM_802_11_STATISTICS_STRUCT_T prStatistics;
  597. P_EVENT_STATISTICS prEventStatistics;
  598. P_GLUE_INFO_T prGlueInfo;
  599. UINT_32 u4QueryInfoLen;
  600. ASSERT(prAdapter);
  601. ASSERT(prCmdInfo);
  602. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  603. if (prCmdInfo->fgIsOid) {
  604. prGlueInfo = prAdapter->prGlueInfo;
  605. u4QueryInfoLen = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  606. prStatistics = (P_PARAM_802_11_STATISTICS_STRUCT_T) prCmdInfo->pvInformationBuffer;
  607. prStatistics->u4Length = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  608. prStatistics->rTransmittedFragmentCount = prEventStatistics->rTransmittedFragmentCount;
  609. prStatistics->rMulticastTransmittedFrameCount = prEventStatistics->rMulticastTransmittedFrameCount;
  610. prStatistics->rFailedCount = prEventStatistics->rFailedCount;
  611. prStatistics->rRetryCount = prEventStatistics->rRetryCount;
  612. prStatistics->rMultipleRetryCount = prEventStatistics->rMultipleRetryCount;
  613. prStatistics->rRTSSuccessCount = prEventStatistics->rRTSSuccessCount;
  614. prStatistics->rRTSFailureCount = prEventStatistics->rRTSFailureCount;
  615. prStatistics->rACKFailureCount = prEventStatistics->rACKFailureCount;
  616. prStatistics->rFrameDuplicateCount = prEventStatistics->rFrameDuplicateCount;
  617. prStatistics->rReceivedFragmentCount = prEventStatistics->rReceivedFragmentCount;
  618. prStatistics->rMulticastReceivedFrameCount = prEventStatistics->rMulticastReceivedFrameCount;
  619. prStatistics->rFCSErrorCount = prEventStatistics->rFCSErrorCount;
  620. prStatistics->rTKIPLocalMICFailures.QuadPart = 0;
  621. prStatistics->rTKIPICVErrors.QuadPart = 0;
  622. prStatistics->rTKIPCounterMeasuresInvoked.QuadPart = 0;
  623. prStatistics->rTKIPReplays.QuadPart = 0;
  624. prStatistics->rCCMPFormatErrors.QuadPart = 0;
  625. prStatistics->rCCMPReplays.QuadPart = 0;
  626. prStatistics->rCCMPDecryptErrors.QuadPart = 0;
  627. prStatistics->rFourWayHandshakeFailures.QuadPart = 0;
  628. prStatistics->rWEPUndecryptableCount.QuadPart = 0;
  629. prStatistics->rWEPICVErrorCount.QuadPart = 0;
  630. prStatistics->rDecryptSuccessCount.QuadPart = 0;
  631. prStatistics->rDecryptFailureCount.QuadPart = 0;
  632. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  633. }
  634. }
  635. VOID nicCmdEventEnterRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  636. {
  637. UINT_32 u4WHISR = 0, u4Value = 0;
  638. UINT_16 au2TxCount[16];
  639. ASSERT(prAdapter);
  640. ASSERT(prCmdInfo);
  641. /* [driver-land] */
  642. /* prAdapter->fgTestMode = TRUE; */
  643. if (prAdapter->fgTestMode)
  644. prAdapter->fgTestMode = FALSE;
  645. else
  646. prAdapter->fgTestMode = TRUE;
  647. /* 0. always indicate disconnection */
  648. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED)
  649. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  650. /* 1. Remove pending TX */
  651. nicTxRelease(prAdapter, TRUE);
  652. /* 1.1 clear pending Security / Management Frames */
  653. kalClearSecurityFrames(prAdapter->prGlueInfo);
  654. kalClearMgmtFrames(prAdapter->prGlueInfo);
  655. /* 1.2 clear pending TX packet queued in glue layer */
  656. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  657. /* 2. Reset driver-domain FSMs */
  658. nicUninitMGMT(prAdapter);
  659. nicResetSystemService(prAdapter);
  660. nicInitMGMT(prAdapter, NULL);
  661. /* 3. Disable Interrupt */
  662. HAL_INTR_DISABLE(prAdapter);
  663. /* 4. Block til firmware completed entering into RF test mode */
  664. kalMsleep(500);
  665. while (1) {
  666. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  667. if (u4Value & WCIR_WLAN_READY) {
  668. break;
  669. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  670. if (prCmdInfo->fgIsOid) {
  671. /* Update Set Information Length */
  672. kalOidComplete(prAdapter->prGlueInfo,
  673. prCmdInfo->fgSetQuery,
  674. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  675. }
  676. return;
  677. }
  678. kalMsleep(10);
  679. }
  680. /* 5. Clear Interrupt Status */
  681. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  682. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  683. HAL_READ_TX_RELEASED_COUNT(prAdapter, au2TxCount);
  684. /* 6. Reset TX Counter */
  685. nicTxResetResource(prAdapter);
  686. /* 7. Re-enable Interrupt */
  687. HAL_INTR_ENABLE(prAdapter);
  688. /* 8. completion indication */
  689. if (prCmdInfo->fgIsOid) {
  690. /* Update Set Information Length */
  691. kalOidComplete(prAdapter->prGlueInfo,
  692. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  693. }
  694. #if CFG_SUPPORT_NVRAM
  695. /* 9. load manufacture data */
  696. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE)
  697. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  698. else
  699. DBGLOG(REQ, WARN, "%s: load manufacture data fail\n", __func__);
  700. #endif
  701. }
  702. VOID nicCmdEventLeaveRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  703. {
  704. UINT_32 u4WHISR = 0, u4Value = 0;
  705. UINT_16 au2TxCount[16];
  706. ASSERT(prAdapter);
  707. ASSERT(prCmdInfo);
  708. /* 1. Disable Interrupt */
  709. HAL_INTR_DISABLE(prAdapter);
  710. /* 2. Block til firmware completed leaving from RF test mode */
  711. kalMsleep(500);
  712. while (1) {
  713. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  714. if (u4Value & WCIR_WLAN_READY) {
  715. break;
  716. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  717. if (prCmdInfo->fgIsOid) {
  718. /* Update Set Information Length */
  719. kalOidComplete(prAdapter->prGlueInfo,
  720. prCmdInfo->fgSetQuery,
  721. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  722. }
  723. return;
  724. }
  725. kalMsleep(10);
  726. }
  727. /* 3. Clear Interrupt Status */
  728. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  729. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  730. HAL_READ_TX_RELEASED_COUNT(prAdapter, au2TxCount);
  731. /* 4. Reset TX Counter */
  732. nicTxResetResource(prAdapter);
  733. /* 5. Re-enable Interrupt */
  734. HAL_INTR_ENABLE(prAdapter);
  735. /* 6. set driver-land variable */
  736. prAdapter->fgTestMode = FALSE;
  737. prAdapter->fgIcapMode = FALSE;
  738. /* 7. completion indication */
  739. if (prCmdInfo->fgIsOid) {
  740. /* Update Set Information Length */
  741. kalOidComplete(prAdapter->prGlueInfo,
  742. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  743. }
  744. /* 8. Indicate as disconnected */
  745. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
  746. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  747. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  748. }
  749. #if CFG_SUPPORT_NVRAM
  750. /* 9. load manufacture data */
  751. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE)
  752. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  753. else
  754. DBGLOG(REQ, WARN, "%s: load manufacture data fail\n", __func__);
  755. #endif
  756. /* 10. Override network address */
  757. wlanUpdateNetworkAddress(prAdapter);
  758. }
  759. VOID nicCmdEventQueryMcastAddr(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  760. {
  761. UINT_32 u4QueryInfoLen;
  762. P_GLUE_INFO_T prGlueInfo;
  763. P_EVENT_MAC_MCAST_ADDR prEventMacMcastAddr;
  764. ASSERT(prAdapter);
  765. ASSERT(prCmdInfo);
  766. ASSERT(pucEventBuf);
  767. /* 4 <2> Update information of OID */
  768. if (prCmdInfo->fgIsOid) {
  769. prGlueInfo = prAdapter->prGlueInfo;
  770. prEventMacMcastAddr = (P_EVENT_MAC_MCAST_ADDR) (pucEventBuf);
  771. u4QueryInfoLen = prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN;
  772. /* buffer length check */
  773. if (prCmdInfo->u4InformationBufferLength < u4QueryInfoLen) {
  774. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_BUFFER_TOO_SHORT);
  775. } else {
  776. kalMemCopy(prCmdInfo->pvInformationBuffer,
  777. prEventMacMcastAddr->arAddress,
  778. prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN);
  779. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  780. }
  781. }
  782. }
  783. VOID nicCmdEventQueryEepromRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  784. {
  785. UINT_32 u4QueryInfoLen;
  786. P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T prEepromRdInfo;
  787. P_GLUE_INFO_T prGlueInfo;
  788. P_EVENT_ACCESS_EEPROM prEventAccessEeprom;
  789. ASSERT(prAdapter);
  790. ASSERT(prCmdInfo);
  791. ASSERT(pucEventBuf);
  792. /* 4 <2> Update information of OID */
  793. if (prCmdInfo->fgIsOid) {
  794. prGlueInfo = prAdapter->prGlueInfo;
  795. prEventAccessEeprom = (P_EVENT_ACCESS_EEPROM) (pucEventBuf);
  796. u4QueryInfoLen = sizeof(PARAM_CUSTOM_EEPROM_RW_STRUCT_T);
  797. prEepromRdInfo = (P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T) prCmdInfo->pvInformationBuffer;
  798. prEepromRdInfo->ucEepromIndex = (UINT_8) (prEventAccessEeprom->u2Offset);
  799. prEepromRdInfo->u2EepromData = prEventAccessEeprom->u2Data;
  800. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  801. }
  802. return;
  803. }
  804. VOID nicCmdEventSetMediaStreamMode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  805. {
  806. PARAM_MEDIA_STREAMING_INDICATION rParamMediaStreamIndication;
  807. ASSERT(prAdapter);
  808. ASSERT(prCmdInfo);
  809. if (prCmdInfo->fgIsOid) {
  810. /* Update Set Information Length */
  811. kalOidComplete(prAdapter->prGlueInfo,
  812. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  813. }
  814. rParamMediaStreamIndication.rStatus.eStatusType = ENUM_STATUS_TYPE_MEDIA_STREAM_MODE;
  815. rParamMediaStreamIndication.eMediaStreamMode =
  816. prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode == 0 ? ENUM_MEDIA_STREAM_OFF : ENUM_MEDIA_STREAM_ON;
  817. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  818. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  819. (PVOID)&rParamMediaStreamIndication, sizeof(PARAM_MEDIA_STREAMING_INDICATION));
  820. }
  821. VOID nicCmdEventSetStopSchedScan(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  822. {
  823. /*
  824. DBGLOG(SCN, INFO, "--->nicCmdEventSetStopSchedScan\n" ));
  825. */
  826. ASSERT(prAdapter);
  827. ASSERT(prCmdInfo);
  828. /*
  829. DBGLOG(SCN, INFO, "<--kalSchedScanStopped\n" );
  830. */
  831. if (prCmdInfo->fgIsOid) {
  832. /* Update Set Information Length */
  833. kalOidComplete(prAdapter->prGlueInfo,
  834. prCmdInfo->fgSetQuery, prCmdInfo->u4InformationBufferLength, WLAN_STATUS_SUCCESS);
  835. }
  836. DBGLOG(SCN, INFO, "nicCmdEventSetStopSchedScan OID done, release lock and send event to uplayer\n");
  837. /*Due to dead lock issue, need to release the IO control before calling kernel APIs */
  838. kalSchedScanStopped(prAdapter->prGlueInfo);
  839. }
  840. /* Statistics responder */
  841. VOID nicCmdEventQueryXmitOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  842. {
  843. P_EVENT_STATISTICS prEventStatistics;
  844. P_GLUE_INFO_T prGlueInfo;
  845. UINT_32 u4QueryInfoLen;
  846. PUINT_32 pu4Data;
  847. PUINT_64 pu8Data;
  848. ASSERT(prAdapter);
  849. ASSERT(prCmdInfo);
  850. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  851. if (prCmdInfo->fgIsOid) {
  852. prGlueInfo = prAdapter->prGlueInfo;
  853. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  854. u4QueryInfoLen = sizeof(UINT_32);
  855. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  856. *pu4Data = (UINT_32) prEventStatistics->rTransmittedFragmentCount.QuadPart;
  857. } else {
  858. u4QueryInfoLen = sizeof(UINT_64);
  859. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  860. *pu8Data = prEventStatistics->rTransmittedFragmentCount.QuadPart;
  861. }
  862. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  863. }
  864. }
  865. VOID nicCmdEventQueryRecvOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  866. {
  867. P_EVENT_STATISTICS prEventStatistics;
  868. P_GLUE_INFO_T prGlueInfo;
  869. UINT_32 u4QueryInfoLen;
  870. PUINT_32 pu4Data;
  871. PUINT_64 pu8Data;
  872. ASSERT(prAdapter);
  873. ASSERT(prCmdInfo);
  874. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  875. if (prCmdInfo->fgIsOid) {
  876. prGlueInfo = prAdapter->prGlueInfo;
  877. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  878. u4QueryInfoLen = sizeof(UINT_32);
  879. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  880. *pu4Data = (UINT_32) prEventStatistics->rReceivedFragmentCount.QuadPart;
  881. } else {
  882. u4QueryInfoLen = sizeof(UINT_64);
  883. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  884. *pu8Data = prEventStatistics->rReceivedFragmentCount.QuadPart;
  885. }
  886. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  887. }
  888. }
  889. VOID nicCmdEventQueryXmitError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  890. {
  891. P_EVENT_STATISTICS prEventStatistics;
  892. P_GLUE_INFO_T prGlueInfo;
  893. UINT_32 u4QueryInfoLen;
  894. PUINT_32 pu4Data;
  895. PUINT_64 pu8Data;
  896. ASSERT(prAdapter);
  897. ASSERT(prCmdInfo);
  898. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  899. if (prCmdInfo->fgIsOid) {
  900. prGlueInfo = prAdapter->prGlueInfo;
  901. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  902. u4QueryInfoLen = sizeof(UINT_32);
  903. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  904. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  905. } else {
  906. u4QueryInfoLen = sizeof(UINT_64);
  907. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  908. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  909. }
  910. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  911. }
  912. }
  913. VOID nicCmdEventQueryRecvError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  914. {
  915. P_EVENT_STATISTICS prEventStatistics;
  916. P_GLUE_INFO_T prGlueInfo;
  917. UINT_32 u4QueryInfoLen;
  918. PUINT_32 pu4Data;
  919. PUINT_64 pu8Data;
  920. ASSERT(prAdapter);
  921. ASSERT(prCmdInfo);
  922. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  923. if (prCmdInfo->fgIsOid) {
  924. prGlueInfo = prAdapter->prGlueInfo;
  925. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  926. u4QueryInfoLen = sizeof(UINT_32);
  927. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  928. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  929. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  930. } else {
  931. u4QueryInfoLen = sizeof(UINT_64);
  932. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  933. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  934. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  935. }
  936. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  937. }
  938. }
  939. VOID nicCmdEventQueryRecvNoBuffer(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  940. {
  941. P_GLUE_INFO_T prGlueInfo;
  942. UINT_32 u4QueryInfoLen;
  943. PUINT_32 pu4Data;
  944. PUINT_64 pu8Data;
  945. ASSERT(prAdapter);
  946. ASSERT(prCmdInfo);
  947. if (prCmdInfo->fgIsOid) {
  948. prGlueInfo = prAdapter->prGlueInfo;
  949. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  950. u4QueryInfoLen = sizeof(UINT_32);
  951. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  952. *pu4Data = 0; /* @FIXME? */
  953. } else {
  954. u4QueryInfoLen = sizeof(UINT_64);
  955. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  956. *pu8Data = 0; /* @FIXME? */
  957. }
  958. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  959. }
  960. }
  961. VOID nicCmdEventQueryRecvCrcError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  962. {
  963. P_EVENT_STATISTICS prEventStatistics;
  964. P_GLUE_INFO_T prGlueInfo;
  965. UINT_32 u4QueryInfoLen;
  966. PUINT_32 pu4Data;
  967. PUINT_64 pu8Data;
  968. ASSERT(prAdapter);
  969. ASSERT(prCmdInfo);
  970. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  971. if (prCmdInfo->fgIsOid) {
  972. prGlueInfo = prAdapter->prGlueInfo;
  973. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  974. u4QueryInfoLen = sizeof(UINT_32);
  975. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  976. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  977. } else {
  978. u4QueryInfoLen = sizeof(UINT_64);
  979. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  980. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  981. }
  982. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  983. }
  984. }
  985. VOID nicCmdEventQueryRecvErrorAlignment(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  986. {
  987. P_GLUE_INFO_T prGlueInfo;
  988. UINT_32 u4QueryInfoLen;
  989. PUINT_32 pu4Data;
  990. PUINT_64 pu8Data;
  991. ASSERT(prAdapter);
  992. ASSERT(prCmdInfo);
  993. if (prCmdInfo->fgIsOid) {
  994. prGlueInfo = prAdapter->prGlueInfo;
  995. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  996. u4QueryInfoLen = sizeof(UINT_32);
  997. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  998. *pu4Data = (UINT_32) 0; /* @FIXME */
  999. } else {
  1000. u4QueryInfoLen = sizeof(UINT_64);
  1001. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1002. *pu8Data = 0; /* @FIXME */
  1003. }
  1004. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1005. }
  1006. }
  1007. VOID nicCmdEventQueryXmitOneCollision(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1008. {
  1009. P_EVENT_STATISTICS prEventStatistics;
  1010. P_GLUE_INFO_T prGlueInfo;
  1011. UINT_32 u4QueryInfoLen;
  1012. PUINT_32 pu4Data;
  1013. PUINT_64 pu8Data;
  1014. ASSERT(prAdapter);
  1015. ASSERT(prCmdInfo);
  1016. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1017. if (prCmdInfo->fgIsOid) {
  1018. prGlueInfo = prAdapter->prGlueInfo;
  1019. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1020. u4QueryInfoLen = sizeof(UINT_32);
  1021. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1022. *pu4Data =
  1023. (UINT_32) (prEventStatistics->rMultipleRetryCount.QuadPart -
  1024. prEventStatistics->rRetryCount.QuadPart);
  1025. } else {
  1026. u4QueryInfoLen = sizeof(UINT_64);
  1027. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1028. *pu8Data =
  1029. (UINT_64) (prEventStatistics->rMultipleRetryCount.QuadPart -
  1030. prEventStatistics->rRetryCount.QuadPart);
  1031. }
  1032. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1033. }
  1034. }
  1035. VOID nicCmdEventQueryXmitMoreCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1036. {
  1037. P_EVENT_STATISTICS prEventStatistics;
  1038. P_GLUE_INFO_T prGlueInfo;
  1039. UINT_32 u4QueryInfoLen;
  1040. PUINT_32 pu4Data;
  1041. PUINT_64 pu8Data;
  1042. ASSERT(prAdapter);
  1043. ASSERT(prCmdInfo);
  1044. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1045. if (prCmdInfo->fgIsOid) {
  1046. prGlueInfo = prAdapter->prGlueInfo;
  1047. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1048. u4QueryInfoLen = sizeof(UINT_32);
  1049. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1050. *pu4Data = (UINT_32) prEventStatistics->rMultipleRetryCount.QuadPart;
  1051. } else {
  1052. u4QueryInfoLen = sizeof(UINT_64);
  1053. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1054. *pu8Data = (UINT_64) prEventStatistics->rMultipleRetryCount.QuadPart;
  1055. }
  1056. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1057. }
  1058. }
  1059. VOID nicCmdEventQueryXmitMaxCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1060. {
  1061. P_EVENT_STATISTICS prEventStatistics;
  1062. P_GLUE_INFO_T prGlueInfo;
  1063. UINT_32 u4QueryInfoLen;
  1064. PUINT_32 pu4Data;
  1065. PUINT_64 pu8Data;
  1066. ASSERT(prAdapter);
  1067. ASSERT(prCmdInfo);
  1068. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  1069. if (prCmdInfo->fgIsOid) {
  1070. prGlueInfo = prAdapter->prGlueInfo;
  1071. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  1072. u4QueryInfoLen = sizeof(UINT_32);
  1073. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  1074. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  1075. } else {
  1076. u4QueryInfoLen = sizeof(UINT_64);
  1077. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  1078. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  1079. }
  1080. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1081. }
  1082. }
  1083. /*----------------------------------------------------------------------------*/
  1084. /*!
  1085. * @brief This function is called when command by OID/ioctl has been timeout
  1086. *
  1087. * @param prAdapter Pointer to the Adapter structure.
  1088. * @param prCmdInfo Pointer to the command information
  1089. *
  1090. * @return TRUE
  1091. * FALSE
  1092. */
  1093. /*----------------------------------------------------------------------------*/
  1094. VOID nicOidCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1095. {
  1096. ASSERT(prAdapter);
  1097. if (prCmdInfo->fgIsOid)
  1098. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1099. }
  1100. /*----------------------------------------------------------------------------*/
  1101. /*!
  1102. * @brief This function is a generic command timeout handler
  1103. *
  1104. * @param pfnOidHandler Pointer to the OID handler
  1105. *
  1106. * @return none
  1107. */
  1108. /*----------------------------------------------------------------------------*/
  1109. VOID nicCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1110. {
  1111. ASSERT(prAdapter);
  1112. }
  1113. /*----------------------------------------------------------------------------*/
  1114. /*!
  1115. * @brief This function is called when command for entering RF test has
  1116. * failed sending due to timeout (highly possibly by firmware crash)
  1117. *
  1118. * @param prAdapter Pointer to the Adapter structure.
  1119. * @param prCmdInfo Pointer to the command information
  1120. *
  1121. * @return none
  1122. *
  1123. */
  1124. /*----------------------------------------------------------------------------*/
  1125. VOID nicOidCmdEnterRFTestTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1126. {
  1127. ASSERT(prAdapter);
  1128. /* 1. Remove pending TX frames */
  1129. nicTxRelease(prAdapter, TRUE);
  1130. /* 1.1 clear pending Security / Management Frames */
  1131. kalClearSecurityFrames(prAdapter->prGlueInfo);
  1132. kalClearMgmtFrames(prAdapter->prGlueInfo);
  1133. /* 1.2 clear pending TX packet queued in glue layer */
  1134. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  1135. /* 2. indicate for OID failure */
  1136. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1137. }
  1138. /*----------------------------------------------------------------------------*/
  1139. /*!
  1140. * @brief This function is called to handle dump burst event
  1141. *
  1142. * @param prAdapter Pointer to the Adapter structure.
  1143. * @param prCmdInfo Pointer to the command information
  1144. * @param pucEventBuf Pointer to event buffer
  1145. *
  1146. * @return none
  1147. *
  1148. */
  1149. /*----------------------------------------------------------------------------*/
  1150. VOID nicEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucEventBuf)
  1151. {
  1152. static UINT_8 aucPath[256];
  1153. static UINT_8 aucPath_done[300];
  1154. static UINT_32 u4CurTimeTick;
  1155. P_EVENT_DUMP_MEM_T prEventDumpMem;
  1156. ASSERT(prAdapter);
  1157. ASSERT(pucEventBuf);
  1158. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1159. prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
  1160. if (kalCheckPath(aucPath) == -1) {
  1161. kalMemSet(aucPath, 0x00, 256);
  1162. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1163. }
  1164. if (prEventDumpMem->ucFragNum == 1) {
  1165. /* Store memory dump into sdcard,
  1166. * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
  1167. */
  1168. u4CurTimeTick = kalGetTimeTick();
  1169. #if defined(LINUX)
  1170. /*if blbist mkdir undre /data/blbist, the dump files wouls put on it */
  1171. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1172. if (kalCheckPath(aucPath) == -1) {
  1173. kalMemSet(aucPath, 0x00, 256);
  1174. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1175. }
  1176. #else
  1177. kal_sprintf_ddk(aucPath, sizeof(aucPath),
  1178. u4CurTimeTick,
  1179. prEventDumpMem->u4Address, prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1180. #endif
  1181. kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1182. } else {
  1183. /* Append current memory dump to the hex file */
  1184. kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1185. }
  1186. DBGLOG(INIT, INFO,
  1187. ": ==> (u4RemainLength = %x, u4Address=%x )\n", prEventDumpMem->u4RemainLength,
  1188. prEventDumpMem->u4Address);
  1189. if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
  1190. /* The request is finished or firmware response a error */
  1191. /* Reply time tick to iwpriv */
  1192. g_bIcapEnable = FALSE;
  1193. g_bCaptureDone = TRUE;
  1194. sprintf(aucPath_done, "/data/blbist/file_dump_done.txt");
  1195. if (kalCheckPath(aucPath_done) == -1) {
  1196. kalMemSet(aucPath_done, 0x00, 256);
  1197. sprintf(aucPath_done, "/data/file_dump_done.txt");
  1198. }
  1199. DBGLOG(INIT, INFO, ": ==> gen done_file\n");
  1200. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1201. g_u2DumpIndex++;
  1202. }
  1203. }
  1204. /*----------------------------------------------------------------------------*/
  1205. /*!
  1206. * @brief This function is called when command for memory dump has
  1207. * replied a event.
  1208. *
  1209. * @param prAdapter Pointer to the Adapter structure.
  1210. * @param prCmdInfo Pointer to the command information
  1211. * @param pucEventBuf Pointer to event buffer
  1212. *
  1213. * @return none
  1214. *
  1215. */
  1216. /*----------------------------------------------------------------------------*/
  1217. VOID nicCmdEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1218. {
  1219. static UINT_8 aucPath[256];
  1220. static UINT_8 aucPath_done[300];
  1221. static UINT_32 u4CurTimeTick;
  1222. P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T prMemDumpInfo;
  1223. P_GLUE_INFO_T prGlueInfo;
  1224. P_EVENT_DUMP_MEM_T prEventDumpMem;
  1225. UINT_32 u4QueryInfoLen;
  1226. ASSERT(prAdapter);
  1227. ASSERT(prCmdInfo);
  1228. ASSERT(pucEventBuf);
  1229. /* 4 <2> Update information of OID */
  1230. if (1) {
  1231. prGlueInfo = prAdapter->prGlueInfo;
  1232. prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
  1233. u4QueryInfoLen = sizeof(P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T);
  1234. prMemDumpInfo = (P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T) prCmdInfo->pvInformationBuffer;
  1235. prMemDumpInfo->u4Address = prEventDumpMem->u4Address;
  1236. prMemDumpInfo->u4Length = prEventDumpMem->u4Length;
  1237. prMemDumpInfo->u4RemainLength = prEventDumpMem->u4RemainLength;
  1238. prMemDumpInfo->ucFragNum = prEventDumpMem->ucFragNum;
  1239. #if 0
  1240. do {
  1241. UINT_32 i = 0;
  1242. DBGLOG(REQ, TRACE, "Rx dump address 0x%X, Length %d, FragNum %d, remain %d\n",
  1243. prEventDumpMem->u4Address,
  1244. prEventDumpMem->u4Length, prEventDumpMem->ucFragNum, prEventDumpMem->u4RemainLength);
  1245. #if 0
  1246. for (i = 0; i < prEventDumpMem->u4Length; i++) {
  1247. DBGLOG(REQ, TRACE, "%02X ", prEventDumpMem->aucBuffer[i]);
  1248. if (i % 32 == 31)
  1249. DBGLOG(REQ, TRACE, "\n");
  1250. }
  1251. #endif
  1252. } while (FALSE);
  1253. #endif
  1254. if (prEventDumpMem->ucFragNum == 1) {
  1255. /* Store memory dump into sdcard,
  1256. * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
  1257. */
  1258. u4CurTimeTick = kalGetTimeTick();
  1259. #if defined(LINUX)
  1260. #if 0
  1261. sprintf(aucPath, "/sdcard/dump_%ld_0x%08lX_%ld.hex",
  1262. u4CurTimeTick,
  1263. prEventDumpMem->u4Address, prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1264. #else
  1265. /*if blbist mkdir undre /data/blbist, the dump files wouls put on it */
  1266. sprintf(aucPath, "/data/blbist/dump_%05d.hex", g_u2DumpIndex);
  1267. if (kalCheckPath(aucPath) == -1) {
  1268. kalMemSet(aucPath, 0x00, 256);
  1269. sprintf(aucPath, "/data/dump_%05d.hex", g_u2DumpIndex);
  1270. }
  1271. #endif
  1272. #else
  1273. kal_sprintf_ddk(aucPath, sizeof(aucPath),
  1274. u4CurTimeTick,
  1275. prEventDumpMem->u4Address,
  1276. prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1277. /* strcpy(aucPath, "dump.hex"); */
  1278. #endif
  1279. kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1280. } else {
  1281. /* Append current memory dump to the hex file */
  1282. kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1283. }
  1284. if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
  1285. /* The request is finished or firmware response a error */
  1286. /* Reply time tick to iwpriv */
  1287. if (prCmdInfo->fgIsOid) {
  1288. /* the oid would be complete only in oid-trigger mode,
  1289. * that is no need to if the event-trigger */
  1290. if (g_bIcapEnable == FALSE) {
  1291. *((PUINT_32) prCmdInfo->pvInformationBuffer) = u4CurTimeTick;
  1292. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery,
  1293. u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1294. }
  1295. }
  1296. g_bIcapEnable = FALSE;
  1297. g_bCaptureDone = TRUE;
  1298. #if defined(LINUX)
  1299. sprintf(aucPath_done, "/data/blbist/file_dump_done.txt");
  1300. if (kalCheckPath(aucPath_done) == -1) {
  1301. kalMemSet(aucPath_done, 0x00, 256);
  1302. sprintf(aucPath_done, "/data/file_dump_done.txt");
  1303. }
  1304. DBGLOG(INIT, INFO, ": ==> gen done_file\n");
  1305. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1306. g_u2DumpIndex++;
  1307. #else
  1308. kal_sprintf_done_ddk(aucPath_done, sizeof(aucPath_done));
  1309. kalWriteToFile(aucPath_done, FALSE, aucPath_done, sizeof(aucPath_done));
  1310. #endif
  1311. } else {
  1312. #if defined(LINUX)
  1313. #else /* 2013/05/26 fw would try to send the buffer successfully */
  1314. /* The memory dump request is not finished, Send next command */
  1315. wlanSendMemDumpCmd(prAdapter,
  1316. prCmdInfo->pvInformationBuffer, prCmdInfo->u4InformationBufferLength);
  1317. #endif
  1318. }
  1319. }
  1320. return;
  1321. }
  1322. #if CFG_SUPPORT_BATCH_SCAN
  1323. /*----------------------------------------------------------------------------*/
  1324. /*!
  1325. * @brief This function is called when event for SUPPORT_BATCH_SCAN
  1326. *
  1327. * @param prAdapter Pointer to the Adapter structure.
  1328. * @param prCmdInfo Pointer to the command information
  1329. * @param pucEventBuf Pointer to the event buffer
  1330. *
  1331. * @return none
  1332. *
  1333. */
  1334. /*----------------------------------------------------------------------------*/
  1335. VOID nicCmdEventBatchScanResult(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1336. {
  1337. UINT_32 u4QueryInfoLen;
  1338. P_EVENT_BATCH_RESULT_T prEventBatchResult;
  1339. P_GLUE_INFO_T prGlueInfo;
  1340. DBGLOG(SCN, TRACE, "nicCmdEventBatchScanResult");
  1341. ASSERT(prAdapter);
  1342. ASSERT(prCmdInfo);
  1343. ASSERT(pucEventBuf);
  1344. /* 4 <2> Update information of OID */
  1345. if (prCmdInfo->fgIsOid) {
  1346. prGlueInfo = prAdapter->prGlueInfo;
  1347. prEventBatchResult = (P_EVENT_BATCH_RESULT_T) pucEventBuf;
  1348. u4QueryInfoLen = sizeof(EVENT_BATCH_RESULT_T);
  1349. kalMemCopy(prCmdInfo->pvInformationBuffer, prEventBatchResult, sizeof(EVENT_BATCH_RESULT_T));
  1350. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1351. }
  1352. }
  1353. #endif
  1354. #if CFG_SUPPORT_BUILD_DATE_CODE
  1355. /*----------------------------------------------------------------------------*/
  1356. /*!
  1357. * @brief This function is called when event for build date code information
  1358. * has been retrieved
  1359. *
  1360. * @param prAdapter Pointer to the Adapter structure.
  1361. * @param prCmdInfo Pointer to the command information
  1362. * @param pucEventBuf Pointer to the event buffer
  1363. *
  1364. * @return none
  1365. *
  1366. */
  1367. /*----------------------------------------------------------------------------*/
  1368. VOID nicCmdEventBuildDateCode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1369. {
  1370. UINT_32 u4QueryInfoLen;
  1371. P_EVENT_BUILD_DATE_CODE prEvent;
  1372. P_GLUE_INFO_T prGlueInfo;
  1373. ASSERT(prAdapter);
  1374. ASSERT(prCmdInfo);
  1375. ASSERT(pucEventBuf);
  1376. /* 4 <2> Update information of OID */
  1377. if (prCmdInfo->fgIsOid) {
  1378. prGlueInfo = prAdapter->prGlueInfo;
  1379. prEvent = (P_EVENT_BUILD_DATE_CODE) pucEventBuf;
  1380. u4QueryInfoLen = sizeof(UINT_8) * 16;
  1381. kalMemCopy(prCmdInfo->pvInformationBuffer, prEvent->aucDateCode, sizeof(UINT_8) * 16);
  1382. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1383. }
  1384. }
  1385. #endif
  1386. /*----------------------------------------------------------------------------*/
  1387. /*!
  1388. * @brief This function is called when event for query STA link status
  1389. * has been retrieved
  1390. *
  1391. * @param prAdapter Pointer to the Adapter structure.
  1392. * @param prCmdInfo Pointer to the command information
  1393. * @param pucEventBuf Pointer to the event buffer
  1394. *
  1395. * @return none
  1396. *
  1397. */
  1398. /*----------------------------------------------------------------------------*/
  1399. VOID nicCmdEventQueryStaStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1400. {
  1401. UINT_32 u4QueryInfoLen;
  1402. P_EVENT_STA_STATISTICS_T prEvent;
  1403. P_GLUE_INFO_T prGlueInfo;
  1404. P_PARAM_GET_STA_STATISTICS prStaStatistics;
  1405. ENUM_WMM_ACI_T eAci;
  1406. P_STA_RECORD_T prStaRec;
  1407. ASSERT(prAdapter);
  1408. ASSERT(prCmdInfo);
  1409. ASSERT(pucEventBuf);
  1410. if (prCmdInfo->fgIsOid) {
  1411. prGlueInfo = prAdapter->prGlueInfo;
  1412. prEvent = (P_EVENT_STA_STATISTICS_T) pucEventBuf;
  1413. prStaStatistics = (P_PARAM_GET_STA_STATISTICS) prCmdInfo->pvInformationBuffer;
  1414. u4QueryInfoLen = sizeof(PARAM_GET_STA_STA_STATISTICS);
  1415. /* Statistics from FW is valid */
  1416. if (prEvent->u4Flags & BIT(0)) {
  1417. prStaStatistics->ucPer = prEvent->ucPer;
  1418. prStaStatistics->ucRcpi = prEvent->ucRcpi;
  1419. prStaStatistics->u4PhyMode = prEvent->u4PhyMode;
  1420. prStaStatistics->u2LinkSpeed = prEvent->u2LinkSpeed;
  1421. prStaStatistics->u4TxFailCount = prEvent->u4TxFailCount;
  1422. prStaStatistics->u4TxLifeTimeoutCount = prEvent->u4TxLifeTimeoutCount;
  1423. prStaRec = cnmGetStaRecByIndex(prAdapter, prEvent->ucStaRecIdx);
  1424. if (prStaRec) {
  1425. /*link layer statistics */
  1426. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  1427. prStaStatistics->arLinkStatistics[eAci].u4TxFailMsdu =
  1428. prEvent->arLinkStatistics[eAci].u4TxFailMsdu;
  1429. prStaStatistics->arLinkStatistics[eAci].u4TxRetryMsdu =
  1430. prEvent->arLinkStatistics[eAci].u4TxRetryMsdu;
  1431. /*for dump bss statistics */
  1432. prStaRec->arLinkStatistics[eAci].u4TxFailMsdu =
  1433. prEvent->arLinkStatistics[eAci].u4TxFailMsdu;
  1434. prStaRec->arLinkStatistics[eAci].u4TxRetryMsdu =
  1435. prEvent->arLinkStatistics[eAci].u4TxRetryMsdu;
  1436. }
  1437. }
  1438. if (prEvent->u4TxCount) {
  1439. UINT_32 u4TxDoneAirTimeMs = USEC_TO_MSEC(prEvent->u4TxDoneAirTime * 32);
  1440. prStaStatistics->u4TxAverageAirTime = (u4TxDoneAirTimeMs / prEvent->u4TxCount);
  1441. } else {
  1442. prStaStatistics->u4TxAverageAirTime = 0;
  1443. }
  1444. }
  1445. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1446. }
  1447. }
  1448. #if CFG_AUTO_CHANNEL_SEL_SUPPORT
  1449. /* 4 Auto Channel Selection */
  1450. /*----------------------------------------------------------------------------*/
  1451. /*!
  1452. * @brief This function is called when event for query STA link status
  1453. * has been retrieved
  1454. *
  1455. * @param prAdapter Pointer to the Adapter structure.
  1456. * @param prCmdInfo Pointer to the command information
  1457. * @param pucEventBuf Pointer to the event buffer
  1458. *
  1459. * @return none
  1460. *
  1461. */
  1462. /*----------------------------------------------------------------------------*/
  1463. VOID nicCmdEventQueryChannelLoad(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1464. {
  1465. UINT_32 u4QueryInfoLen;
  1466. P_EVENT_CHN_LOAD_T prEvent;
  1467. P_GLUE_INFO_T prGlueInfo;
  1468. P_PARAM_GET_CHN_LOAD prChnLoad;
  1469. ASSERT(prAdapter);
  1470. ASSERT(prCmdInfo);
  1471. ASSERT(pucEventBuf);
  1472. if (prCmdInfo->fgIsOid) {
  1473. prGlueInfo = prAdapter->prGlueInfo;
  1474. prEvent = (P_EVENT_CHN_LOAD_T) pucEventBuf; /* 4 The firmware responsed data */
  1475. /* 4 Fill the firmware data in and send it back to host */
  1476. prChnLoad = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1477. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1478. /* Statistics from FW is valid */
  1479. if (prEvent->u4Flags & BIT(0)) {
  1480. prChnLoad->rEachChnLoad[0].ucChannel = prEvent->ucChannel;
  1481. prChnLoad->rEachChnLoad[0].u2ChannelLoad = prEvent->u2ChannelLoad;
  1482. DBGLOG(P2P, INFO, "CHN[%d]=%d\n", prEvent->ucChannel, prEvent->u2ChannelLoad);
  1483. }
  1484. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1485. }
  1486. }
  1487. VOID nicCmdEventQueryLTESafeChn(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1488. {
  1489. UINT_32 u4QueryInfoLen;
  1490. P_EVENT_LTE_MODE_T prEvent;
  1491. P_GLUE_INFO_T prGlueInfo;
  1492. P_PARAM_GET_CHN_LOAD prLteSafeChnInfo;
  1493. ASSERT(prAdapter);
  1494. ASSERT(prCmdInfo);
  1495. ASSERT(pucEventBuf);
  1496. if (prCmdInfo->fgIsOid) {
  1497. prGlueInfo = prAdapter->prGlueInfo;
  1498. prEvent = (P_EVENT_LTE_MODE_T) pucEventBuf; /* 4 The firmware responsed data */
  1499. prLteSafeChnInfo = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1500. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1501. /* Statistics from FW is valid */
  1502. if (prEvent->u4Flags & BIT(0)) {
  1503. /* prLteSafeChnInfo->rLteSafeChnList.ucChannelHigh= prEvent->rLteSafeChn.ucChannelHigh; */
  1504. /* prLteSafeChnInfo->rLteSafeChnList.ucChannelLow= prEvent->rLteSafeChn.ucChannelLow; */
  1505. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[0] =
  1506. prEvent->rLteSafeChn.u4SafeChannelBitmask[0];
  1507. if (prEvent->ucVersion != 0) {
  1508. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[1] =
  1509. prEvent->rLteSafeChn.u4SafeChannelBitmask[1];
  1510. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[2] =
  1511. prEvent->rLteSafeChn.u4SafeChannelBitmask[2];
  1512. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[3] =
  1513. prEvent->rLteSafeChn.u4SafeChannelBitmask[3];
  1514. }
  1515. DBGLOG(P2P, INFO,
  1516. "[Query-info Auto Channel]LTE safe channels 0x%08x\n",
  1517. prLteSafeChnInfo->rLteSafeChnList.u4SafeChannelBitmask[0]);
  1518. }
  1519. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1520. }
  1521. }
  1522. #endif