hem_mbox.c 27 KB

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