nic_cmd_event.c 52 KB

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