nic_cmd_event.c 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638
  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. /*Memory copy length is depended on upper-layer*/
  424. kalMemCopy(prQueryBuffer, prTestStatus, prCmdInfo->u4InformationBufferLength);
  425. u4QueryInfoLen = sizeof(EVENT_TEST_STATUS);
  426. /* Update Query Information Length */
  427. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  428. }
  429. }
  430. VOID nicCmdEventQueryLinkQuality(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  431. {
  432. PARAM_RSSI rRssi, *prRssi;
  433. P_EVENT_LINK_QUALITY prLinkQuality;
  434. P_GLUE_INFO_T prGlueInfo;
  435. UINT_32 u4QueryInfoLen;
  436. ASSERT(prAdapter);
  437. ASSERT(prCmdInfo);
  438. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  439. rRssi = (PARAM_RSSI) prLinkQuality->cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
  440. DBGLOG(NIC, INFO, "<rxm> %s: rRssi = %d\n", __func__, rRssi);
  441. if (prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  442. if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
  443. rRssi = PARAM_WHQL_RSSI_MAX_DBM;
  444. else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
  445. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  446. } else {
  447. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  448. }
  449. if (prCmdInfo->fgIsOid) {
  450. prGlueInfo = prAdapter->prGlueInfo;
  451. prRssi = (PARAM_RSSI *) prCmdInfo->pvInformationBuffer;
  452. kalMemCopy(prRssi, &rRssi, sizeof(PARAM_RSSI));
  453. u4QueryInfoLen = sizeof(PARAM_RSSI);
  454. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  455. }
  456. }
  457. /*----------------------------------------------------------------------------*/
  458. /*!
  459. * @brief This routine is in response of OID_GEN_LINK_SPEED query request
  460. *
  461. * @param prAdapter Pointer to the Adapter structure.
  462. * @param prCmdInfo Pointer to the pending command info
  463. * @param pucEventBuf
  464. *
  465. * @retval none
  466. */
  467. /*----------------------------------------------------------------------------*/
  468. VOID nicCmdEventQueryLinkSpeed(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  469. {
  470. P_EVENT_LINK_QUALITY prLinkQuality;
  471. P_GLUE_INFO_T prGlueInfo;
  472. UINT_32 u4QueryInfoLen;
  473. PUINT_32 pu4LinkSpeed;
  474. ASSERT(prAdapter);
  475. ASSERT(prCmdInfo);
  476. prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
  477. if (prCmdInfo->fgIsOid) {
  478. prGlueInfo = prAdapter->prGlueInfo;
  479. pu4LinkSpeed = (PUINT_32) (prCmdInfo->pvInformationBuffer);
  480. *pu4LinkSpeed = prLinkQuality->u2LinkSpeed * 5000;
  481. u4QueryInfoLen = sizeof(UINT_32);
  482. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  483. }
  484. }
  485. VOID nicCmdEventQueryStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  486. {
  487. P_PARAM_802_11_STATISTICS_STRUCT_T prStatistics;
  488. P_EVENT_STATISTICS prEventStatistics;
  489. P_GLUE_INFO_T prGlueInfo;
  490. UINT_32 u4QueryInfoLen;
  491. ASSERT(prAdapter);
  492. ASSERT(prCmdInfo);
  493. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  494. if (prCmdInfo->fgIsOid) {
  495. prGlueInfo = prAdapter->prGlueInfo;
  496. u4QueryInfoLen = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  497. prStatistics = (P_PARAM_802_11_STATISTICS_STRUCT_T) prCmdInfo->pvInformationBuffer;
  498. prStatistics->u4Length = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
  499. prStatistics->rTransmittedFragmentCount = prEventStatistics->rTransmittedFragmentCount;
  500. prStatistics->rMulticastTransmittedFrameCount = prEventStatistics->rMulticastTransmittedFrameCount;
  501. prStatistics->rFailedCount = prEventStatistics->rFailedCount;
  502. prStatistics->rRetryCount = prEventStatistics->rRetryCount;
  503. prStatistics->rMultipleRetryCount = prEventStatistics->rMultipleRetryCount;
  504. prStatistics->rRTSSuccessCount = prEventStatistics->rRTSSuccessCount;
  505. prStatistics->rRTSFailureCount = prEventStatistics->rRTSFailureCount;
  506. prStatistics->rACKFailureCount = prEventStatistics->rACKFailureCount;
  507. prStatistics->rFrameDuplicateCount = prEventStatistics->rFrameDuplicateCount;
  508. prStatistics->rReceivedFragmentCount = prEventStatistics->rReceivedFragmentCount;
  509. prStatistics->rMulticastReceivedFrameCount = prEventStatistics->rMulticastReceivedFrameCount;
  510. prStatistics->rFCSErrorCount = prEventStatistics->rFCSErrorCount;
  511. prStatistics->rTKIPLocalMICFailures.QuadPart = 0;
  512. prStatistics->rTKIPICVErrors.QuadPart = 0;
  513. prStatistics->rTKIPCounterMeasuresInvoked.QuadPart = 0;
  514. prStatistics->rTKIPReplays.QuadPart = 0;
  515. prStatistics->rCCMPFormatErrors.QuadPart = 0;
  516. prStatistics->rCCMPReplays.QuadPart = 0;
  517. prStatistics->rCCMPDecryptErrors.QuadPart = 0;
  518. prStatistics->rFourWayHandshakeFailures.QuadPart = 0;
  519. prStatistics->rWEPUndecryptableCount.QuadPart = 0;
  520. prStatistics->rWEPICVErrorCount.QuadPart = 0;
  521. prStatistics->rDecryptSuccessCount.QuadPart = 0;
  522. prStatistics->rDecryptFailureCount.QuadPart = 0;
  523. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  524. }
  525. }
  526. VOID nicCmdEventEnterRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  527. {
  528. #define WAIT_FW_READY_RETRY_CNT 200
  529. UINT_32 u4WHISR = 0, u4Value = 0;
  530. UINT_8 aucTxCount[8];
  531. UINT_16 u2RetryCnt = 0;
  532. ASSERT(prAdapter);
  533. ASSERT(prCmdInfo);
  534. /* [driver-land] */
  535. prAdapter->fgTestMode = TRUE;
  536. /* 0. always indicate disconnection */
  537. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED)
  538. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  539. /* 1. Remove pending TX */
  540. nicTxRelease(prAdapter);
  541. /* 1.1 clear pending Security / Management Frames */
  542. kalClearSecurityFrames(prAdapter->prGlueInfo);
  543. kalClearMgmtFrames(prAdapter->prGlueInfo);
  544. /* 1.2 clear pending TX packet queued in glue layer */
  545. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  546. /* 2. Reset driver-domain FSMs */
  547. nicUninitMGMT(prAdapter);
  548. nicResetSystemService(prAdapter);
  549. nicInitMGMT(prAdapter, NULL);
  550. /* 3. Disable Interrupt */
  551. HAL_INTR_DISABLE(prAdapter);
  552. /* 4. Block til firmware completed entering into RF test mode */
  553. kalMsleep(500);
  554. while (1) {
  555. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  556. if (u4Value & WCIR_WLAN_READY) {
  557. break;
  558. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE ||
  559. kalIsResetting() || u2RetryCnt >= WAIT_FW_READY_RETRY_CNT) {
  560. if (prCmdInfo->fgIsOid) {
  561. /* Update Set Information Length */
  562. kalOidComplete(prAdapter->prGlueInfo,
  563. prCmdInfo->fgSetQuery,
  564. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  565. }
  566. return;
  567. }
  568. kalMsleep(10);
  569. u2RetryCnt++;
  570. }
  571. /* 5. Clear Interrupt Status */
  572. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  573. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  574. HAL_READ_TX_RELEASED_COUNT(prAdapter, aucTxCount);
  575. /* 6. Reset TX Counter */
  576. nicTxResetResource(prAdapter);
  577. /* 7. Re-enable Interrupt */
  578. HAL_INTR_ENABLE(prAdapter);
  579. /* 8. completion indication */
  580. if (prCmdInfo->fgIsOid) {
  581. /* Update Set Information Length */
  582. kalOidComplete(prAdapter->prGlueInfo,
  583. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  584. }
  585. #if CFG_SUPPORT_NVRAM
  586. /* 9. load manufacture data */
  587. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  588. #endif
  589. }
  590. VOID nicCmdEventLeaveRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  591. {
  592. #define WAIT_FW_READY_RETRY_CNT 200
  593. UINT_32 u4WHISR = 0, u4Value = 0;
  594. UINT_8 aucTxCount[8];
  595. UINT_16 u2RetryCnt = 0;
  596. ASSERT(prAdapter);
  597. ASSERT(prCmdInfo);
  598. /* 1. Disable Interrupt */
  599. HAL_INTR_DISABLE(prAdapter);
  600. /* 2. Block til firmware completed leaving from RF test mode */
  601. kalMsleep(500);
  602. while (1) {
  603. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  604. if (u4Value & WCIR_WLAN_READY) {
  605. break;
  606. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE ||
  607. kalIsResetting() || u2RetryCnt >= WAIT_FW_READY_RETRY_CNT) {
  608. if (prCmdInfo->fgIsOid) {
  609. /* Update Set Information Length */
  610. kalOidComplete(prAdapter->prGlueInfo,
  611. prCmdInfo->fgSetQuery,
  612. prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
  613. }
  614. return;
  615. }
  616. kalMsleep(10);
  617. u2RetryCnt++;
  618. }
  619. /* 3. Clear Interrupt Status */
  620. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  621. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  622. HAL_READ_TX_RELEASED_COUNT(prAdapter, aucTxCount);
  623. /* 4. Reset TX Counter */
  624. nicTxResetResource(prAdapter);
  625. /* 5. Re-enable Interrupt */
  626. HAL_INTR_ENABLE(prAdapter);
  627. /* 6. set driver-land variable */
  628. prAdapter->fgTestMode = FALSE;
  629. /* 7. completion indication */
  630. if (prCmdInfo->fgIsOid) {
  631. /* Update Set Information Length */
  632. kalOidComplete(prAdapter->prGlueInfo,
  633. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  634. }
  635. /* 8. Indicate as disconnected */
  636. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
  637. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  638. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  639. }
  640. #if CFG_SUPPORT_NVRAM
  641. /* 9. load manufacture data */
  642. wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
  643. #endif
  644. /* 10. Override network address */
  645. wlanUpdateNetworkAddress(prAdapter);
  646. }
  647. VOID nicCmdEventQueryAddress(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  648. {
  649. UINT_32 u4QueryInfoLen;
  650. P_GLUE_INFO_T prGlueInfo;
  651. P_EVENT_BASIC_CONFIG prEventBasicConfig;
  652. ASSERT(prAdapter);
  653. ASSERT(prCmdInfo);
  654. ASSERT(pucEventBuf);
  655. prEventBasicConfig = (P_EVENT_BASIC_CONFIG) (pucEventBuf);
  656. /* copy to adapter */
  657. kalMemCopy(&(prAdapter->rMyMacAddr), &(prEventBasicConfig->rMyMacAddr), MAC_ADDR_LEN);
  658. /* 4 <2> Update information of OID */
  659. if (prCmdInfo->fgIsOid) {
  660. prGlueInfo = prAdapter->prGlueInfo;
  661. kalMemCopy(prCmdInfo->pvInformationBuffer, &(prEventBasicConfig->rMyMacAddr), MAC_ADDR_LEN);
  662. u4QueryInfoLen = MAC_ADDR_LEN;
  663. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  664. }
  665. /* 4 <3> Update new MAC address and all 3 networks */
  666. COPY_MAC_ADDR(prAdapter->rWifiVar.aucMacAddress, prAdapter->rMyMacAddr);
  667. COPY_MAC_ADDR(prAdapter->rWifiVar.aucDeviceAddress, prAdapter->rMyMacAddr);
  668. prAdapter->rWifiVar.aucDeviceAddress[0] ^= MAC_ADDR_LOCAL_ADMIN;
  669. COPY_MAC_ADDR(prAdapter->rWifiVar.aucInterfaceAddress, prAdapter->rMyMacAddr);
  670. prAdapter->rWifiVar.aucInterfaceAddress[0] ^= MAC_ADDR_LOCAL_ADMIN;
  671. COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].aucOwnMacAddr, prAdapter->rMyMacAddr);
  672. #if CFG_ENABLE_WIFI_DIRECT
  673. if (prAdapter->fgIsP2PRegistered) {
  674. COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX].aucOwnMacAddr,
  675. prAdapter->rWifiVar.aucDeviceAddress);
  676. }
  677. #endif
  678. #if CFG_ENABLE_BT_OVER_WIFI
  679. COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX].aucOwnMacAddr,
  680. prAdapter->rWifiVar.aucDeviceAddress);
  681. #endif
  682. #if CFG_TEST_WIFI_DIRECT_GO
  683. if (prAdapter->rWifiVar.prP2pFsmInfo->eCurrentState == P2P_STATE_IDLE) {
  684. wlanEnableP2pFunction(prAdapter);
  685. wlanEnableATGO(prAdapter);
  686. }
  687. #endif
  688. kalUpdateMACAddress(prAdapter->prGlueInfo, prAdapter->rWifiVar.aucMacAddress);
  689. }
  690. VOID nicCmdEventQueryMcastAddr(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  691. {
  692. UINT_32 u4QueryInfoLen;
  693. P_GLUE_INFO_T prGlueInfo;
  694. P_EVENT_MAC_MCAST_ADDR prEventMacMcastAddr;
  695. ASSERT(prAdapter);
  696. ASSERT(prCmdInfo);
  697. ASSERT(pucEventBuf);
  698. /* 4 <2> Update information of OID */
  699. if (prCmdInfo->fgIsOid) {
  700. prGlueInfo = prAdapter->prGlueInfo;
  701. prEventMacMcastAddr = (P_EVENT_MAC_MCAST_ADDR) (pucEventBuf);
  702. u4QueryInfoLen = prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN;
  703. /* buffer length check */
  704. if (prCmdInfo->u4InformationBufferLength < u4QueryInfoLen) {
  705. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_BUFFER_TOO_SHORT);
  706. } else {
  707. kalMemCopy(prCmdInfo->pvInformationBuffer,
  708. prEventMacMcastAddr->arAddress,
  709. prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN);
  710. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  711. }
  712. }
  713. }
  714. VOID nicCmdEventQueryEepromRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  715. {
  716. UINT_32 u4QueryInfoLen;
  717. P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T prEepromRdInfo;
  718. P_GLUE_INFO_T prGlueInfo;
  719. P_EVENT_ACCESS_EEPROM prEventAccessEeprom;
  720. ASSERT(prAdapter);
  721. ASSERT(prCmdInfo);
  722. ASSERT(pucEventBuf);
  723. /* 4 <2> Update information of OID */
  724. if (prCmdInfo->fgIsOid) {
  725. prGlueInfo = prAdapter->prGlueInfo;
  726. prEventAccessEeprom = (P_EVENT_ACCESS_EEPROM) (pucEventBuf);
  727. u4QueryInfoLen = sizeof(PARAM_CUSTOM_EEPROM_RW_STRUCT_T);
  728. prEepromRdInfo = (P_PARAM_CUSTOM_EEPROM_RW_STRUCT_T) prCmdInfo->pvInformationBuffer;
  729. prEepromRdInfo->ucEepromIndex = (UINT_8) (prEventAccessEeprom->u2Offset);
  730. prEepromRdInfo->u2EepromData = prEventAccessEeprom->u2Data;
  731. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  732. }
  733. return;
  734. }
  735. VOID nicCmdEventSetMediaStreamMode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  736. {
  737. PARAM_MEDIA_STREAMING_INDICATION rParamMediaStreamIndication;
  738. ASSERT(prAdapter);
  739. ASSERT(prCmdInfo);
  740. if (prCmdInfo->fgIsOid) {
  741. /* Update Set Information Length */
  742. kalOidComplete(prAdapter->prGlueInfo,
  743. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
  744. }
  745. rParamMediaStreamIndication.rStatus.eStatusType = ENUM_STATUS_TYPE_MEDIA_STREAM_MODE;
  746. rParamMediaStreamIndication.eMediaStreamMode =
  747. prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode == 0 ? ENUM_MEDIA_STREAM_OFF : ENUM_MEDIA_STREAM_ON;
  748. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  749. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  750. (PVOID)&rParamMediaStreamIndication, sizeof(PARAM_MEDIA_STREAMING_INDICATION));
  751. }
  752. /* Statistics responder */
  753. VOID nicCmdEventQueryXmitOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  754. {
  755. P_EVENT_STATISTICS prEventStatistics;
  756. P_GLUE_INFO_T prGlueInfo;
  757. UINT_32 u4QueryInfoLen;
  758. PUINT_32 pu4Data;
  759. PUINT_64 pu8Data;
  760. ASSERT(prAdapter);
  761. ASSERT(prCmdInfo);
  762. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  763. if (prCmdInfo->fgIsOid) {
  764. prGlueInfo = prAdapter->prGlueInfo;
  765. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  766. u4QueryInfoLen = sizeof(UINT_32);
  767. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  768. *pu4Data = (UINT_32) prEventStatistics->rTransmittedFragmentCount.QuadPart;
  769. } else {
  770. u4QueryInfoLen = sizeof(UINT_64);
  771. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  772. *pu8Data = prEventStatistics->rTransmittedFragmentCount.QuadPart;
  773. }
  774. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  775. }
  776. }
  777. VOID nicCmdEventQueryRecvOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  778. {
  779. P_EVENT_STATISTICS prEventStatistics;
  780. P_GLUE_INFO_T prGlueInfo;
  781. UINT_32 u4QueryInfoLen;
  782. PUINT_32 pu4Data;
  783. PUINT_64 pu8Data;
  784. ASSERT(prAdapter);
  785. ASSERT(prCmdInfo);
  786. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  787. if (prCmdInfo->fgIsOid) {
  788. prGlueInfo = prAdapter->prGlueInfo;
  789. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  790. u4QueryInfoLen = sizeof(UINT_32);
  791. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  792. *pu4Data = (UINT_32) prEventStatistics->rReceivedFragmentCount.QuadPart;
  793. } else {
  794. u4QueryInfoLen = sizeof(UINT_64);
  795. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  796. *pu8Data = prEventStatistics->rReceivedFragmentCount.QuadPart;
  797. }
  798. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  799. }
  800. }
  801. VOID nicCmdEventQueryXmitError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  802. {
  803. P_EVENT_STATISTICS prEventStatistics;
  804. P_GLUE_INFO_T prGlueInfo;
  805. UINT_32 u4QueryInfoLen;
  806. PUINT_32 pu4Data;
  807. PUINT_64 pu8Data;
  808. ASSERT(prAdapter);
  809. ASSERT(prCmdInfo);
  810. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  811. if (prCmdInfo->fgIsOid) {
  812. prGlueInfo = prAdapter->prGlueInfo;
  813. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  814. u4QueryInfoLen = sizeof(UINT_32);
  815. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  816. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  817. } else {
  818. u4QueryInfoLen = sizeof(UINT_64);
  819. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  820. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  821. }
  822. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  823. }
  824. }
  825. VOID nicCmdEventQueryRecvError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  826. {
  827. P_EVENT_STATISTICS prEventStatistics;
  828. P_GLUE_INFO_T prGlueInfo;
  829. UINT_32 u4QueryInfoLen;
  830. PUINT_32 pu4Data;
  831. PUINT_64 pu8Data;
  832. ASSERT(prAdapter);
  833. ASSERT(prCmdInfo);
  834. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  835. if (prCmdInfo->fgIsOid) {
  836. prGlueInfo = prAdapter->prGlueInfo;
  837. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  838. u4QueryInfoLen = sizeof(UINT_32);
  839. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  840. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  841. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  842. } else {
  843. u4QueryInfoLen = sizeof(UINT_64);
  844. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  845. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  846. /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
  847. }
  848. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  849. }
  850. }
  851. VOID nicCmdEventQueryRecvNoBuffer(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  852. {
  853. P_EVENT_STATISTICS prEventStatistics;
  854. P_GLUE_INFO_T prGlueInfo;
  855. UINT_32 u4QueryInfoLen;
  856. PUINT_32 pu4Data;
  857. PUINT_64 pu8Data;
  858. ASSERT(prAdapter);
  859. ASSERT(prCmdInfo);
  860. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  861. if (prCmdInfo->fgIsOid) {
  862. prGlueInfo = prAdapter->prGlueInfo;
  863. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  864. u4QueryInfoLen = sizeof(UINT_32);
  865. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  866. *pu4Data = 0; /* @FIXME? */
  867. } else {
  868. u4QueryInfoLen = sizeof(UINT_64);
  869. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  870. *pu8Data = 0; /* @FIXME? */
  871. }
  872. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  873. }
  874. }
  875. VOID nicCmdEventQueryRecvCrcError(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  876. {
  877. P_EVENT_STATISTICS prEventStatistics;
  878. P_GLUE_INFO_T prGlueInfo;
  879. UINT_32 u4QueryInfoLen;
  880. PUINT_32 pu4Data;
  881. PUINT_64 pu8Data;
  882. ASSERT(prAdapter);
  883. ASSERT(prCmdInfo);
  884. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  885. if (prCmdInfo->fgIsOid) {
  886. prGlueInfo = prAdapter->prGlueInfo;
  887. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  888. u4QueryInfoLen = sizeof(UINT_32);
  889. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  890. *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
  891. } else {
  892. u4QueryInfoLen = sizeof(UINT_64);
  893. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  894. *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
  895. }
  896. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  897. }
  898. }
  899. VOID nicCmdEventQueryRecvErrorAlignment(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  900. {
  901. P_EVENT_STATISTICS prEventStatistics;
  902. P_GLUE_INFO_T prGlueInfo;
  903. UINT_32 u4QueryInfoLen;
  904. PUINT_32 pu4Data;
  905. PUINT_64 pu8Data;
  906. ASSERT(prAdapter);
  907. ASSERT(prCmdInfo);
  908. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  909. if (prCmdInfo->fgIsOid) {
  910. prGlueInfo = prAdapter->prGlueInfo;
  911. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  912. u4QueryInfoLen = sizeof(UINT_32);
  913. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  914. *pu4Data = (UINT_32) 0; /* @FIXME */
  915. } else {
  916. u4QueryInfoLen = sizeof(UINT_64);
  917. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  918. *pu8Data = 0; /* @FIXME */
  919. }
  920. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  921. }
  922. }
  923. VOID nicCmdEventQueryXmitOneCollision(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  924. {
  925. P_EVENT_STATISTICS prEventStatistics;
  926. P_GLUE_INFO_T prGlueInfo;
  927. UINT_32 u4QueryInfoLen;
  928. PUINT_32 pu4Data;
  929. PUINT_64 pu8Data;
  930. ASSERT(prAdapter);
  931. ASSERT(prCmdInfo);
  932. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  933. if (prCmdInfo->fgIsOid) {
  934. prGlueInfo = prAdapter->prGlueInfo;
  935. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  936. u4QueryInfoLen = sizeof(UINT_32);
  937. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  938. *pu4Data =
  939. (UINT_32) (prEventStatistics->rMultipleRetryCount.QuadPart -
  940. prEventStatistics->rRetryCount.QuadPart);
  941. } else {
  942. u4QueryInfoLen = sizeof(UINT_64);
  943. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  944. *pu8Data =
  945. (UINT_64) (prEventStatistics->rMultipleRetryCount.QuadPart -
  946. prEventStatistics->rRetryCount.QuadPart);
  947. }
  948. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  949. }
  950. }
  951. VOID nicCmdEventQueryXmitMoreCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  952. {
  953. P_EVENT_STATISTICS prEventStatistics;
  954. P_GLUE_INFO_T prGlueInfo;
  955. UINT_32 u4QueryInfoLen;
  956. PUINT_32 pu4Data;
  957. PUINT_64 pu8Data;
  958. ASSERT(prAdapter);
  959. ASSERT(prCmdInfo);
  960. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  961. if (prCmdInfo->fgIsOid) {
  962. prGlueInfo = prAdapter->prGlueInfo;
  963. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  964. u4QueryInfoLen = sizeof(UINT_32);
  965. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  966. *pu4Data = (UINT_32) prEventStatistics->rMultipleRetryCount.QuadPart;
  967. } else {
  968. u4QueryInfoLen = sizeof(UINT_64);
  969. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  970. *pu8Data = (UINT_64) prEventStatistics->rMultipleRetryCount.QuadPart;
  971. }
  972. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  973. }
  974. }
  975. VOID nicCmdEventQueryXmitMaxCollisions(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  976. {
  977. P_EVENT_STATISTICS prEventStatistics;
  978. P_GLUE_INFO_T prGlueInfo;
  979. UINT_32 u4QueryInfoLen;
  980. PUINT_32 pu4Data;
  981. PUINT_64 pu8Data;
  982. ASSERT(prAdapter);
  983. ASSERT(prCmdInfo);
  984. prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
  985. if (prCmdInfo->fgIsOid) {
  986. prGlueInfo = prAdapter->prGlueInfo;
  987. if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
  988. u4QueryInfoLen = sizeof(UINT_32);
  989. pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
  990. *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
  991. } else {
  992. u4QueryInfoLen = sizeof(UINT_64);
  993. pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
  994. *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
  995. }
  996. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  997. }
  998. }
  999. /*----------------------------------------------------------------------------*/
  1000. /*!
  1001. * @brief This function is called when command by OID/ioctl has been timeout
  1002. *
  1003. * @param prAdapter Pointer to the Adapter structure.
  1004. * @param prCmdInfo Pointer to the command information
  1005. *
  1006. * @return TRUE
  1007. * FALSE
  1008. */
  1009. /*----------------------------------------------------------------------------*/
  1010. VOID nicOidCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1011. {
  1012. ASSERT(prAdapter);
  1013. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1014. }
  1015. /*----------------------------------------------------------------------------*/
  1016. /*!
  1017. * @brief This function is a generic command timeout handler
  1018. *
  1019. * @param pfnOidHandler Pointer to the OID handler
  1020. *
  1021. * @return none
  1022. */
  1023. /*----------------------------------------------------------------------------*/
  1024. VOID nicCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1025. {
  1026. ASSERT(prAdapter);
  1027. }
  1028. /*----------------------------------------------------------------------------*/
  1029. /*!
  1030. * @brief This function is called when command for entering RF test has
  1031. * failed sending due to timeout (highly possibly by firmware crash)
  1032. *
  1033. * @param prAdapter Pointer to the Adapter structure.
  1034. * @param prCmdInfo Pointer to the command information
  1035. *
  1036. * @return none
  1037. *
  1038. */
  1039. /*----------------------------------------------------------------------------*/
  1040. VOID nicOidCmdEnterRFTestTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1041. {
  1042. ASSERT(prAdapter);
  1043. /* 1. Remove pending TX frames */
  1044. nicTxRelease(prAdapter);
  1045. /* 1.1 clear pending Security / Management Frames */
  1046. kalClearSecurityFrames(prAdapter->prGlueInfo);
  1047. kalClearMgmtFrames(prAdapter->prGlueInfo);
  1048. /* 1.2 clear pending TX packet queued in glue layer */
  1049. kalFlushPendingTxPackets(prAdapter->prGlueInfo);
  1050. /* 2. indicate for OID failure */
  1051. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  1052. }
  1053. /*----------------------------------------------------------------------------*/
  1054. /*!
  1055. * @brief This function is called when command for memory dump has
  1056. * replied a event.
  1057. *
  1058. * @param prAdapter Pointer to the Adapter structure.
  1059. * @param prCmdInfo Pointer to the command information
  1060. * @param pucEventBuf Pointer to event buffer
  1061. *
  1062. * @return none
  1063. *
  1064. */
  1065. /*----------------------------------------------------------------------------*/
  1066. VOID nicCmdEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1067. {
  1068. UINT_32 u4QueryInfoLen;
  1069. P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T prMemDumpInfo;
  1070. P_GLUE_INFO_T prGlueInfo;
  1071. P_EVENT_DUMP_MEM_T prEventDumpMem;
  1072. static UINT_8 aucPath[256];
  1073. static UINT_32 u4CurTimeTick;
  1074. ASSERT(prAdapter);
  1075. ASSERT(prCmdInfo);
  1076. ASSERT(pucEventBuf);
  1077. /* 4 <2> Update information of OID */
  1078. if (prCmdInfo->fgIsOid) {
  1079. prGlueInfo = prAdapter->prGlueInfo;
  1080. prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
  1081. u4QueryInfoLen = sizeof(P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T);
  1082. prMemDumpInfo = (P_PARAM_CUSTOM_MEM_DUMP_STRUCT_T) prCmdInfo->pvInformationBuffer;
  1083. prMemDumpInfo->u4Address = prEventDumpMem->u4Address;
  1084. prMemDumpInfo->u4Length = prEventDumpMem->u4Length;
  1085. prMemDumpInfo->u4RemainLength = prEventDumpMem->u4RemainLength;
  1086. prMemDumpInfo->ucFragNum = prEventDumpMem->ucFragNum;
  1087. #if 0
  1088. do {
  1089. UINT_32 i = 0;
  1090. DBGLOG(REQ, TRACE, "Rx dump address 0x%X, Length %d, FragNum %d, remain %d\n",
  1091. prEventDumpMem->u4Address,
  1092. prEventDumpMem->u4Length, prEventDumpMem->ucFragNum, prEventDumpMem->u4RemainLength);
  1093. #if 0
  1094. for (i = 0; i < prEventDumpMem->u4Length; i++) {
  1095. DBGLOG(REQ, TRACE, "%02X ", prEventDumpMem->aucBuffer[i]);
  1096. if (i % 32 == 31)
  1097. DBGLOG(REQ, TRACE, "\n");
  1098. }
  1099. #endif
  1100. } while (FALSE);
  1101. #endif
  1102. if (prEventDumpMem->ucFragNum == 1) {
  1103. /* Store memory dump into sdcard,
  1104. * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
  1105. */
  1106. u4CurTimeTick = kalGetTimeTick();
  1107. sprintf(aucPath, "/sdcard/dump_%d_0x%08X_%d.hex",
  1108. u4CurTimeTick,
  1109. prEventDumpMem->u4Address, prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
  1110. kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1111. } else {
  1112. /* Append current memory dump to the hex file */
  1113. kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0], prEventDumpMem->u4Length);
  1114. }
  1115. if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
  1116. /* The request is finished or firmware response a error */
  1117. /* Reply time tick to iwpriv */
  1118. *((PUINT_32) prCmdInfo->pvInformationBuffer) = u4CurTimeTick;
  1119. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1120. } else {
  1121. /* The memory dump request is not finished, Send next command */
  1122. wlanSendMemDumpCmd(prAdapter,
  1123. prCmdInfo->pvInformationBuffer, prCmdInfo->u4InformationBufferLength);
  1124. }
  1125. }
  1126. return;
  1127. }
  1128. #if CFG_SUPPORT_BATCH_SCAN
  1129. /*----------------------------------------------------------------------------*/
  1130. /*!
  1131. * @brief This function is called when event for SUPPORT_BATCH_SCAN
  1132. *
  1133. * @param prAdapter Pointer to the Adapter structure.
  1134. * @param prCmdInfo Pointer to the command information
  1135. * @param pucEventBuf Pointer to the event buffer
  1136. *
  1137. * @return none
  1138. *
  1139. */
  1140. /*----------------------------------------------------------------------------*/
  1141. VOID nicCmdEventBatchScanResult(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1142. {
  1143. UINT_32 u4QueryInfoLen;
  1144. P_EVENT_BATCH_RESULT_T prEventBatchResult;
  1145. P_GLUE_INFO_T prGlueInfo;
  1146. DBGLOG(SCN, TRACE, "nicCmdEventBatchScanResult");
  1147. ASSERT(prAdapter);
  1148. ASSERT(prCmdInfo);
  1149. ASSERT(pucEventBuf);
  1150. /* 4 <2> Update information of OID */
  1151. if (prCmdInfo->fgIsOid) {
  1152. prGlueInfo = prAdapter->prGlueInfo;
  1153. prEventBatchResult = (P_EVENT_BATCH_RESULT_T) pucEventBuf;
  1154. u4QueryInfoLen = sizeof(EVENT_BATCH_RESULT_T);
  1155. kalMemCopy(prCmdInfo->pvInformationBuffer, prEventBatchResult, sizeof(EVENT_BATCH_RESULT_T));
  1156. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1157. }
  1158. }
  1159. #endif
  1160. #if CFG_SUPPORT_BUILD_DATE_CODE
  1161. /*----------------------------------------------------------------------------*/
  1162. /*!
  1163. * @brief This function is called when event for build date code information
  1164. * has been retrieved
  1165. *
  1166. * @param prAdapter Pointer to the Adapter structure.
  1167. * @param prCmdInfo Pointer to the command information
  1168. * @param pucEventBuf Pointer to the event buffer
  1169. *
  1170. * @return none
  1171. *
  1172. */
  1173. /*----------------------------------------------------------------------------*/
  1174. VOID nicCmdEventBuildDateCode(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1175. {
  1176. UINT_32 u4QueryInfoLen;
  1177. P_EVENT_BUILD_DATE_CODE prEvent;
  1178. P_GLUE_INFO_T prGlueInfo;
  1179. ASSERT(prAdapter);
  1180. ASSERT(prCmdInfo);
  1181. ASSERT(pucEventBuf);
  1182. /* 4 <2> Update information of OID */
  1183. if (prCmdInfo->fgIsOid) {
  1184. prGlueInfo = prAdapter->prGlueInfo;
  1185. prEvent = (P_EVENT_BUILD_DATE_CODE) pucEventBuf;
  1186. u4QueryInfoLen = sizeof(UINT_8) * 16;
  1187. kalMemCopy(prCmdInfo->pvInformationBuffer, prEvent->aucDateCode, sizeof(UINT_8) * 16);
  1188. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1189. }
  1190. }
  1191. #endif
  1192. /*----------------------------------------------------------------------------*/
  1193. /*!
  1194. * @brief This function is called when event for query STA link status
  1195. * has been retrieved
  1196. *
  1197. * @param prAdapter Pointer to the Adapter structure.
  1198. * @param prCmdInfo Pointer to the command information
  1199. * @param pucEventBuf Pointer to the event buffer
  1200. *
  1201. * @return none
  1202. *
  1203. */
  1204. /*----------------------------------------------------------------------------*/
  1205. VOID nicCmdEventQueryStaStatistics(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1206. {
  1207. UINT_32 u4QueryInfoLen;
  1208. P_EVENT_STA_STATISTICS_T prEvent;
  1209. P_GLUE_INFO_T prGlueInfo;
  1210. P_PARAM_GET_STA_STATISTICS prStaStatistics;
  1211. if ((prAdapter == NULL)
  1212. || (prCmdInfo == NULL)
  1213. || (pucEventBuf == NULL)
  1214. || (prCmdInfo->pvInformationBuffer == NULL)) {
  1215. ASSERT(FALSE);
  1216. return;
  1217. }
  1218. if (prCmdInfo->fgIsOid) {
  1219. prGlueInfo = prAdapter->prGlueInfo;
  1220. prEvent = (P_EVENT_STA_STATISTICS_T) pucEventBuf;
  1221. prStaStatistics = (P_PARAM_GET_STA_STATISTICS) prCmdInfo->pvInformationBuffer;
  1222. u4QueryInfoLen = sizeof(PARAM_GET_STA_STA_STATISTICS);
  1223. /* Statistics from FW is valid */
  1224. if (prEvent->u4Flags & BIT(0)) {
  1225. prStaStatistics->ucPer = prEvent->ucPer;
  1226. prStaStatistics->ucRcpi = prEvent->ucRcpi;
  1227. prStaStatistics->u4PhyMode = prEvent->u4PhyMode;
  1228. prStaStatistics->u2LinkSpeed = prEvent->u2LinkSpeed;
  1229. prStaStatistics->u4TxFailCount = prEvent->u4TxFailCount;
  1230. prStaStatistics->u4TxLifeTimeoutCount = prEvent->u4TxLifeTimeoutCount;
  1231. if (prEvent->u4TxCount) {
  1232. UINT_32 u4TxDoneAirTimeMs = USEC_TO_MSEC(prEvent->u4TxDoneAirTime * 32);
  1233. prStaStatistics->u4TxAverageAirTime = (u4TxDoneAirTimeMs / prEvent->u4TxCount);
  1234. } else {
  1235. prStaStatistics->u4TxAverageAirTime = 0;
  1236. }
  1237. }
  1238. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1239. }
  1240. }
  1241. #if CFG_AUTO_CHANNEL_SEL_SUPPORT
  1242. /* 4 Auto Channel Selection */
  1243. /*----------------------------------------------------------------------------*/
  1244. /*!
  1245. * @brief This function is called when event for query STA link status
  1246. * has been retrieved
  1247. *
  1248. * @param prAdapter Pointer to the Adapter structure.
  1249. * @param prCmdInfo Pointer to the command information
  1250. * @param pucEventBuf Pointer to the event buffer
  1251. *
  1252. * @return none
  1253. *
  1254. */
  1255. /*----------------------------------------------------------------------------*/
  1256. VOID nicCmdEventQueryChannelLoad(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1257. {
  1258. UINT_32 u4QueryInfoLen;
  1259. P_EVENT_CHN_LOAD_T prEvent;
  1260. P_GLUE_INFO_T prGlueInfo;
  1261. P_PARAM_GET_CHN_LOAD prChnLoad;
  1262. if ((prAdapter == NULL)
  1263. || (prCmdInfo == NULL)
  1264. || (pucEventBuf == NULL)
  1265. || (prCmdInfo->pvInformationBuffer == NULL)) {
  1266. ASSERT(FALSE);
  1267. return;
  1268. }
  1269. if (prCmdInfo->fgIsOid) {
  1270. prGlueInfo = prAdapter->prGlueInfo;
  1271. prEvent = (P_EVENT_CHN_LOAD_T) pucEventBuf; /* 4 The firmware responsed data */
  1272. /* 4 Fill the firmware data in and send it back to host */
  1273. prChnLoad = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1274. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1275. /* Statistics from FW is valid */
  1276. if (prEvent->u4Flags & BIT(0)) {
  1277. prChnLoad->rEachChnLoad[0].ucChannel = prEvent->ucChannel;
  1278. prChnLoad->rEachChnLoad[0].u2ChannelLoad = prEvent->u2ChannelLoad;
  1279. DBGLOG(P2P, INFO, "CHN[%d]=%d\n", prEvent->ucChannel, prEvent->u2ChannelLoad);
  1280. }
  1281. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1282. }
  1283. }
  1284. VOID nicCmdEventQueryLTESafeChn(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1285. {
  1286. UINT_8 ucIdx = 0;
  1287. UINT_32 u4QueryInfoLen;
  1288. P_EVENT_LTE_MODE_T prEvent;
  1289. P_GLUE_INFO_T prGlueInfo;
  1290. P_PARAM_GET_CHN_LOAD prLteSafeChnInfo;
  1291. if ((prAdapter == NULL)
  1292. || (prCmdInfo == NULL)
  1293. || (pucEventBuf == NULL)
  1294. || (prCmdInfo->pvInformationBuffer == NULL)) {
  1295. ASSERT(FALSE);
  1296. return;
  1297. }
  1298. if (prCmdInfo->fgIsOid) {
  1299. prGlueInfo = prAdapter->prGlueInfo;
  1300. prEvent = (P_EVENT_LTE_MODE_T) pucEventBuf; /* 4 The firmware responsed data */
  1301. prLteSafeChnInfo = (P_PARAM_GET_CHN_LOAD) prCmdInfo->pvInformationBuffer;
  1302. u4QueryInfoLen = sizeof(PARAM_GET_CHN_LOAD);
  1303. /* Statistics from FW is valid */
  1304. if (prEvent->u4Flags & BIT(0)) {
  1305. for (ucIdx = 0; ucIdx < (NL80211_TESTMODE_AVAILABLE_CHAN_NUM - 1); ucIdx++) {
  1306. prLteSafeChnInfo->rLteSafeChnList.au4SafeChannelBitmask[ucIdx] =
  1307. prEvent->rLteSafeChn.au4SafeChannelBitmask[ucIdx];
  1308. DBGLOG(P2P, INFO,
  1309. "[Auto Channel]LTE safe channels [%d]=[%x]\n", ucIdx,
  1310. (UINT32) prLteSafeChnInfo->rLteSafeChnList.au4SafeChannelBitmask[ucIdx]);
  1311. }
  1312. }
  1313. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1314. }
  1315. }
  1316. #endif
  1317. /*----------------------------------------------------------------------------*/
  1318. /*!
  1319. * @brief This function is called when event for query FW bss info
  1320. * has been retrieved
  1321. *
  1322. * @param prAdapter Pointer to the Adapter structure.
  1323. * @param prCmdInfo Pointer to the command information
  1324. * @param pucEventBuf Pointer to the event buffer
  1325. *
  1326. * @return none
  1327. *
  1328. */
  1329. /*----------------------------------------------------------------------------*/
  1330. VOID nicCmdEventGetBSSInfo(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  1331. {
  1332. UINT_32 u4QueryInfoLen;
  1333. P_EVENT_AIS_BSS_INFO_T prEvent;
  1334. P_GLUE_INFO_T prGlueInfo;
  1335. P_BSS_INFO_T prAisBssInfo;
  1336. ASSERT(prAdapter);
  1337. ASSERT(prCmdInfo);
  1338. ASSERT(pucEventBuf);
  1339. /* 4 <2> Update information of OID */
  1340. if (prCmdInfo->fgIsOid) {
  1341. prGlueInfo = prAdapter->prGlueInfo;
  1342. prEvent = (P_EVENT_AIS_BSS_INFO_T) pucEventBuf;
  1343. u4QueryInfoLen = sizeof(EVENT_AIS_BSS_INFO_T);
  1344. kalMemCopy(prCmdInfo->pvInformationBuffer, prEvent, sizeof(EVENT_AIS_BSS_INFO_T));
  1345. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1346. if (prEvent->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
  1347. if (prEvent->eConnectionState != prAisBssInfo->eConnectionState) {
  1348. DBGLOG(NIC, ERROR, "driver[%d] & FW[%d] status didn't sync !!!\n",
  1349. prAisBssInfo->eConnectionState, prEvent->eCurrentOPMode);
  1350. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_RADIO_LOST, FALSE);
  1351. }
  1352. }
  1353. kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
  1354. }
  1355. }