2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_WIFI_DRIVER_V2_3/mgmt/hem_mbox.c#1 $
10 /*******************************************************************************
11 * Copyright (c) 2009 MediaTek Inc.
13 * All rights reserved. Copying, compilation, modification, distribution
14 * or any other use whatsoever of this material is strictly prohibited
15 * except in accordance with a Software License Agreement with
17 ********************************************************************************
20 /*******************************************************************************
23 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
24 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
25 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
26 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
27 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
28 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
29 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
30 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
31 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
32 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
33 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
34 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
35 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
37 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
38 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
39 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
40 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
41 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
43 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
44 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
45 * OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
46 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
47 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
49 ********************************************************************************
56 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
60 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
61 ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
63 ** 07 24 2012 yuche.tsai
67 ** 07 24 2012 yuche.tsai
71 ** 07 19 2012 yuche.tsai
73 ** Code update for JB.
75 * 07 17 2012 yuche.tsai
77 * Compile no error before trial run.
80 * [WCXRP00001231] [MT6620 Wi-Fi][MT5931][Driver] Correct SCAN_V2 related debugging facilities within hem_mbox.c
81 * correct for debug message string table by adding missed scan_v2 related definitions.
85 * Sync CFG80211 modification from branch 2,2.
87 * 01 17 2012 yuche.tsai
89 * Update mgmt frame filter setting.
90 * Please also update FW 2.1
92 * 01 13 2012 yuche.tsai
94 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
97 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
98 * Adjust code for DBG and CONFIG_XLOG.
100 * 11 15 2011 cm.chang
102 * Add exception handle for NULL function pointer of mailbox message
105 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
106 * modify the xlog related code.
109 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
110 * adding the code for XLOG.
113 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
114 * 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
116 * 06 07 2011 yuche.tsai
117 * [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
118 * Add invitation support.
120 * 04 18 2011 terry.wu
121 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
122 * Remove flag CFG_WIFI_DIRECT_MOVED.
124 * 03 29 2011 cm.chang
125 * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
129 * [WCXRP00000490] [MT6620 Wi-Fi][Driver][Win32] modify kalMsleep() implementation because NdisMSleep() won't sleep long enough for specified interval such as 500ms
130 * modify cnm_timer and hem_mbox APIs to be thread safe to ease invoking restrictions
132 * 02 15 2011 chinghwa.yu
133 * [WCXRP00000065] Update BoW design and settings
134 * Update bowString and channel grant.
136 * 01 26 2011 cm.chang
137 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
138 * Allocate system RAM if fixed message or mgmt buffer is not available
140 * 01 26 2011 yuche.tsai
141 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
144 * 01 25 2011 yuche.tsai
145 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
146 * Fix Compile Error when DBG is disabled.
149 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
150 * 1. add an extra counter for tracking pending forward frames.
151 * 2. notify TX service thread as well when there is pending forward frame
152 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
154 * 12 08 2010 chinghwa.yu
155 * [WCXRP00000065] Update BoW design and settings
156 * Support concurrent networks.
158 * 11 08 2010 cm.chang
159 * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID
160 * Remove CNM channel reover message ID
163 * [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
164 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
165 * 2) Remove CNM CH-RECOVER event handling
166 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
169 * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
170 * update the frog's new p2p state machine.
174 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
176 * 09 16 2010 cm.chang
178 * Remove unused message ID
182 * eliminate klockwork errors
184 * 08 26 2010 yuche.tsai
186 * Add P2P Connection Abort Event Message handler.
188 * 08 25 2010 george.huang
190 * update OID/ registry control path for PM related settings
192 * 08 24 2010 yarco.yang
194 * Fixed Driver ASSERT at mboxInitMsgMap()
196 * 08 24 2010 chinghwa.yu
198 * Update for MID_SCN_BOW_SCAN_DONE mboxDummy.
199 * Update saa_fsm for BOW.
201 * 08 23 2010 chinghwa.yu
203 * Add CFG_ENABLE_BT_OVER_WIFI.
205 * 08 23 2010 chinghwa.yu
211 * add interface for RLM to trigger OBSS-SCAN.
213 * 08 16 2010 yuche.tsai
215 * Add debug message for newly add P2P message.
217 * 08 11 2010 yuche.tsai
219 * Add some function entry for P2P FSM under provisioning phase..
221 * 08 11 2010 yuche.tsai
223 * Add some events to P2P Module.
225 * 08 05 2010 yuche.tsai
227 * Add message box event for P2P device switch on & device discovery.
231 * remove unused mailbox message definitions.
233 * 08 02 2010 yuche.tsai
235 * P2P Group Negotiation Code Check in.
239 * [WPD00003833] [MT6620 and MT5931] Driver migration.
240 * message table should not be commented out by compilation option without modifying header file
244 * [WPD00003833] [MT6620 and MT5931] Driver migration.
245 * Add Ad-Hoc support to AIS-FSM
247 * 07 19 2010 yuche.tsai
249 * Add wifi direct scan done callback.
253 * change handler of MID_MNY_CNM_CONNECTION_ABORT from NULL to mboxDummy.
257 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
259 * 07 08 2010 cm.chang
260 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
261 * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
264 * [WPD00003833][MT6620 and MT5931] Driver migration
265 * AIS-FSM integration with CNM channel request messages
268 * [WPD00003833][MT6620 and MT5931] Driver migration
269 * implementation of DRV-SCN and related mailbox message handling.
271 * 07 01 2010 cm.chang
272 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
273 * Modify CNM message handler for new flow
276 * [WPD00003833][MT6620 and MT5931] Driver migration
277 * enable currently migrated message call-backs.
280 * [WPD00003833][MT6620 and MT5931] Driver migration
281 * restore utility function invoking via hem_mbox to direct calls
284 * [WPD00003833][MT6620 and MT5931] Driver migration
285 * add buildable & linkable ais_fsm.c
287 * related reference are still waiting to be resolved
290 * [WPD00003833][MT6620 and MT5931] Driver migration
291 * hem_mbox is migrated.
294 * [WPD00003833][MT6620 and MT5931] Driver migration
295 * add hem_mbox.c and cnm_mem.h (but disabled some feature) for further migration
297 * 05 12 2010 kevin.huang
298 * [BORA00000794][WIFISYS][New Feature]Power Management Support
299 * Fix file merge error
301 * 05 12 2010 kevin.huang
302 * [BORA00000794][WIFISYS][New Feature]Power Management Support
303 * Add Power Management - Legacy PS-POLL support.
305 * 04 29 2010 tehuang.liu
306 * [BORA00000605][WIFISYS] Phase3 Integration
307 * Removed MID_RXM_MQM_QOS_ACTION_FRAME
309 * 04 29 2010 tehuang.liu
310 * [BORA00000605][WIFISYS] Phase3 Integration
311 * Removed MID_RXM_MQM_BA_ACTION_FRAME
313 * 04 27 2010 tehuang.liu
314 * [BORA00000605][WIFISYS] Phase3 Integration
315 * MID_RXM_MQM_BA_ACTION_FRAME
317 * 03 30 2010 cm.chang
318 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
319 * Support 2.4G OBSS scan
321 * 03 16 2010 kevin.huang
322 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
325 * 03 10 2010 kevin.huang
326 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
328 * * * * * * * * * * * * * * Add Channel Manager for arbitration of JOIN and SCAN Req
330 * 03 05 2010 cm.chang
331 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
332 * Develop partial DPD code
334 * 02 11 2010 tehuang.liu
335 * [BORA00000569][WIFISYS] Phase 2 Integration Test
336 * Updated arMsgMapTable for MID_RXM_MQM_QOS_ACTION_FRAME
338 * 01 11 2010 kevin.huang
339 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
340 * Add Deauth and Disassoc Handler
342 * Dec 9 2009 mtk01461
343 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
344 * Add hemRunEventScanDone() to arMsgMapTable[]
346 * Dec 4 2009 mtk01461
347 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
348 * Fix mboxDummy() didn't free prMsgHdr
350 * Dec 3 2009 mtk01461
351 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
352 * Add saaAisJoinComplete event handler
354 * Dec 2 2009 MTK02468
355 * [BORA00000337] To check in codes for FPGA emulation
356 * Fixed the handler function name in arMsgMapTable for MID_RXM_MQM_BA_ACTION_FRAME
358 * Dec 2 2009 MTK02468
359 * [BORA00000337] To check in codes for FPGA emulation
360 * Added MID_RXM_MQM_BA_ACTION_FRAME to MsgMapTable
362 * Nov 23 2009 mtk01461
363 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
364 * Revise MSG Handler (remove dummy and add for SAA)
366 * Nov 16 2009 mtk01461
367 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
368 * Add aisFsmRunEventAbort() event handler
370 * Nov 11 2009 mtk01461
371 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
374 * Nov 10 2009 mtk01461
375 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
376 * Add more MSG_HNDL_ENTRY_T to avoid ASSERT() in mboxInitMsgMap()
378 * Nov 5 2009 mtk01461
379 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
380 * Add SCN message and function entry to arMsgMapTable[]
382 * Nov 2 2009 mtk01104
383 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
384 * Fix sorting algorithm in mboxInitMsgMap()
386 * Oct 28 2009 mtk01104
387 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
392 /*******************************************************************************
393 * C O M P I L E R F L A G S
394 ********************************************************************************
397 /*******************************************************************************
398 * E X T E R N A L R E F E R E N C E S
399 ********************************************************************************
403 /*******************************************************************************
405 ********************************************************************************
408 /*******************************************************************************
410 ********************************************************************************
413 /*******************************************************************************
414 * P U B L I C D A T A
415 ********************************************************************************
418 /*******************************************************************************
419 * P R I V A T E D A T A
420 ********************************************************************************
423 /*lint -save -e64 Type mismatch */
424 static PUINT_8 apucDebugMsg[] = {
425 (PUINT_8)DISP_STRING("MID_MNY_CNM_CH_REQ"),
426 (PUINT_8)DISP_STRING("MID_MNY_CNM_CH_ABORT"),
427 (PUINT_8)DISP_STRING("MID_CNM_AIS_CH_GRANT"),
428 (PUINT_8)DISP_STRING("MID_CNM_P2P_CH_GRANT"),
429 (PUINT_8)DISP_STRING("MID_CNM_BOW_CH_GRANT"),
431 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_REQ"),
432 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_REQ_V2"),
433 (PUINT_8)DISP_STRING("MID_AIS_SCN_SCAN_CANCEL"),
434 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_REQ"),
435 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_REQ_V2"),
436 (PUINT_8)DISP_STRING("MID_P2P_SCN_SCAN_CANCEL"),
437 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_REQ"),
438 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_REQ_V2"),
439 (PUINT_8)DISP_STRING("MID_BOW_SCN_SCAN_CANCEL"),
440 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_REQ"),
441 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_REQ_V2"),
442 (PUINT_8)DISP_STRING("MID_RLM_SCN_SCAN_CANCEL"),
443 (PUINT_8)DISP_STRING("MID_SCN_AIS_SCAN_DONE"),
444 (PUINT_8)DISP_STRING("MID_SCN_P2P_SCAN_DONE"),
445 (PUINT_8)DISP_STRING("MID_SCN_BOW_SCAN_DONE"),
446 (PUINT_8)DISP_STRING("MID_SCN_RLM_SCAN_DONE"),
448 (PUINT_8)DISP_STRING("MID_OID_AIS_FSM_JOIN_REQ"),
449 (PUINT_8)DISP_STRING("MID_OID_AIS_FSM_ABORT"),
450 (PUINT_8)DISP_STRING("MID_AIS_SAA_FSM_START"),
451 (PUINT_8)DISP_STRING("MID_AIS_SAA_FSM_ABORT"),
452 (PUINT_8)DISP_STRING("MID_SAA_AIS_JOIN_COMPLETE"),
454 #if CFG_ENABLE_BT_OVER_WIFI
455 (PUINT_8)DISP_STRING("MID_BOW_SAA_FSM_START"),
456 (PUINT_8)DISP_STRING("MID_BOW_SAA_FSM_ABORT"),
457 (PUINT_8)DISP_STRING("MID_SAA_BOW_JOIN_COMPLETE"),
460 #if CFG_ENABLE_WIFI_DIRECT
461 (PUINT_8)DISP_STRING("MID_P2P_SAA_FSM_START"),
462 (PUINT_8)DISP_STRING("MID_P2P_SAA_FSM_ABORT"),
463 (PUINT_8)DISP_STRING("MID_SAA_P2P_JOIN_COMPLETE"),
465 (PUINT_8)DISP_STRING("MID_MNY_P2P_FUN_SWITCH"),
466 (PUINT_8)DISP_STRING("MID_MNY_P2P_DEVICE_DISCOVERY"),
467 (PUINT_8)DISP_STRING("MID_MNY_P2P_CONNECTION_REQ"),
468 (PUINT_8)DISP_STRING("MID_MNY_P2P_CONNECTION_ABORT"),
469 (PUINT_8)DISP_STRING("MID_MNY_P2P_BEACON_UPDATE"),
470 (PUINT_8)DISP_STRING("MID_MNY_P2P_STOP_AP"),
471 (PUINT_8)DISP_STRING("MID_MNY_P2P_CHNL_REQ"),
472 (PUINT_8)DISP_STRING("MID_MNY_P2P_CHNL_ABORT"),
473 (PUINT_8)DISP_STRING("MID_MNY_P2P_MGMT_TX"),
474 (PUINT_8)DISP_STRING("MID_MNY_P2P_GROUP_DISSOLVE"),
475 (PUINT_8)DISP_STRING("MID_MNY_P2P_MGMT_FRAME_REGISTER"),
476 (PUINT_8)DISP_STRING("MID_MNY_P2P_NET_DEV_REGISTER"),
477 (PUINT_8)DISP_STRING("MID_MNY_P2P_START_AP"),
478 (PUINT_8)DISP_STRING("MID_MNY_P2P_UPDATE_IE_BUF"),
481 #if CFG_SUPPORT_ADHOC
482 //(PUINT_8)DISP_STRING("MID_AIS_CNM_CREATE_IBSS_REQ"),
483 //(PUINT_8)DISP_STRING("MID_CNM_AIS_CREATE_IBSS_GRANT"),
484 //(PUINT_8)DISP_STRING("MID_AIS_CNM_MERGE_IBSS_REQ"),
485 //(PUINT_8)DISP_STRING("MID_CNM_AIS_MERGE_IBSS_GRANT"),
486 (PUINT_8)DISP_STRING("MID_SCN_AIS_FOUND_IBSS"),
487 #endif /* CFG_SUPPORT_ADHOC */
489 (PUINT_8)DISP_STRING("MID_SAA_AIS_FSM_ABORT")
494 /* This message entry will be re-ordered based on the message ID order
495 * by invoking mboxInitMsgMap()
497 static MSG_HNDL_ENTRY_T arMsgMapTable[] = {
498 { MID_MNY_CNM_CH_REQ, cnmChMngrRequestPrivilege },
499 { MID_MNY_CNM_CH_ABORT, cnmChMngrAbortPrivilege },
500 { MID_CNM_AIS_CH_GRANT, aisFsmRunEventChGrant },
501 #if CFG_ENABLE_WIFI_DIRECT
502 { MID_CNM_P2P_CH_GRANT, p2pFsmRunEventChGrant }, /*set in gl_p2p_init.c*/
504 { MID_CNM_P2P_CH_GRANT, mboxDummy },
507 #if CFG_ENABLE_BT_OVER_WIFI
508 { MID_CNM_BOW_CH_GRANT, bowRunEventChGrant },
510 { MID_CNM_BOW_CH_GRANT, mboxDummy },
513 /*--------------------------------------------------*/
514 /* SCN Module Mailbox Messages */
515 /*--------------------------------------------------*/
516 { MID_AIS_SCN_SCAN_REQ, scnFsmMsgStart },
517 { MID_AIS_SCN_SCAN_REQ_V2, scnFsmMsgStart },
518 { MID_AIS_SCN_SCAN_CANCEL, scnFsmMsgAbort },
519 { MID_P2P_SCN_SCAN_REQ, scnFsmMsgStart },
520 { MID_P2P_SCN_SCAN_REQ_V2, scnFsmMsgStart },
521 { MID_P2P_SCN_SCAN_CANCEL, scnFsmMsgAbort },
522 { MID_BOW_SCN_SCAN_REQ, scnFsmMsgStart },
523 { MID_BOW_SCN_SCAN_REQ_V2, scnFsmMsgStart },
524 { MID_BOW_SCN_SCAN_CANCEL, scnFsmMsgAbort },
525 { MID_RLM_SCN_SCAN_REQ, scnFsmMsgStart },
526 { MID_RLM_SCN_SCAN_REQ_V2, scnFsmMsgStart },
527 { MID_RLM_SCN_SCAN_CANCEL, scnFsmMsgAbort },
528 { MID_SCN_AIS_SCAN_DONE, aisFsmRunEventScanDone },
529 #if CFG_ENABLE_WIFI_DIRECT
530 { MID_SCN_P2P_SCAN_DONE, p2pFsmRunEventScanDone }, /*set in gl_p2p_init.c*/
532 { MID_SCN_P2P_SCAN_DONE, mboxDummy },
535 #if CFG_ENABLE_BT_OVER_WIFI
536 { MID_SCN_BOW_SCAN_DONE, bowResponderScanDone },
538 { MID_SCN_BOW_SCAN_DONE, mboxDummy },
540 { MID_SCN_RLM_SCAN_DONE, rlmObssScanDone },
542 /*--------------------------------------------------*/
543 /* AIS Module Mailbox Messages */
544 /*--------------------------------------------------*/
545 { MID_OID_AIS_FSM_JOIN_REQ, aisFsmRunEventAbort },
546 { MID_OID_AIS_FSM_ABORT, aisFsmRunEventAbort },
547 { MID_AIS_SAA_FSM_START, saaFsmRunEventStart },
548 { MID_AIS_SAA_FSM_ABORT, saaFsmRunEventAbort },
549 { MID_SAA_AIS_JOIN_COMPLETE, aisFsmRunEventJoinComplete },
551 #if CFG_ENABLE_BT_OVER_WIFI
552 /*--------------------------------------------------*/
553 /* BOW Module Mailbox Messages */
554 /*--------------------------------------------------*/
555 { MID_BOW_SAA_FSM_START, saaFsmRunEventStart },
556 { MID_BOW_SAA_FSM_ABORT, saaFsmRunEventAbort },
557 { MID_SAA_BOW_JOIN_COMPLETE, bowFsmRunEventJoinComplete },
560 #if CFG_ENABLE_WIFI_DIRECT /*set in gl_p2p_init.c*/
561 { MID_P2P_SAA_FSM_START, saaFsmRunEventStart },
562 { MID_P2P_SAA_FSM_ABORT, saaFsmRunEventAbort },
563 { MID_SAA_P2P_JOIN_COMPLETE, p2pFsmRunEventJoinComplete },// TODO: p2pFsmRunEventJoinComplete
565 { MID_MNY_P2P_FUN_SWITCH, p2pFsmRunEventSwitchOPMode },
566 { MID_MNY_P2P_DEVICE_DISCOVERY, p2pFsmRunEventScanRequest },
567 { MID_MNY_P2P_CONNECTION_REQ, p2pFsmRunEventConnectionRequest },
568 { MID_MNY_P2P_CONNECTION_ABORT, p2pFsmRunEventConnectionAbort },
569 { MID_MNY_P2P_BEACON_UPDATE, p2pFsmRunEventBeaconUpdate },
570 { MID_MNY_P2P_STOP_AP, p2pFsmRunEventStopAP },
571 { MID_MNY_P2P_CHNL_REQ, p2pFsmRunEventChannelRequest },
572 { MID_MNY_P2P_CHNL_ABORT, p2pFsmRunEventChannelAbort },
573 { MID_MNY_P2P_MGMT_TX, p2pFsmRunEventMgmtFrameTx },
574 { MID_MNY_P2P_GROUP_DISSOLVE, p2pFsmRunEventDissolve },
575 { MID_MNY_P2P_MGMT_FRAME_REGISTER, p2pFsmRunEventMgmtFrameRegister },
576 { MID_MNY_P2P_NET_DEV_REGISTER, p2pFsmRunEventNetDeviceRegister },
577 { MID_MNY_P2P_START_AP, p2pFsmRunEventStartAP },
578 { MID_MNY_P2P_MGMT_FRAME_UPDATE, p2pFsmRunEventUpdateMgmtFrame },
580 { MID_MNY_P2P_WFD_CFG_UPDATE, p2pFsmRunEventWfdSettingUpdate },
585 #if CFG_SUPPORT_ADHOC
586 { MID_SCN_AIS_FOUND_IBSS, aisFsmRunEventFoundIBSSPeer },
587 #endif /* CFG_SUPPORT_ADHOC */
589 { MID_SAA_AIS_FSM_ABORT, aisFsmRunEventAbort }
592 /*******************************************************************************
594 ********************************************************************************
598 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
599 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
600 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
601 DBGLOG(CNM, LOUD, ("DO MSG [%d: %s]\n", prMsg->eMsgId, apucDebugMsg[prMsg->eMsgId])); \
602 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
605 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
606 cnmMemFree(prAdapter, prMsg); \
610 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
611 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
612 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
613 DBGLOG(CNM, LOUD, ("DO MSG [%d]\n", prMsg->eMsgId)); \
614 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
617 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
618 cnmMemFree(prAdapter, prMsg); \
622 /*******************************************************************************
623 * F U N C T I O N D E C L A R A T I O N S
624 ********************************************************************************
627 /*******************************************************************************
629 ********************************************************************************
633 /*----------------------------------------------------------------------------*/
641 /*----------------------------------------------------------------------------*/
648 MSG_HNDL_ENTRY_T rTempEntry;
650 ASSERT((sizeof(arMsgMapTable) / sizeof(MSG_HNDL_ENTRY_T)) == MID_TOTAL_NUM);
652 for (i = 0; i < MID_TOTAL_NUM; i++) {
653 if (arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i) {
656 for (idx = i + 1; idx < MID_TOTAL_NUM; idx++) {
657 if (arMsgMapTable[idx].eMsgId == (ENUM_MSG_ID_T) i) {
661 ASSERT(idx < MID_TOTAL_NUM);
662 if (idx >= MID_TOTAL_NUM) {
666 /* Swap target entry and current entry */
667 rTempEntry.eMsgId = arMsgMapTable[idx].eMsgId;
668 rTempEntry.pfMsgHndl= arMsgMapTable[idx].pfMsgHndl;
670 arMsgMapTable[idx].eMsgId = arMsgMapTable[i].eMsgId;
671 arMsgMapTable[idx].pfMsgHndl = arMsgMapTable[i].pfMsgHndl;
673 arMsgMapTable[i].eMsgId = rTempEntry.eMsgId;
674 arMsgMapTable[i].pfMsgHndl = rTempEntry.pfMsgHndl;
677 /* Verify the correctness of final message map */
678 for (i = 0; i < MID_TOTAL_NUM; i++) {
679 ASSERT(arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i);
680 while (arMsgMapTable[i].eMsgId != (ENUM_MSG_ID_T) i);
685 /*----------------------------------------------------------------------------*/
693 /*----------------------------------------------------------------------------*/
696 IN P_ADAPTER_T prAdapter,
697 IN ENUM_MBOX_ID_T eMboxId
701 KAL_SPIN_LOCK_DECLARATION();
703 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
706 prMbox = &(prAdapter->arMbox[eMboxId]);
708 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
709 LINK_INITIALIZE(&prMbox->rLinkHead);
710 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
713 /*----------------------------------------------------------------------------*/
721 /*----------------------------------------------------------------------------*/
724 IN P_ADAPTER_T prAdapter,
725 IN ENUM_MBOX_ID_T eMboxId,
726 IN P_MSG_HDR_T prMsg,
727 IN EUNM_MSG_SEND_METHOD_T eMethod
731 KAL_SPIN_LOCK_DECLARATION();
733 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
737 prMbox = &(prAdapter->arMbox[eMboxId]);
740 case MSG_SEND_METHOD_BUF:
741 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
742 LINK_INSERT_TAIL(&prMbox->rLinkHead, &prMsg->rLinkEntry);
743 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
745 // to wake up main service thread
746 GLUE_SET_EVENT(prAdapter->prGlueInfo);
750 case MSG_SEND_METHOD_UNBUF:
751 MBOX_HNDL_MSG(prAdapter, prMsg);
760 /*----------------------------------------------------------------------------*/
768 /*----------------------------------------------------------------------------*/
771 IN P_ADAPTER_T prAdapter,
772 ENUM_MBOX_ID_T eMboxId
777 KAL_SPIN_LOCK_DECLARATION();
779 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
782 prMbox = &(prAdapter->arMbox[eMboxId]);
784 while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) {
785 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
786 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
787 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
790 MBOX_HNDL_MSG(prAdapter, prMsg);
795 /*----------------------------------------------------------------------------*/
803 /*----------------------------------------------------------------------------*/
806 IN P_ADAPTER_T prAdapter
813 /* Initialize Mailbox */
816 /* Setup/initialize each mailbox */
817 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
818 mboxSetup(prAdapter, i);
823 /*----------------------------------------------------------------------------*/
831 /*----------------------------------------------------------------------------*/
834 IN P_ADAPTER_T prAdapter
840 KAL_SPIN_LOCK_DECLARATION();
844 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
845 prMbox = &(prAdapter->arMbox[i]);
847 while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) {
848 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
849 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
850 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
853 cnmMemFree(prAdapter, prMsg);
858 /*----------------------------------------------------------------------------*/
860 * \brief This is dummy function to prevent empty arMsgMapTable[] for compiling.
866 /*----------------------------------------------------------------------------*/
869 IN P_ADAPTER_T prAdapter,
870 IN P_MSG_HDR_T prMsgHdr
875 cnmMemFree(prAdapter, prMsgHdr);