hem_mbox.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/hem_mbox.c#3
  3. */
  4. /*! \file "hem_mbox.c"
  5. \brief
  6. */
  7. /*
  8. ** Log: hem_mbox.c
  9. **
  10. ** 08 31 2012 yuche.tsai
  11. ** [ALPS00349585] [6577JB][WiFi direct][KE]Establish p2p connection while both device
  12. ** have connected to AP previously,one device reboots automatically with KE
  13. ** Fix possible KE when concurrent & disconnect.
  14. **
  15. ** 07 26 2012 yuche.tsai
  16. ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
  17. ** Update driver code of ALPS.JB for hot-spot.
  18. **
  19. ** 07 19 2012 yuche.tsai
  20. ** NULL
  21. ** Code update for JB.
  22. *
  23. * 07 17 2012 yuche.tsai
  24. * NULL
  25. * Compile no error before trial run.
  26. *
  27. * 05 03 2012 cp.wu
  28. * [WCXRP00001231] [MT6620 Wi-Fi][MT5931][Driver] Correct SCAN_V2 related debugging facilities within hem_mbox.c
  29. * correct for debug message string table by adding missed scan_v2 related definitions.
  30. *
  31. * 03 02 2012 terry.wu
  32. * NULL
  33. * Sync CFG80211 modification from branch 2,2.
  34. *
  35. * 01 17 2012 yuche.tsai
  36. * NULL
  37. * Update mgmt frame filter setting.
  38. * Please also update FW 2.1
  39. *
  40. * 01 13 2012 yuche.tsai
  41. * NULL
  42. * WiFi Hot Spot Tethering for ICS ALPHA testing version.
  43. *
  44. * 11 24 2011 wh.su
  45. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  46. * Adjust code for DBG and CONFIG_XLOG.
  47. *
  48. * 11 15 2011 cm.chang
  49. * NULL
  50. * Add exception handle for NULL function pointer of mailbox message
  51. *
  52. * 11 11 2011 wh.su
  53. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  54. * modify the xlog related code.
  55. *
  56. * 11 02 2011 wh.su
  57. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  58. * adding the code for XLOG.
  59. *
  60. * 07 18 2011 cp.wu
  61. * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search
  62. * for more than one SSID in a single scanning request
  63. * add framework in driver domain for supporting new SCAN_REQ_V2 for more than 1 SSID support
  64. * as well as uProbeDelay in NDIS 6.x driver model
  65. *
  66. * 06 07 2011 yuche.tsai
  67. * [WCXRP00000696] [Volunteer Patch][MT6620][Driver] Infinite loop issue when RX invitation response.
  68. * [WCXRP00000763] [Volunteer Patch][MT6620][Driver] RX Service Discovery Frame under AP mode Issue
  69. * Add invitation support.
  70. *
  71. * 04 18 2011 terry.wu
  72. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  73. * Remove flag CFG_WIFI_DIRECT_MOVED.
  74. *
  75. * 03 29 2011 cm.chang
  76. * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
  77. * As CR title
  78. *
  79. * 02 24 2011 cp.wu
  80. * [WCXRP00000490] [MT6620 Wi-Fi][Driver][Win32] modify kalMsleep() implementation
  81. * because NdisMSleep() won't sleep long enough for specified interval such as 500ms
  82. * modify cnm_timer and hem_mbox APIs to be thread safe to ease invoking restrictions
  83. *
  84. * 02 15 2011 chinghwa.yu
  85. * [WCXRP00000065] Update BoW design and settings
  86. * Update bowString and channel grant.
  87. *
  88. * 01 26 2011 cm.chang
  89. * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
  90. * Allocate system RAM if fixed message or mgmt buffer is not available
  91. *
  92. * 01 26 2011 yuche.tsai
  93. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  94. * .
  95. *
  96. * 01 25 2011 yuche.tsai
  97. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  98. * Fix Compile Error when DBG is disabled.
  99. *
  100. * 01 24 2011 cp.wu
  101. * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
  102. * 1. add an extra counter for tracking pending forward frames.
  103. * 2. notify TX service thread as well when there is pending forward frame
  104. * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
  105. *
  106. * 12 08 2010 chinghwa.yu
  107. * [WCXRP00000065] Update BoW design and settings
  108. * Support concurrent networks.
  109. *
  110. * 11 08 2010 cm.chang
  111. * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID
  112. * Remove CNM channel reover message ID
  113. *
  114. * 11 01 2010 cp.wu
  115. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver]
  116. * Add implementation for querying current TX rate from firmware auto rate module
  117. * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
  118. * 2) Remove CNM CH-RECOVER event handling
  119. * 3) cfg read/write API renamed with kal prefix for unified naming rules.
  120. *
  121. * 10 08 2010 wh.su
  122. * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
  123. * update the frog's new p2p state machine.
  124. *
  125. * 09 28 2010 wh.su
  126. * NULL
  127. * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
  128. *
  129. * 09 16 2010 cm.chang
  130. * NULL
  131. * Remove unused message ID
  132. *
  133. * 08 30 2010 cp.wu
  134. * NULL
  135. * eliminate klockwork errors
  136. *
  137. * 08 26 2010 yuche.tsai
  138. * NULL
  139. * Add P2P Connection Abort Event Message handler.
  140. *
  141. * 08 25 2010 george.huang
  142. * NULL
  143. * update OID/ registry control path for PM related settings
  144. *
  145. * 08 24 2010 yarco.yang
  146. * NULL
  147. * Fixed Driver ASSERT at mboxInitMsgMap()
  148. *
  149. * 08 24 2010 chinghwa.yu
  150. * NULL
  151. * Update for MID_SCN_BOW_SCAN_DONE mboxDummy.
  152. * Update saa_fsm for BOW.
  153. *
  154. * 08 23 2010 chinghwa.yu
  155. * NULL
  156. * Add CFG_ENABLE_BT_OVER_WIFI.
  157. *
  158. * 08 23 2010 chinghwa.yu
  159. * NULL
  160. * Update for BOW.
  161. *
  162. * 08 16 2010 cp.wu
  163. * NULL
  164. * add interface for RLM to trigger OBSS-SCAN.
  165. *
  166. * 08 16 2010 yuche.tsai
  167. * NULL
  168. * Add debug message for newly add P2P message.
  169. *
  170. * 08 11 2010 yuche.tsai
  171. * NULL
  172. * Add some function entry for P2P FSM under provisioning phase..
  173. *
  174. * 08 11 2010 yuche.tsai
  175. * NULL
  176. * Add some events to P2P Module.
  177. *
  178. * 08 05 2010 yuche.tsai
  179. * NULL
  180. * Add message box event for P2P device switch on & device discovery.
  181. *
  182. * 08 04 2010 cp.wu
  183. * NULL
  184. * remove unused mailbox message definitions.
  185. *
  186. * 08 02 2010 yuche.tsai
  187. * NULL
  188. * P2P Group Negotiation Code Check in.
  189. *
  190. * 07 19 2010 cp.wu
  191. *
  192. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  193. * message table should not be commented out by compilation option without modifying header file
  194. *
  195. * 07 19 2010 cp.wu
  196. *
  197. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  198. * Add Ad-Hoc support to AIS-FSM
  199. *
  200. * 07 19 2010 yuche.tsai
  201. *
  202. * Add wifi direct scan done callback.
  203. *
  204. * 07 09 2010 cp.wu
  205. *
  206. * change handler of MID_MNY_CNM_CONNECTION_ABORT from NULL to mboxDummy.
  207. *
  208. * 07 08 2010 cp.wu
  209. *
  210. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  211. *
  212. * 07 08 2010 cm.chang
  213. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  214. * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
  215. *
  216. * 07 01 2010 cp.wu
  217. * [WPD00003833][MT6620 and MT5931] Driver migration
  218. * AIS-FSM integration with CNM channel request messages
  219. *
  220. * 07 01 2010 cp.wu
  221. * [WPD00003833][MT6620 and MT5931] Driver migration
  222. * implementation of DRV-SCN and related mailbox message handling.
  223. *
  224. * 07 01 2010 cm.chang
  225. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  226. * Modify CNM message handler for new flow
  227. *
  228. * 06 15 2010 cp.wu
  229. * [WPD00003833][MT6620 and MT5931] Driver migration
  230. * enable currently migrated message call-backs.
  231. *
  232. * 06 14 2010 cp.wu
  233. * [WPD00003833][MT6620 and MT5931] Driver migration
  234. * restore utility function invoking via hem_mbox to direct calls
  235. *
  236. * 06 10 2010 cp.wu
  237. * [WPD00003833][MT6620 and MT5931] Driver migration
  238. * add buildable & linkable ais_fsm.c
  239. *
  240. * related reference are still waiting to be resolved
  241. *
  242. * 06 08 2010 cp.wu
  243. * [WPD00003833][MT6620 and MT5931] Driver migration
  244. * hem_mbox is migrated.
  245. *
  246. * 06 08 2010 cp.wu
  247. * [WPD00003833][MT6620 and MT5931] Driver migration
  248. * add hem_mbox.c and cnm_mem.h (but disabled some feature) for further migration
  249. *
  250. * 05 12 2010 kevin.huang
  251. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  252. * Fix file merge error
  253. *
  254. * 05 12 2010 kevin.huang
  255. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  256. * Add Power Management - Legacy PS-POLL support.
  257. *
  258. * 04 29 2010 tehuang.liu
  259. * [BORA00000605][WIFISYS] Phase3 Integration
  260. * Removed MID_RXM_MQM_QOS_ACTION_FRAME
  261. *
  262. * 04 29 2010 tehuang.liu
  263. * [BORA00000605][WIFISYS] Phase3 Integration
  264. * Removed MID_RXM_MQM_BA_ACTION_FRAME
  265. *
  266. * 04 27 2010 tehuang.liu
  267. * [BORA00000605][WIFISYS] Phase3 Integration
  268. * MID_RXM_MQM_BA_ACTION_FRAME
  269. *
  270. * 03 30 2010 cm.chang
  271. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  272. * Support 2.4G OBSS scan
  273. *
  274. * 03 16 2010 kevin.huang
  275. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  276. * Add AdHoc Mode
  277. *
  278. * 03 10 2010 kevin.huang
  279. * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
  280. *
  281. * * * * * * * * * * * * * * Add Channel Manager for arbitration of JOIN and SCAN Req
  282. *
  283. * 03 05 2010 cm.chang
  284. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  285. * Develop partial DPD code
  286. *
  287. * 02 11 2010 tehuang.liu
  288. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  289. * Updated arMsgMapTable for MID_RXM_MQM_QOS_ACTION_FRAME
  290. *
  291. * 01 11 2010 kevin.huang
  292. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  293. * Add Deauth and Disassoc Handler
  294. *
  295. * Dec 9 2009 mtk01461
  296. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  297. * Add hemRunEventScanDone() to arMsgMapTable[]
  298. *
  299. * Dec 4 2009 mtk01461
  300. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  301. * Fix mboxDummy() didn't free prMsgHdr
  302. *
  303. * Dec 3 2009 mtk01461
  304. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  305. * Add saaAisJoinComplete event handler
  306. *
  307. * Dec 2 2009 MTK02468
  308. * [BORA00000337] To check in codes for FPGA emulation
  309. * Fixed the handler function name in arMsgMapTable for MID_RXM_MQM_BA_ACTION_FRAME
  310. *
  311. * Dec 2 2009 MTK02468
  312. * [BORA00000337] To check in codes for FPGA emulation
  313. * Added MID_RXM_MQM_BA_ACTION_FRAME to MsgMapTable
  314. *
  315. * Nov 23 2009 mtk01461
  316. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  317. * Revise MSG Handler (remove dummy and add for SAA)
  318. *
  319. * Nov 16 2009 mtk01461
  320. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  321. * Add aisFsmRunEventAbort() event handler
  322. *
  323. * Nov 11 2009 mtk01461
  324. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  325. * Fix typo
  326. *
  327. * Nov 10 2009 mtk01461
  328. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  329. * Add more MSG_HNDL_ENTRY_T to avoid ASSERT() in mboxInitMsgMap()
  330. *
  331. * Nov 5 2009 mtk01461
  332. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  333. * Add SCN message and function entry to arMsgMapTable[]
  334. *
  335. * Nov 2 2009 mtk01104
  336. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  337. * Fix sorting algorithm in mboxInitMsgMap()
  338. *
  339. * Oct 28 2009 mtk01104
  340. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  341. *
  342. **
  343. */
  344. /*******************************************************************************
  345. * C O M P I L E R F L A G S
  346. ********************************************************************************
  347. */
  348. /*******************************************************************************
  349. * E X T E R N A L R E F E R E N C E S
  350. ********************************************************************************
  351. */
  352. #include "precomp.h"
  353. /*******************************************************************************
  354. * C O N S T A N T S
  355. ********************************************************************************
  356. */
  357. /*******************************************************************************
  358. * D A T A T Y P E S
  359. ********************************************************************************
  360. */
  361. /*******************************************************************************
  362. * P U B L I C D A T A
  363. ********************************************************************************
  364. */
  365. /*******************************************************************************
  366. * P R I V A T E D A T A
  367. ********************************************************************************
  368. */
  369. #if DBG
  370. /*lint -save -e64 Type mismatch */
  371. static PUINT_8 apucDebugMsg[] = {
  372. (PUINT_8) DISP_STRING("MID_MNY_CNM_CH_REQ"),
  373. (PUINT_8) DISP_STRING("MID_MNY_CNM_CH_ABORT"),
  374. (PUINT_8) DISP_STRING("MID_CNM_AIS_CH_GRANT"),
  375. (PUINT_8) DISP_STRING("MID_CNM_P2P_CH_GRANT"),
  376. (PUINT_8) DISP_STRING("MID_CNM_BOW_CH_GRANT"),
  377. (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_REQ"),
  378. (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_REQ_V2"),
  379. (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_CANCEL"),
  380. (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_REQ"),
  381. (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_REQ_V2"),
  382. (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_CANCEL"),
  383. (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_REQ"),
  384. (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_REQ_V2"),
  385. (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_CANCEL"),
  386. (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_REQ"),
  387. (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_REQ_V2"),
  388. (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_CANCEL"),
  389. (PUINT_8) DISP_STRING("MID_SCN_AIS_SCAN_DONE"),
  390. (PUINT_8) DISP_STRING("MID_SCN_P2P_SCAN_DONE"),
  391. (PUINT_8) DISP_STRING("MID_SCN_BOW_SCAN_DONE"),
  392. (PUINT_8) DISP_STRING("MID_SCN_RLM_SCAN_DONE"),
  393. (PUINT_8) DISP_STRING("MID_OID_AIS_FSM_JOIN_REQ"),
  394. (PUINT_8) DISP_STRING("MID_OID_AIS_FSM_ABORT"),
  395. (PUINT_8) DISP_STRING("MID_AIS_SAA_FSM_START"),
  396. (PUINT_8) DISP_STRING("MID_AIS_SAA_FSM_ABORT"),
  397. (PUINT_8) DISP_STRING("MID_SAA_AIS_JOIN_COMPLETE"),
  398. #if CFG_ENABLE_BT_OVER_WIFI
  399. (PUINT_8) DISP_STRING("MID_BOW_SAA_FSM_START"),
  400. (PUINT_8) DISP_STRING("MID_BOW_SAA_FSM_ABORT"),
  401. (PUINT_8) DISP_STRING("MID_SAA_BOW_JOIN_COMPLETE"),
  402. #endif
  403. #if CFG_ENABLE_WIFI_DIRECT
  404. (PUINT_8) DISP_STRING("MID_P2P_SAA_FSM_START"),
  405. (PUINT_8) DISP_STRING("MID_P2P_SAA_FSM_ABORT"),
  406. (PUINT_8) DISP_STRING("MID_SAA_P2P_JOIN_COMPLETE"),
  407. (PUINT_8) DISP_STRING("MID_MNY_P2P_FUN_SWITCH"),
  408. (PUINT_8) DISP_STRING("MID_MNY_P2P_DEVICE_DISCOVERY"),
  409. (PUINT_8) DISP_STRING("MID_MNY_P2P_CONNECTION_REQ"),
  410. (PUINT_8) DISP_STRING("MID_MNY_P2P_CONNECTION_ABORT"),
  411. (PUINT_8) DISP_STRING("MID_MNY_P2P_BEACON_UPDATE"),
  412. (PUINT_8) DISP_STRING("MID_MNY_P2P_STOP_AP"),
  413. (PUINT_8) DISP_STRING("MID_MNY_P2P_CHNL_REQ"),
  414. (PUINT_8) DISP_STRING("MID_MNY_P2P_CHNL_ABORT"),
  415. (PUINT_8) DISP_STRING("MID_MNY_P2P_MGMT_TX"),
  416. (PUINT_8) DISP_STRING("MID_MNY_P2P_GROUP_DISSOLVE"),
  417. (PUINT_8) DISP_STRING("MID_MNY_P2P_MGMT_FRAME_REGISTER"),
  418. (PUINT_8) DISP_STRING("MID_MNY_P2P_NET_DEV_REGISTER"),
  419. (PUINT_8) DISP_STRING("MID_MNY_P2P_START_AP"),
  420. (PUINT_8) DISP_STRING("MID_MNY_P2P_UPDATE_IE_BUF"),
  421. #endif
  422. #if CFG_SUPPORT_ADHOC
  423. /* (PUINT_8)DISP_STRING("MID_AIS_CNM_CREATE_IBSS_REQ"), */
  424. /* (PUINT_8)DISP_STRING("MID_CNM_AIS_CREATE_IBSS_GRANT"), */
  425. /* (PUINT_8)DISP_STRING("MID_AIS_CNM_MERGE_IBSS_REQ"), */
  426. /* (PUINT_8)DISP_STRING("MID_CNM_AIS_MERGE_IBSS_GRANT"), */
  427. (PUINT_8) DISP_STRING("MID_SCN_AIS_FOUND_IBSS"),
  428. #endif /* CFG_SUPPORT_ADHOC */
  429. (PUINT_8) DISP_STRING("MID_SAA_AIS_FSM_ABORT"),
  430. (PUINT_8) DISP_STRING("MID_MNY_AIS_REMAIN_ON_CHANNEL"),
  431. (PUINT_8) DISP_STRING("MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL"),
  432. (PUINT_8) DISP_STRING("MID_MNY_AIS_MGMT_TX")
  433. };
  434. /*lint -restore */
  435. #endif /* DBG */
  436. /* This message entry will be re-ordered based on the message ID order
  437. * by invoking mboxInitMsgMap()
  438. */
  439. static MSG_HNDL_ENTRY_T arMsgMapTable[] = {
  440. {MID_MNY_CNM_CH_REQ, cnmChMngrRequestPrivilege},
  441. {MID_MNY_CNM_CH_ABORT, cnmChMngrAbortPrivilege},
  442. {MID_CNM_AIS_CH_GRANT, aisFsmRunEventChGrant},
  443. #if CFG_ENABLE_WIFI_DIRECT
  444. {MID_CNM_P2P_CH_GRANT, p2pFsmRunEventChGrant}, /*set in gl_p2p_init.c */
  445. #else
  446. {MID_CNM_P2P_CH_GRANT, mboxDummy},
  447. #endif
  448. #if CFG_ENABLE_BT_OVER_WIFI
  449. {MID_CNM_BOW_CH_GRANT, bowRunEventChGrant},
  450. #else
  451. {MID_CNM_BOW_CH_GRANT, mboxDummy},
  452. #endif
  453. /*--------------------------------------------------*/
  454. /* SCN Module Mailbox Messages */
  455. /*--------------------------------------------------*/
  456. {MID_AIS_SCN_SCAN_REQ, scnFsmMsgStart},
  457. {MID_AIS_SCN_SCAN_REQ_V2, scnFsmMsgStart},
  458. {MID_AIS_SCN_SCAN_CANCEL, scnFsmMsgAbort},
  459. {MID_P2P_SCN_SCAN_REQ, scnFsmMsgStart},
  460. {MID_P2P_SCN_SCAN_REQ_V2, scnFsmMsgStart},
  461. {MID_P2P_SCN_SCAN_CANCEL, scnFsmMsgAbort},
  462. {MID_BOW_SCN_SCAN_REQ, scnFsmMsgStart},
  463. {MID_BOW_SCN_SCAN_REQ_V2, scnFsmMsgStart},
  464. {MID_BOW_SCN_SCAN_CANCEL, scnFsmMsgAbort},
  465. {MID_RLM_SCN_SCAN_REQ, scnFsmMsgStart},
  466. {MID_RLM_SCN_SCAN_REQ_V2, scnFsmMsgStart},
  467. {MID_RLM_SCN_SCAN_CANCEL, scnFsmMsgAbort},
  468. {MID_SCN_AIS_SCAN_DONE, aisFsmRunEventScanDone},
  469. #if CFG_ENABLE_WIFI_DIRECT
  470. {MID_SCN_P2P_SCAN_DONE, p2pFsmRunEventScanDone}, /*set in gl_p2p_init.c */
  471. #else
  472. {MID_SCN_P2P_SCAN_DONE, mboxDummy},
  473. #endif
  474. #if CFG_ENABLE_BT_OVER_WIFI
  475. {MID_SCN_BOW_SCAN_DONE, bowResponderScanDone},
  476. #else
  477. {MID_SCN_BOW_SCAN_DONE, mboxDummy},
  478. #endif
  479. {MID_SCN_RLM_SCAN_DONE, rlmObssScanDone},
  480. /*--------------------------------------------------*/
  481. /* AIS Module Mailbox Messages */
  482. /*--------------------------------------------------*/
  483. {MID_OID_AIS_FSM_JOIN_REQ, aisFsmRunEventAbort},
  484. {MID_OID_AIS_FSM_ABORT, aisFsmRunEventAbort},
  485. {MID_AIS_SAA_FSM_START, saaFsmRunEventStart},
  486. {MID_AIS_SAA_FSM_ABORT, saaFsmRunEventAbort},
  487. {MID_SAA_AIS_JOIN_COMPLETE, aisFsmRunEventJoinComplete},
  488. #if CFG_ENABLE_BT_OVER_WIFI
  489. /*--------------------------------------------------*/
  490. /* BOW Module Mailbox Messages */
  491. /*--------------------------------------------------*/
  492. {MID_BOW_SAA_FSM_START, saaFsmRunEventStart},
  493. {MID_BOW_SAA_FSM_ABORT, saaFsmRunEventAbort},
  494. {MID_SAA_BOW_JOIN_COMPLETE, bowFsmRunEventJoinComplete},
  495. #endif
  496. #if CFG_ENABLE_WIFI_DIRECT /*set in gl_p2p_init.c */
  497. {MID_P2P_SAA_FSM_START, saaFsmRunEventStart},
  498. {MID_P2P_SAA_FSM_ABORT, saaFsmRunEventAbort},
  499. {MID_SAA_P2P_JOIN_COMPLETE, p2pFsmRunEventJoinComplete}, /* TODO: p2pFsmRunEventJoinComplete */
  500. {MID_MNY_P2P_FUN_SWITCH, p2pFsmRunEventSwitchOPMode},
  501. {MID_MNY_P2P_DEVICE_DISCOVERY, p2pFsmRunEventScanRequest},
  502. {MID_MNY_P2P_CONNECTION_REQ, p2pFsmRunEventConnectionRequest},
  503. {MID_MNY_P2P_CONNECTION_ABORT, p2pFsmRunEventConnectionAbort},
  504. {MID_MNY_P2P_BEACON_UPDATE, p2pFsmRunEventBeaconUpdate},
  505. {MID_MNY_P2P_STOP_AP, p2pFsmRunEventStopAP},
  506. {MID_MNY_P2P_CHNL_REQ, p2pFsmRunEventChannelRequest},
  507. {MID_MNY_P2P_CHNL_ABORT, p2pFsmRunEventChannelAbort},
  508. {MID_MNY_P2P_MGMT_TX, p2pFsmRunEventMgmtFrameTx},
  509. {MID_MNY_P2P_GROUP_DISSOLVE, p2pFsmRunEventDissolve},
  510. {MID_MNY_P2P_MGMT_FRAME_REGISTER, p2pFsmRunEventMgmtFrameRegister},
  511. {MID_MNY_P2P_NET_DEV_REGISTER, p2pFsmRunEventNetDeviceRegister},
  512. {MID_MNY_P2P_START_AP, p2pFsmRunEventStartAP},
  513. {MID_MNY_P2P_MGMT_FRAME_UPDATE, p2pFsmRunEventUpdateMgmtFrame},
  514. #if CFG_SUPPORT_WFD
  515. {MID_MNY_P2P_WFD_CFG_UPDATE, p2pFsmRunEventWfdSettingUpdate},
  516. #endif
  517. #endif
  518. #if CFG_SUPPORT_ADHOC
  519. {MID_SCN_AIS_FOUND_IBSS, aisFsmRunEventFoundIBSSPeer},
  520. #endif /* CFG_SUPPORT_ADHOC */
  521. {MID_SAA_AIS_FSM_ABORT, aisFsmRunEventAbort},
  522. {MID_MNY_AIS_REMAIN_ON_CHANNEL, aisFsmRunEventRemainOnChannel},
  523. {MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL, aisFsmRunEventCancelRemainOnChannel},
  524. {MID_MNY_AIS_MGMT_TX, aisFsmRunEventMgmtFrameTx}
  525. };
  526. /*******************************************************************************
  527. * M A C R O S
  528. ********************************************************************************
  529. */
  530. #if DBG
  531. #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
  532. ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
  533. if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
  534. DBGLOG(CNM, LOUD, "DO MSG [%d: %s]\n", prMsg->eMsgId, apucDebugMsg[prMsg->eMsgId]); \
  535. arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
  536. } \
  537. else { \
  538. DBGLOG(CNM, ERROR, "NULL fptr for MSG [%d]\n", prMsg->eMsgId); \
  539. cnmMemFree(prAdapter, prMsg); \
  540. } \
  541. } while (0)
  542. #else
  543. #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
  544. ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
  545. if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
  546. DBGLOG(CNM, LOUD, "DO MSG [%d]\n", prMsg->eMsgId); \
  547. arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
  548. } \
  549. else { \
  550. DBGLOG(CNM, ERROR, "NULL fptr for MSG [%d]\n", prMsg->eMsgId); \
  551. cnmMemFree(prAdapter, prMsg); \
  552. } \
  553. } while (0)
  554. #endif
  555. /*******************************************************************************
  556. * F U N C T I O N D E C L A R A T I O N S
  557. ********************************************************************************
  558. */
  559. /*******************************************************************************
  560. * F U N C T I O N S
  561. ********************************************************************************
  562. */
  563. /*----------------------------------------------------------------------------*/
  564. /*!
  565. * \brief
  566. *
  567. * \param[in]
  568. *
  569. * \return none
  570. */
  571. /*----------------------------------------------------------------------------*/
  572. VOID mboxInitMsgMap(VOID)
  573. {
  574. UINT_32 i, idx;
  575. MSG_HNDL_ENTRY_T rTempEntry;
  576. ASSERT((sizeof(arMsgMapTable) / sizeof(MSG_HNDL_ENTRY_T)) == MID_TOTAL_NUM);
  577. for (i = 0; i < MID_TOTAL_NUM; i++) {
  578. if (arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i)
  579. continue;
  580. for (idx = i + 1; idx < MID_TOTAL_NUM; idx++) {
  581. if (arMsgMapTable[idx].eMsgId == (ENUM_MSG_ID_T) i)
  582. break;
  583. }
  584. ASSERT(idx < MID_TOTAL_NUM);
  585. if (idx >= MID_TOTAL_NUM)
  586. continue;
  587. /* Swap target entry and current entry */
  588. rTempEntry.eMsgId = arMsgMapTable[idx].eMsgId;
  589. rTempEntry.pfMsgHndl = arMsgMapTable[idx].pfMsgHndl;
  590. arMsgMapTable[idx].eMsgId = arMsgMapTable[i].eMsgId;
  591. arMsgMapTable[idx].pfMsgHndl = arMsgMapTable[i].pfMsgHndl;
  592. arMsgMapTable[i].eMsgId = rTempEntry.eMsgId;
  593. arMsgMapTable[i].pfMsgHndl = rTempEntry.pfMsgHndl;
  594. }
  595. /* Verify the correctness of final message map */
  596. for (i = 0; i < MID_TOTAL_NUM; i++) {
  597. ASSERT(arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i);
  598. while (arMsgMapTable[i].eMsgId != (ENUM_MSG_ID_T) i)
  599. ;
  600. }
  601. }
  602. /*----------------------------------------------------------------------------*/
  603. /*!
  604. * \brief
  605. *
  606. * \param[in]
  607. *
  608. * \return none
  609. */
  610. /*----------------------------------------------------------------------------*/
  611. VOID mboxSetup(IN P_ADAPTER_T prAdapter, IN ENUM_MBOX_ID_T eMboxId)
  612. {
  613. P_MBOX_T prMbox;
  614. KAL_SPIN_LOCK_DECLARATION();
  615. ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
  616. ASSERT(prAdapter);
  617. prMbox = &(prAdapter->arMbox[eMboxId]);
  618. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  619. LINK_INITIALIZE(&prMbox->rLinkHead);
  620. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  621. }
  622. /*----------------------------------------------------------------------------*/
  623. /*!
  624. * \brief
  625. *
  626. * \param[in]
  627. *
  628. * \return none
  629. */
  630. /*----------------------------------------------------------------------------*/
  631. VOID
  632. mboxSendMsg(IN P_ADAPTER_T prAdapter,
  633. IN ENUM_MBOX_ID_T eMboxId, IN P_MSG_HDR_T prMsg, IN EUNM_MSG_SEND_METHOD_T eMethod)
  634. {
  635. P_MBOX_T prMbox;
  636. KAL_SPIN_LOCK_DECLARATION();
  637. ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
  638. ASSERT(prMsg);
  639. ASSERT(prAdapter);
  640. prMbox = &(prAdapter->arMbox[eMboxId]);
  641. switch (eMethod) {
  642. case MSG_SEND_METHOD_BUF:
  643. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  644. LINK_INSERT_TAIL(&prMbox->rLinkHead, &prMsg->rLinkEntry);
  645. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  646. /* to wake up main service thread */
  647. GLUE_SET_EVENT(prAdapter->prGlueInfo);
  648. break;
  649. case MSG_SEND_METHOD_UNBUF:
  650. MBOX_HNDL_MSG(prAdapter, prMsg);
  651. break;
  652. default:
  653. ASSERT(0);
  654. break;
  655. }
  656. }
  657. /*----------------------------------------------------------------------------*/
  658. /*!
  659. * \brief
  660. *
  661. * \param[in]
  662. *
  663. * \return none
  664. */
  665. /*----------------------------------------------------------------------------*/
  666. VOID mboxRcvAllMsg(IN P_ADAPTER_T prAdapter, ENUM_MBOX_ID_T eMboxId)
  667. {
  668. P_MBOX_T prMbox;
  669. P_MSG_HDR_T prMsg;
  670. KAL_SPIN_LOCK_DECLARATION();
  671. ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
  672. ASSERT(prAdapter);
  673. prMbox = &(prAdapter->arMbox[eMboxId]);
  674. while (!LINK_IS_EMPTY(&prMbox->rLinkHead)) {
  675. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  676. LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
  677. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  678. ASSERT(prMsg);
  679. MBOX_HNDL_MSG(prAdapter, prMsg);
  680. }
  681. }
  682. /*----------------------------------------------------------------------------*/
  683. /*!
  684. * \brief
  685. *
  686. * \param[in]
  687. *
  688. * \return none
  689. */
  690. /*----------------------------------------------------------------------------*/
  691. VOID mboxInitialize(IN P_ADAPTER_T prAdapter)
  692. {
  693. UINT_32 i;
  694. ASSERT(prAdapter);
  695. /* Initialize Mailbox */
  696. mboxInitMsgMap();
  697. /* Setup/initialize each mailbox */
  698. for (i = 0; i < MBOX_ID_TOTAL_NUM; i++)
  699. mboxSetup(prAdapter, i);
  700. }
  701. /*----------------------------------------------------------------------------*/
  702. /*!
  703. * \brief
  704. *
  705. * \param[in]
  706. *
  707. * \return none
  708. */
  709. /*----------------------------------------------------------------------------*/
  710. VOID mboxDestroy(IN P_ADAPTER_T prAdapter)
  711. {
  712. P_MBOX_T prMbox;
  713. P_MSG_HDR_T prMsg;
  714. UINT_8 i;
  715. KAL_SPIN_LOCK_DECLARATION();
  716. ASSERT(prAdapter);
  717. for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
  718. prMbox = &(prAdapter->arMbox[i]);
  719. while (!LINK_IS_EMPTY(&prMbox->rLinkHead)) {
  720. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  721. LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
  722. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
  723. ASSERT(prMsg);
  724. cnmMemFree(prAdapter, prMsg);
  725. }
  726. }
  727. }
  728. /*----------------------------------------------------------------------------*/
  729. /*!
  730. * \brief This is dummy function to prevent empty arMsgMapTable[] for compiling.
  731. *
  732. * \param[in]
  733. *
  734. * \return none
  735. */
  736. /*----------------------------------------------------------------------------*/
  737. VOID mboxDummy(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  738. {
  739. ASSERT(prAdapter);
  740. cnmMemFree(prAdapter, prMsgHdr);
  741. }