2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/hem_mbox.c#3 $
15 ** 08 31 2012 yuche.tsai
16 ** [ALPS00349585] [6577JB][WiFi direct][KE]Establish p2p connection while both device have connected to AP previously,one device reboots automatically with KE
17 ** Fix possible KE when concurrent & disconnect.
19 ** 07 26 2012 yuche.tsai
20 ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
21 ** Update driver code of ALPS.JB for hot-spot.
23 ** 07 19 2012 yuche.tsai
25 ** Code update for JB.
27 * 07 17 2012 yuche.tsai
29 * Compile no error before trial run.
32 * [WCXRP00001231] [MT6620 Wi-Fi][MT5931][Driver] Correct SCAN_V2 related debugging facilities within hem_mbox.c
33 * correct for debug message string table by adding missed scan_v2 related definitions.
37 * Sync CFG80211 modification from branch 2,2.
39 * 01 17 2012 yuche.tsai
41 * Update mgmt frame filter setting.
42 * Please also update FW 2.1
44 * 01 13 2012 yuche.tsai
46 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
49 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
50 * Adjust code for DBG and CONFIG_XLOG.
54 * Add exception handle for NULL function pointer of mailbox message
57 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
58 * modify the xlog related code.
61 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
62 * adding the code for XLOG.
65 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
66 * add framework in driver domain for supporting new SCAN_REQ_V2 for more than 1 SSID support as well as uProbeDelay in NDIS 6.x driver model
68 * 06 07 2011 yuche.tsai
69 * [WCXRP00000696] [Volunteer Patch][MT6620][Driver] Infinite loop issue when RX invitation response.[WCXRP00000763] [Volunteer Patch][MT6620][Driver] RX Service Discovery Frame under AP mode Issue
70 * Add invitation support.
73 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
74 * Remove flag CFG_WIFI_DIRECT_MOVED.
77 * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
81 * [WCXRP00000490] [MT6620 Wi-Fi][Driver][Win32] modify kalMsleep() implementation 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
84 * 02 15 2011 chinghwa.yu
85 * [WCXRP00000065] Update BoW design and settings
86 * Update bowString and channel grant.
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
92 * 01 26 2011 yuche.tsai
93 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
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.
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
106 * 12 08 2010 chinghwa.yu
107 * [WCXRP00000065] Update BoW design and settings
108 * Support concurrent networks.
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
115 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate from firmware auto rate module
116 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
117 * 2) Remove CNM CH-RECOVER event handling
118 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
121 * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
122 * update the frog's new p2p state machine.
126 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
128 * 09 16 2010 cm.chang
130 * Remove unused message ID
134 * eliminate klockwork errors
136 * 08 26 2010 yuche.tsai
138 * Add P2P Connection Abort Event Message handler.
140 * 08 25 2010 george.huang
142 * update OID/ registry control path for PM related settings
144 * 08 24 2010 yarco.yang
146 * Fixed Driver ASSERT at mboxInitMsgMap()
148 * 08 24 2010 chinghwa.yu
150 * Update for MID_SCN_BOW_SCAN_DONE mboxDummy.
151 * Update saa_fsm for BOW.
153 * 08 23 2010 chinghwa.yu
155 * Add CFG_ENABLE_BT_OVER_WIFI.
157 * 08 23 2010 chinghwa.yu
163 * add interface for RLM to trigger OBSS-SCAN.
165 * 08 16 2010 yuche.tsai
167 * Add debug message for newly add P2P message.
169 * 08 11 2010 yuche.tsai
171 * Add some function entry for P2P FSM under provisioning phase..
173 * 08 11 2010 yuche.tsai
175 * Add some events to P2P Module.
177 * 08 05 2010 yuche.tsai
179 * Add message box event for P2P device switch on & device discovery.
183 * remove unused mailbox message definitions.
185 * 08 02 2010 yuche.tsai
187 * P2P Group Negotiation Code Check in.
191 * [WPD00003833] [MT6620 and MT5931] Driver migration.
192 * message table should not be commented out by compilation option without modifying header file
196 * [WPD00003833] [MT6620 and MT5931] Driver migration.
197 * Add Ad-Hoc support to AIS-FSM
199 * 07 19 2010 yuche.tsai
201 * Add wifi direct scan done callback.
205 * change handler of MID_MNY_CNM_CONNECTION_ABORT from NULL to mboxDummy.
209 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
211 * 07 08 2010 cm.chang
212 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
213 * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
216 * [WPD00003833][MT6620 and MT5931] Driver migration
217 * AIS-FSM integration with CNM channel request messages
220 * [WPD00003833][MT6620 and MT5931] Driver migration
221 * implementation of DRV-SCN and related mailbox message handling.
223 * 07 01 2010 cm.chang
224 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
225 * Modify CNM message handler for new flow
228 * [WPD00003833][MT6620 and MT5931] Driver migration
229 * enable currently migrated message call-backs.
232 * [WPD00003833][MT6620 and MT5931] Driver migration
233 * restore utility function invoking via hem_mbox to direct calls
236 * [WPD00003833][MT6620 and MT5931] Driver migration
237 * add buildable & linkable ais_fsm.c
239 * related reference are still waiting to be resolved
242 * [WPD00003833][MT6620 and MT5931] Driver migration
243 * hem_mbox is migrated.
246 * [WPD00003833][MT6620 and MT5931] Driver migration
247 * add hem_mbox.c and cnm_mem.h (but disabled some feature) for further migration
249 * 05 12 2010 kevin.huang
250 * [BORA00000794][WIFISYS][New Feature]Power Management Support
251 * Fix file merge error
253 * 05 12 2010 kevin.huang
254 * [BORA00000794][WIFISYS][New Feature]Power Management Support
255 * Add Power Management - Legacy PS-POLL support.
257 * 04 29 2010 tehuang.liu
258 * [BORA00000605][WIFISYS] Phase3 Integration
259 * Removed MID_RXM_MQM_QOS_ACTION_FRAME
261 * 04 29 2010 tehuang.liu
262 * [BORA00000605][WIFISYS] Phase3 Integration
263 * Removed MID_RXM_MQM_BA_ACTION_FRAME
265 * 04 27 2010 tehuang.liu
266 * [BORA00000605][WIFISYS] Phase3 Integration
267 * MID_RXM_MQM_BA_ACTION_FRAME
269 * 03 30 2010 cm.chang
270 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
271 * Support 2.4G OBSS scan
273 * 03 16 2010 kevin.huang
274 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
277 * 03 10 2010 kevin.huang
278 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
280 * * * * * * * * * * * * * * Add Channel Manager for arbitration of JOIN and SCAN Req
282 * 03 05 2010 cm.chang
283 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
284 * Develop partial DPD code
286 * 02 11 2010 tehuang.liu
287 * [BORA00000569][WIFISYS] Phase 2 Integration Test
288 * Updated arMsgMapTable for MID_RXM_MQM_QOS_ACTION_FRAME
290 * 01 11 2010 kevin.huang
291 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
292 * Add Deauth and Disassoc Handler
294 * Dec 9 2009 mtk01461
295 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
296 * Add hemRunEventScanDone() to arMsgMapTable[]
298 * Dec 4 2009 mtk01461
299 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
300 * Fix mboxDummy() didn't free prMsgHdr
302 * Dec 3 2009 mtk01461
303 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
304 * Add saaAisJoinComplete event handler
306 * Dec 2 2009 MTK02468
307 * [BORA00000337] To check in codes for FPGA emulation
308 * Fixed the handler function name in arMsgMapTable for MID_RXM_MQM_BA_ACTION_FRAME
310 * Dec 2 2009 MTK02468
311 * [BORA00000337] To check in codes for FPGA emulation
312 * Added MID_RXM_MQM_BA_ACTION_FRAME to MsgMapTable
314 * Nov 23 2009 mtk01461
315 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
316 * Revise MSG Handler (remove dummy and add for SAA)
318 * Nov 16 2009 mtk01461
319 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
320 * Add aisFsmRunEventAbort() event handler
322 * Nov 11 2009 mtk01461
323 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
326 * Nov 10 2009 mtk01461
327 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
328 * Add more MSG_HNDL_ENTRY_T to avoid ASSERT() in mboxInitMsgMap()
330 * Nov 5 2009 mtk01461
331 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
332 * Add SCN message and function entry to arMsgMapTable[]
334 * Nov 2 2009 mtk01104
335 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
336 * Fix sorting algorithm in mboxInitMsgMap()
338 * Oct 28 2009 mtk01104
339 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
344 /*******************************************************************************
345 * C O M P I L E R F L A G S
346 ********************************************************************************
349 /*******************************************************************************
350 * E X T E R N A L R E F E R E N C E S
351 ********************************************************************************
355 /*******************************************************************************
357 ********************************************************************************
360 /*******************************************************************************
362 ********************************************************************************
365 /*******************************************************************************
366 * P U B L I C D A T A
367 ********************************************************************************
370 /*******************************************************************************
371 * P R I V A T E D A T A
372 ********************************************************************************
375 /*lint -save -e64 Type mismatch */
376 static PUINT_8 apucDebugMsg[] = {
377 (PUINT_8)DISP_STRING("MID_MNY_CNM_CH_REQ"),
378 (PUINT_8)DISP_STRING("MID_MNY_CNM_CH_ABORT"),
379 (PUINT_8)DISP_STRING("MID_CNM_AIS_CH_GRANT"),
380 (PUINT_8)DISP_STRING("MID_CNM_P2P_CH_GRANT"),
381 (PUINT_8)DISP_STRING("MID_CNM_BOW_CH_GRANT"),
383 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_REQ"),
384 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_REQ_V2"),
385 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_CANCEL"),
386 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_REQ"),
387 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_REQ_V2"),
388 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_CANCEL"),
389 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_REQ"),
390 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_REQ_V2"),
391 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_CANCEL"),
392 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_REQ"),
393 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_REQ_V2"),
394 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_CANCEL"),
395 (PUINT_8)DISP_STRING("MID_SCN_AIS_SCAN_DONE"),
396 (PUINT_8)DISP_STRING("MID_SCN_P2P_SCAN_DONE"),
397 (PUINT_8)DISP_STRING("MID_SCN_BOW_SCAN_DONE"),
398 (PUINT_8)DISP_STRING("MID_SCN_RLM_SCAN_DONE"),
400 (PUINT_8)DISP_STRING("MID_OID_AIS_FSM_JOIN_REQ"),
401 (PUINT_8)DISP_STRING("MID_OID_AIS_FSM_ABORT"),
402 (PUINT_8)DISP_STRING("MID_AIS_SAA_FSM_START"),
403 (PUINT_8)DISP_STRING("MID_AIS_SAA_FSM_ABORT"),
404 (PUINT_8)DISP_STRING("MID_SAA_AIS_JOIN_COMPLETE"),
406 #if CFG_ENABLE_BT_OVER_WIFI
407 (PUINT_8)DISP_STRING("MID_BOW_SAA_FSM_START"),
408 (PUINT_8)DISP_STRING("MID_BOW_SAA_FSM_ABORT"),
409 (PUINT_8)DISP_STRING("MID_SAA_BOW_JOIN_COMPLETE"),
412 #if CFG_ENABLE_WIFI_DIRECT
413 (PUINT_8)DISP_STRING("MID_P2P_SAA_FSM_START"),
414 (PUINT_8)DISP_STRING("MID_P2P_SAA_FSM_ABORT"),
415 (PUINT_8)DISP_STRING("MID_SAA_P2P_JOIN_COMPLETE"),
417 (PUINT_8)DISP_STRING("MID_MNY_P2P_FUN_SWITCH"),
418 (PUINT_8)DISP_STRING("MID_MNY_P2P_DEVICE_DISCOVERY"),
419 (PUINT_8)DISP_STRING("MID_MNY_P2P_CONNECTION_REQ"),
420 (PUINT_8)DISP_STRING("MID_MNY_P2P_CONNECTION_ABORT"),
421 (PUINT_8)DISP_STRING("MID_MNY_P2P_BEACON_UPDATE"),
422 (PUINT_8)DISP_STRING("MID_MNY_P2P_STOP_AP"),
423 (PUINT_8)DISP_STRING("MID_MNY_P2P_CHNL_REQ"),
424 (PUINT_8)DISP_STRING("MID_MNY_P2P_CHNL_ABORT"),
425 (PUINT_8)DISP_STRING("MID_MNY_P2P_MGMT_TX"),
426 (PUINT_8)DISP_STRING("MID_MNY_P2P_GROUP_DISSOLVE"),
427 (PUINT_8)DISP_STRING("MID_MNY_P2P_MGMT_FRAME_REGISTER"),
428 (PUINT_8)DISP_STRING("MID_MNY_P2P_NET_DEV_REGISTER"),
429 (PUINT_8)DISP_STRING("MID_MNY_P2P_START_AP"),
430 (PUINT_8)DISP_STRING("MID_MNY_P2P_UPDATE_IE_BUF"),
433 #if CFG_SUPPORT_ADHOC
434 //(PUINT_8)DISP_STRING("MID_AIS_CNM_CREATE_IBSS_REQ"),
435 //(PUINT_8)DISP_STRING("MID_CNM_AIS_CREATE_IBSS_GRANT"),
436 //(PUINT_8)DISP_STRING("MID_AIS_CNM_MERGE_IBSS_REQ"),
437 //(PUINT_8)DISP_STRING("MID_CNM_AIS_MERGE_IBSS_GRANT"),
438 (PUINT_8)DISP_STRING("MID_SCN_AIS_FOUND_IBSS"),
439 #endif /* CFG_SUPPORT_ADHOC */
441 (PUINT_8)DISP_STRING("MID_SAA_AIS_FSM_ABORT")
446 /* This message entry will be re-ordered based on the message ID order
447 * by invoking mboxInitMsgMap()
449 static MSG_HNDL_ENTRY_T arMsgMapTable[] = {
450 { MID_MNY_CNM_CH_REQ, cnmChMngrRequestPrivilege },
451 { MID_MNY_CNM_CH_ABORT, cnmChMngrAbortPrivilege },
452 { MID_CNM_AIS_CH_GRANT, aisFsmRunEventChGrant },
453 #if CFG_ENABLE_WIFI_DIRECT
454 { MID_CNM_P2P_CH_GRANT, p2pFsmRunEventChGrant }, /*set in gl_p2p_init.c*/
456 { MID_CNM_P2P_CH_GRANT, mboxDummy },
459 #if CFG_ENABLE_BT_OVER_WIFI
460 { MID_CNM_BOW_CH_GRANT, bowRunEventChGrant },
462 { MID_CNM_BOW_CH_GRANT, mboxDummy },
465 /*--------------------------------------------------*/
466 /* SCN Module Mailbox Messages */
467 /*--------------------------------------------------*/
468 { MID_AIS_SCN_SCAN_REQ, scnFsmMsgStart },
469 { MID_AIS_SCN_SCAN_REQ_V2, scnFsmMsgStart },
470 { MID_AIS_SCN_SCAN_CANCEL, scnFsmMsgAbort },
471 { MID_P2P_SCN_SCAN_REQ, scnFsmMsgStart },
472 { MID_P2P_SCN_SCAN_REQ_V2, scnFsmMsgStart },
473 { MID_P2P_SCN_SCAN_CANCEL, scnFsmMsgAbort },
474 { MID_BOW_SCN_SCAN_REQ, scnFsmMsgStart },
475 { MID_BOW_SCN_SCAN_REQ_V2, scnFsmMsgStart },
476 { MID_BOW_SCN_SCAN_CANCEL, scnFsmMsgAbort },
477 { MID_RLM_SCN_SCAN_REQ, scnFsmMsgStart },
478 { MID_RLM_SCN_SCAN_REQ_V2, scnFsmMsgStart },
479 { MID_RLM_SCN_SCAN_CANCEL, scnFsmMsgAbort },
480 { MID_SCN_AIS_SCAN_DONE, aisFsmRunEventScanDone },
481 #if CFG_ENABLE_WIFI_DIRECT
482 { MID_SCN_P2P_SCAN_DONE, p2pFsmRunEventScanDone }, /*set in gl_p2p_init.c*/
484 { MID_SCN_P2P_SCAN_DONE, mboxDummy },
487 #if CFG_ENABLE_BT_OVER_WIFI
488 { MID_SCN_BOW_SCAN_DONE, bowResponderScanDone },
490 { MID_SCN_BOW_SCAN_DONE, mboxDummy },
492 { MID_SCN_RLM_SCAN_DONE, rlmObssScanDone },
494 /*--------------------------------------------------*/
495 /* AIS Module Mailbox Messages */
496 /*--------------------------------------------------*/
497 { MID_OID_AIS_FSM_JOIN_REQ, aisFsmRunEventAbort },
498 { MID_OID_AIS_FSM_ABORT, aisFsmRunEventAbort },
499 { MID_AIS_SAA_FSM_START, saaFsmRunEventStart },
500 { MID_AIS_SAA_FSM_ABORT, saaFsmRunEventAbort },
501 { MID_SAA_AIS_JOIN_COMPLETE, aisFsmRunEventJoinComplete },
503 #if CFG_ENABLE_BT_OVER_WIFI
504 /*--------------------------------------------------*/
505 /* BOW Module Mailbox Messages */
506 /*--------------------------------------------------*/
507 { MID_BOW_SAA_FSM_START, saaFsmRunEventStart },
508 { MID_BOW_SAA_FSM_ABORT, saaFsmRunEventAbort },
509 { MID_SAA_BOW_JOIN_COMPLETE, bowFsmRunEventJoinComplete },
512 #if CFG_ENABLE_WIFI_DIRECT /*set in gl_p2p_init.c*/
513 { MID_P2P_SAA_FSM_START, saaFsmRunEventStart },
514 { MID_P2P_SAA_FSM_ABORT, saaFsmRunEventAbort },
515 { MID_SAA_P2P_JOIN_COMPLETE, p2pFsmRunEventJoinComplete },// TODO: p2pFsmRunEventJoinComplete
517 { MID_MNY_P2P_FUN_SWITCH, p2pFsmRunEventSwitchOPMode },
518 { MID_MNY_P2P_DEVICE_DISCOVERY, p2pFsmRunEventScanRequest },
519 { MID_MNY_P2P_CONNECTION_REQ, p2pFsmRunEventConnectionRequest },
520 { MID_MNY_P2P_CONNECTION_ABORT, p2pFsmRunEventConnectionAbort },
521 { MID_MNY_P2P_BEACON_UPDATE, p2pFsmRunEventBeaconUpdate },
522 { MID_MNY_P2P_STOP_AP, p2pFsmRunEventStopAP },
523 { MID_MNY_P2P_CHNL_REQ, p2pFsmRunEventChannelRequest },
524 { MID_MNY_P2P_CHNL_ABORT, p2pFsmRunEventChannelAbort },
525 { MID_MNY_P2P_MGMT_TX, p2pFsmRunEventMgmtFrameTx },
526 { MID_MNY_P2P_GROUP_DISSOLVE, p2pFsmRunEventDissolve },
527 { MID_MNY_P2P_MGMT_FRAME_REGISTER, p2pFsmRunEventMgmtFrameRegister },
528 { MID_MNY_P2P_NET_DEV_REGISTER, p2pFsmRunEventNetDeviceRegister },
529 { MID_MNY_P2P_START_AP, p2pFsmRunEventStartAP },
530 { MID_MNY_P2P_MGMT_FRAME_UPDATE, p2pFsmRunEventUpdateMgmtFrame },
533 #if CFG_SUPPORT_ADHOC
534 { MID_SCN_AIS_FOUND_IBSS, aisFsmRunEventFoundIBSSPeer },
535 #endif /* CFG_SUPPORT_ADHOC */
537 { MID_SAA_AIS_FSM_ABORT, aisFsmRunEventAbort }
540 /*******************************************************************************
542 ********************************************************************************
546 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
547 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
548 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
549 DBGLOG(CNM, LOUD, ("DO MSG [%d: %s]\n", prMsg->eMsgId, apucDebugMsg[prMsg->eMsgId])); \
550 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
553 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
554 cnmMemFree(prAdapter, prMsg); \
558 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
559 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
560 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
561 DBGLOG(CNM, LOUD, ("DO MSG [%d]\n", prMsg->eMsgId)); \
562 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
565 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
566 cnmMemFree(prAdapter, prMsg); \
570 /*******************************************************************************
571 * F U N C T I O N D E C L A R A T I O N S
572 ********************************************************************************
575 /*******************************************************************************
577 ********************************************************************************
581 /*----------------------------------------------------------------------------*/
589 /*----------------------------------------------------------------------------*/
596 MSG_HNDL_ENTRY_T rTempEntry;
598 ASSERT((sizeof(arMsgMapTable) / sizeof(MSG_HNDL_ENTRY_T)) == MID_TOTAL_NUM);
600 for (i = 0; i < MID_TOTAL_NUM; i++) {
601 if (arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i) {
604 for (idx = i + 1; idx < MID_TOTAL_NUM; idx++) {
605 if (arMsgMapTable[idx].eMsgId == (ENUM_MSG_ID_T) i) {
609 ASSERT(idx < MID_TOTAL_NUM);
610 if (idx >= MID_TOTAL_NUM) {
614 /* Swap target entry and current entry */
615 rTempEntry.eMsgId = arMsgMapTable[idx].eMsgId;
616 rTempEntry.pfMsgHndl= arMsgMapTable[idx].pfMsgHndl;
618 arMsgMapTable[idx].eMsgId = arMsgMapTable[i].eMsgId;
619 arMsgMapTable[idx].pfMsgHndl = arMsgMapTable[i].pfMsgHndl;
621 arMsgMapTable[i].eMsgId = rTempEntry.eMsgId;
622 arMsgMapTable[i].pfMsgHndl = rTempEntry.pfMsgHndl;
625 /* Verify the correctness of final message map */
626 for (i = 0; i < MID_TOTAL_NUM; i++) {
627 ASSERT(arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i);
628 while (arMsgMapTable[i].eMsgId != (ENUM_MSG_ID_T) i);
633 /*----------------------------------------------------------------------------*/
641 /*----------------------------------------------------------------------------*/
644 IN P_ADAPTER_T prAdapter,
645 IN ENUM_MBOX_ID_T eMboxId
649 KAL_SPIN_LOCK_DECLARATION();
651 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
654 prMbox = &(prAdapter->arMbox[eMboxId]);
656 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
657 LINK_INITIALIZE(&prMbox->rLinkHead);
658 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
661 /*----------------------------------------------------------------------------*/
669 /*----------------------------------------------------------------------------*/
672 IN P_ADAPTER_T prAdapter,
673 IN ENUM_MBOX_ID_T eMboxId,
674 IN P_MSG_HDR_T prMsg,
675 IN EUNM_MSG_SEND_METHOD_T eMethod
679 KAL_SPIN_LOCK_DECLARATION();
681 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
685 prMbox = &(prAdapter->arMbox[eMboxId]);
688 case MSG_SEND_METHOD_BUF:
689 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
690 LINK_INSERT_TAIL(&prMbox->rLinkHead, &prMsg->rLinkEntry);
691 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
693 // to wake up main service thread
694 GLUE_SET_EVENT(prAdapter->prGlueInfo);
698 case MSG_SEND_METHOD_UNBUF:
699 MBOX_HNDL_MSG(prAdapter, prMsg);
708 /*----------------------------------------------------------------------------*/
716 /*----------------------------------------------------------------------------*/
719 IN P_ADAPTER_T prAdapter,
720 ENUM_MBOX_ID_T eMboxId
725 KAL_SPIN_LOCK_DECLARATION();
727 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
730 prMbox = &(prAdapter->arMbox[eMboxId]);
732 while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) {
733 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
734 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
735 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
738 MBOX_HNDL_MSG(prAdapter, prMsg);
743 /*----------------------------------------------------------------------------*/
751 /*----------------------------------------------------------------------------*/
754 IN P_ADAPTER_T prAdapter
761 /* Initialize Mailbox */
764 /* Setup/initialize each mailbox */
765 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
766 mboxSetup(prAdapter, i);
771 /*----------------------------------------------------------------------------*/
779 /*----------------------------------------------------------------------------*/
782 IN P_ADAPTER_T prAdapter
788 KAL_SPIN_LOCK_DECLARATION();
792 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
793 prMbox = &(prAdapter->arMbox[i]);
795 while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) {
796 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
797 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
798 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
801 cnmMemFree(prAdapter, prMsg);
806 /*----------------------------------------------------------------------------*/
808 * \brief This is dummy function to prevent empty arMsgMapTable[] for compiling.
814 /*----------------------------------------------------------------------------*/
817 IN P_ADAPTER_T prAdapter,
818 IN P_MSG_HDR_T prMsgHdr
823 cnmMemFree(prAdapter, prMsgHdr);