import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6630 / wlan / mgmt / hem_mbox.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/hem_mbox.c#7 $
3 */
4
5 /*! \file "hem_mbox.c"
6 \brief
7
8 */
9
10
11
12 /*
13 ** $Log: hem_mbox.c $
14 **
15 ** 08 22 2013 yuche.tsai
16 ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
17 ** [BORA00000779] [MT6620] Emulation For TX Code Check In
18 ** Make P2P group interface formation success.
19 **
20 ** 08 09 2013 cp.wu
21 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
22 ** 1. integrate scheduled scan functionality
23 ** 2. condition compilation for linux-3.4 & linux-3.8 compatibility
24 ** 3. correct CMD queue access to reduce lock scope
25 **
26 ** 07 29 2013 cp.wu
27 ** [BORA00002725] [MT6630][Wi-Fi] Add MGMT TX/RX support for Linux port
28 ** Preparation for porting remain_on_channel support
29 **
30 ** 07 17 2013 yuche.tsai
31 ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
32 ** MT6630 P2P first connection check point 1.
33 **
34 ** 02 27 2013 yuche.tsai
35 ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
36 ** Add new code, fix compile warning.
37 **
38 ** 01 22 2013 cp.wu
39 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
40 ** modification for ucBssIndex migration
41 **
42 ** 09 17 2012 cm.chang
43 ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
44 ** Duplicate source from MT6620 v2.3 driver branch
45 ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
46 **
47 ** 08 24 2012 cp.wu
48 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
49 ** .
50 **
51 ** 08 24 2012 cp.wu
52 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
53 ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
54 **
55 ** 07 24 2012 yuche.tsai
56 ** NULL
57 ** Bug fix.
58 **
59 ** 07 24 2012 yuche.tsai
60 ** NULL
61 ** Bug fix for JB.
62 **
63 ** 07 19 2012 yuche.tsai
64 ** NULL
65 ** Code update for JB.
66 *
67 * 07 17 2012 yuche.tsai
68 * NULL
69 * Compile no error before trial run.
70 *
71 * 05 03 2012 cp.wu
72 * [WCXRP00001231] [MT6620 Wi-Fi][MT5931][Driver] Correct SCAN_V2 related debugging facilities within hem_mbox.c
73 * correct for debug message string table by adding missed scan_v2 related definitions.
74 *
75 * 03 02 2012 terry.wu
76 * NULL
77 * Sync CFG80211 modification from branch 2,2.
78 *
79 * 01 17 2012 yuche.tsai
80 * NULL
81 * Update mgmt frame filter setting.
82 * Please also update FW 2.1
83 *
84 * 01 13 2012 yuche.tsai
85 * NULL
86 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
87 *
88 * 11 24 2011 wh.su
89 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
90 * Adjust code for DBG and CONFIG_XLOG.
91 *
92 * 11 15 2011 cm.chang
93 * NULL
94 * Add exception handle for NULL function pointer of mailbox message
95 *
96 * 11 11 2011 wh.su
97 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
98 * modify the xlog related code.
99 *
100 * 11 02 2011 wh.su
101 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
102 * adding the code for XLOG.
103 *
104 * 07 18 2011 cp.wu
105 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
106 * 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
107 *
108 * 06 07 2011 yuche.tsai
109 * [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
110 * Add invitation support.
111 *
112 * 04 18 2011 terry.wu
113 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
114 * Remove flag CFG_WIFI_DIRECT_MOVED.
115 *
116 * 03 29 2011 cm.chang
117 * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
118 * As CR title
119 *
120 * 02 24 2011 cp.wu
121 * [WCXRP00000490] [MT6620 Wi-Fi][Driver][Win32] modify kalMsleep() implementation because NdisMSleep() won't sleep long enough for specified interval such as 500ms
122 * modify cnm_timer and hem_mbox APIs to be thread safe to ease invoking restrictions
123 *
124 * 02 15 2011 chinghwa.yu
125 * [WCXRP00000065] Update BoW design and settings
126 * Update bowString and channel grant.
127 *
128 * 01 26 2011 cm.chang
129 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
130 * Allocate system RAM if fixed message or mgmt buffer is not available
131 *
132 * 01 26 2011 yuche.tsai
133 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
134 * .
135 *
136 * 01 25 2011 yuche.tsai
137 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
138 * Fix Compile Error when DBG is disabled.
139 *
140 * 01 24 2011 cp.wu
141 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
142 * 1. add an extra counter for tracking pending forward frames.
143 * 2. notify TX service thread as well when there is pending forward frame
144 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
145 *
146 * 12 08 2010 chinghwa.yu
147 * [WCXRP00000065] Update BoW design and settings
148 * Support concurrent networks.
149 *
150 * 11 08 2010 cm.chang
151 * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID
152 * Remove CNM channel reover message ID
153 *
154 * 11 01 2010 cp.wu
155 * [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
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 /*******************************************************************************
385 * C O M P I L E R F L A G S
386 ********************************************************************************
387 */
388
389 /*******************************************************************************
390 * E X T E R N A L R E F E R E N C E S
391 ********************************************************************************
392 */
393 #include "precomp.h"
394
395 /*******************************************************************************
396 * C O N S T A N T S
397 ********************************************************************************
398 */
399
400 /*******************************************************************************
401 * D A T A T Y P E S
402 ********************************************************************************
403 */
404
405 /*******************************************************************************
406 * P U B L I C D A T A
407 ********************************************************************************
408 */
409
410 /*******************************************************************************
411 * P R I V A T E D A T A
412 ********************************************************************************
413 */
414 #if DBG
415 /*lint -save -e64 Type mismatch */
416 static PUINT_8 apucDebugMsg[] = {
417 (PUINT_8) DISP_STRING("MID_MNY_CNM_CH_REQ"),
418 (PUINT_8) DISP_STRING("MID_MNY_CNM_CH_ABORT"),
419 (PUINT_8) DISP_STRING("MID_CNM_AIS_CH_GRANT"),
420 (PUINT_8) DISP_STRING("MID_CNM_P2P_CH_GRANT"),
421 (PUINT_8) DISP_STRING("MID_CNM_BOW_CH_GRANT"),
422
423 (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_REQ"),
424 (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_REQ_V2"),
425 (PUINT_8) DISP_STRING("MID_AIS_SCN_SCAN_CANCEL"),
426 (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_REQ"),
427 (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_REQ_V2"),
428 (PUINT_8) DISP_STRING("MID_P2P_SCN_SCAN_CANCEL"),
429 (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_REQ"),
430 (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_REQ_V2"),
431 (PUINT_8) DISP_STRING("MID_BOW_SCN_SCAN_CANCEL"),
432 (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_REQ"),
433 (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_REQ_V2"),
434 (PUINT_8) DISP_STRING("MID_RLM_SCN_SCAN_CANCEL"),
435 (PUINT_8) DISP_STRING("MID_SCN_AIS_SCAN_DONE"),
436 (PUINT_8) DISP_STRING("MID_SCN_P2P_SCAN_DONE"),
437 (PUINT_8) DISP_STRING("MID_SCN_BOW_SCAN_DONE"),
438 (PUINT_8) DISP_STRING("MID_SCN_RLM_SCAN_DONE"),
439
440 (PUINT_8) DISP_STRING("MID_OID_AIS_FSM_JOIN_REQ"),
441 (PUINT_8) DISP_STRING("MID_OID_AIS_FSM_ABORT"),
442 (PUINT_8) DISP_STRING("MID_AIS_SAA_FSM_START"),
443 (PUINT_8) DISP_STRING("MID_AIS_SAA_FSM_ABORT"),
444 (PUINT_8) DISP_STRING("MID_SAA_AIS_JOIN_COMPLETE"),
445
446 #if CFG_ENABLE_BT_OVER_WIFI
447 (PUINT_8) DISP_STRING("MID_BOW_SAA_FSM_START"),
448 (PUINT_8) DISP_STRING("MID_BOW_SAA_FSM_ABORT"),
449 (PUINT_8) DISP_STRING("MID_SAA_BOW_JOIN_COMPLETE"),
450 #endif
451
452 #if CFG_ENABLE_WIFI_DIRECT
453 (PUINT_8) DISP_STRING("MID_P2P_SAA_FSM_START"),
454 (PUINT_8) DISP_STRING("MID_P2P_SAA_FSM_ABORT"),
455 (PUINT_8) DISP_STRING("MID_SAA_P2P_JOIN_COMPLETE"),
456
457 (PUINT_8) DISP_STRING("MID_MNY_P2P_FUN_SWITCH"),
458 (PUINT_8) DISP_STRING("MID_MNY_P2P_DEVICE_DISCOVERY"),
459 (PUINT_8) DISP_STRING("MID_MNY_P2P_CONNECTION_REQ"),
460 (PUINT_8) DISP_STRING("MID_MNY_P2P_CONNECTION_ABORT"),
461 (PUINT_8) DISP_STRING("MID_MNY_P2P_BEACON_UPDATE"),
462 (PUINT_8) DISP_STRING("MID_MNY_P2P_STOP_AP"),
463 (PUINT_8) DISP_STRING("MID_MNY_P2P_CHNL_REQ"),
464 (PUINT_8) DISP_STRING("MID_MNY_P2P_CHNL_ABORT"),
465 (PUINT_8) DISP_STRING("MID_MNY_P2P_MGMT_TX"),
466 (PUINT_8) DISP_STRING("MID_MNY_P2P_GROUP_DISSOLVE"),
467 (PUINT_8) DISP_STRING("MID_MNY_P2P_MGMT_FRAME_REGISTER"),
468 (PUINT_8) DISP_STRING("MID_MNY_P2P_NET_DEV_REGISTER"),
469 (PUINT_8) DISP_STRING("MID_MNY_P2P_START_AP"),
470 (PUINT_8) DISP_STRING("MID_MNY_P2P_UPDATE_IE_BUF"),
471 #endif
472
473 #if CFG_SUPPORT_ADHOC
474 /* (PUINT_8)DISP_STRING("MID_AIS_CNM_CREATE_IBSS_REQ"), */
475 /* (PUINT_8)DISP_STRING("MID_CNM_AIS_CREATE_IBSS_GRANT"), */
476 /* (PUINT_8)DISP_STRING("MID_AIS_CNM_MERGE_IBSS_REQ"), */
477 /* (PUINT_8)DISP_STRING("MID_CNM_AIS_MERGE_IBSS_GRANT"), */
478 (PUINT_8) DISP_STRING("MID_SCN_AIS_FOUND_IBSS"),
479 #endif /* CFG_SUPPORT_ADHOC */
480
481 (PUINT_8) DISP_STRING("MID_SAA_AIS_FSM_ABORT"),
482 (PUINT_8) DISP_STRING("MID_MNY_AIS_REMAIN_ON_CHANNEL"),
483 (PUINT_8) DISP_STRING("MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL"),
484 (PUINT_8) DISP_STRING("MID_MNY_AIS_MGMT_TX")
485
486 };
487
488 /*lint -restore */
489 #endif /* DBG */
490
491 /* This message entry will be re-ordered based on the message ID order
492 * by invoking mboxInitMsgMap()
493 */
494 static MSG_HNDL_ENTRY_T arMsgMapTable[] = {
495 {MID_MNY_CNM_CH_REQ, cnmChMngrRequestPrivilege},
496 {MID_MNY_CNM_CH_ABORT, cnmChMngrAbortPrivilege},
497 {MID_CNM_AIS_CH_GRANT, aisFsmRunEventChGrant},
498 #if CFG_ENABLE_WIFI_DIRECT
499 {MID_CNM_P2P_CH_GRANT, p2pFsmRunEventChGrant}, /*set in gl_p2p_init.c */
500 #else
501 {MID_CNM_P2P_CH_GRANT, mboxDummy},
502 #endif
503
504 #if CFG_ENABLE_BT_OVER_WIFI
505 {MID_CNM_BOW_CH_GRANT, bowRunEventChGrant},
506 #else
507 {MID_CNM_BOW_CH_GRANT, mboxDummy},
508 #endif
509
510 /*--------------------------------------------------*/
511 /* SCN Module Mailbox Messages */
512 /*--------------------------------------------------*/
513 {MID_AIS_SCN_SCAN_REQ, scnFsmMsgStart},
514 {MID_AIS_SCN_SCAN_REQ_V2, scnFsmMsgStart},
515 {MID_AIS_SCN_SCAN_CANCEL, scnFsmMsgAbort},
516 {MID_P2P_SCN_SCAN_REQ, scnFsmMsgStart},
517 {MID_P2P_SCN_SCAN_REQ_V2, scnFsmMsgStart},
518 {MID_P2P_SCN_SCAN_CANCEL, scnFsmMsgAbort},
519 {MID_BOW_SCN_SCAN_REQ, scnFsmMsgStart},
520 {MID_BOW_SCN_SCAN_REQ_V2, scnFsmMsgStart},
521 {MID_BOW_SCN_SCAN_CANCEL, scnFsmMsgAbort},
522 {MID_RLM_SCN_SCAN_REQ, scnFsmMsgStart},
523 {MID_RLM_SCN_SCAN_REQ_V2, scnFsmMsgStart},
524 {MID_RLM_SCN_SCAN_CANCEL, scnFsmMsgAbort},
525 {MID_SCN_AIS_SCAN_DONE, aisFsmRunEventScanDone},
526 #if CFG_ENABLE_WIFI_DIRECT
527 {MID_SCN_P2P_SCAN_DONE, p2pFsmRunEventScanDone}, /*set in gl_p2p_init.c */
528 #else
529 {MID_SCN_P2P_SCAN_DONE, mboxDummy},
530 #endif
531
532 #if CFG_ENABLE_BT_OVER_WIFI
533 {MID_SCN_BOW_SCAN_DONE, bowResponderScanDone},
534 #else
535 {MID_SCN_BOW_SCAN_DONE, mboxDummy},
536 #endif
537 {MID_SCN_RLM_SCAN_DONE, rlmObssScanDone},
538
539 /*--------------------------------------------------*/
540 /* AIS Module Mailbox Messages */
541 /*--------------------------------------------------*/
542 {MID_OID_AIS_FSM_JOIN_REQ, aisFsmRunEventAbort},
543 {MID_OID_AIS_FSM_ABORT, aisFsmRunEventAbort},
544 {MID_AIS_SAA_FSM_START, saaFsmRunEventStart},
545 {MID_AIS_SAA_FSM_ABORT, saaFsmRunEventAbort},
546 {MID_SAA_AIS_JOIN_COMPLETE, aisFsmRunEventJoinComplete},
547
548 #if CFG_ENABLE_BT_OVER_WIFI
549 /*--------------------------------------------------*/
550 /* BOW Module Mailbox Messages */
551 /*--------------------------------------------------*/
552 {MID_BOW_SAA_FSM_START, saaFsmRunEventStart},
553 {MID_BOW_SAA_FSM_ABORT, saaFsmRunEventAbort},
554 {MID_SAA_BOW_JOIN_COMPLETE, bowFsmRunEventJoinComplete},
555 #endif
556
557 #if CFG_ENABLE_WIFI_DIRECT /*set in gl_p2p_init.c */
558 {MID_P2P_SAA_FSM_START, saaFsmRunEventStart},
559 {MID_P2P_SAA_FSM_ABORT, saaFsmRunEventAbort},
560 {MID_SAA_P2P_JOIN_COMPLETE, p2pRoleFsmRunEventJoinComplete}, /* V */
561
562 {MID_MNY_P2P_FUN_SWITCH, p2pRoleFsmRunEventSwitchOPMode},
563 {MID_MNY_P2P_DEVICE_DISCOVERY, p2pFsmRunEventScanRequest}, /* V */
564 {MID_MNY_P2P_CONNECTION_REQ, p2pRoleFsmRunEventConnectionRequest},
565 {MID_MNY_P2P_CONNECTION_ABORT, p2pRoleFsmRunEventConnectionAbort},
566 {MID_MNY_P2P_BEACON_UPDATE, p2pFsmRunEventBeaconUpdate},
567 {MID_MNY_P2P_STOP_AP, p2pRoleFsmRunEventStopAP},
568 {MID_MNY_P2P_CHNL_REQ, p2pDevFsmRunEventChannelRequest}, /* V */
569 {MID_MNY_P2P_CHNL_ABORT, p2pDevFsmRunEventChannelAbort}, /* V */
570 {MID_MNY_P2P_MGMT_TX, p2pDevFsmRunEventMgmtTx}, /* V */
571 {MID_MNY_P2P_GROUP_DISSOLVE, p2pRoleFsmRunEventDissolve},
572 {MID_MNY_P2P_MGMT_FRAME_REGISTER, p2pDevFsmRunEventMgmtFrameRegister},
573 {MID_MNY_P2P_NET_DEV_REGISTER, p2pFsmRunEventNetDeviceRegister},
574 {MID_MNY_P2P_START_AP, p2pRoleFsmRunEventStartAP},
575 {MID_MNY_P2P_MGMT_FRAME_UPDATE, p2pFsmRunEventUpdateMgmtFrame},
576 #if CFG_SUPPORT_WFD
577 {MID_MNY_P2P_WFD_CFG_UPDATE, p2pFsmRunEventWfdSettingUpdate},
578 #endif
579
580 #endif
581
582 #if CFG_SUPPORT_ADHOC
583 {MID_SCN_AIS_FOUND_IBSS, aisFsmRunEventFoundIBSSPeer},
584 #endif /* CFG_SUPPORT_ADHOC */
585
586 {MID_SAA_AIS_FSM_ABORT, aisFsmRunEventAbort},
587 {MID_MNY_AIS_REMAIN_ON_CHANNEL, aisFsmRunEventRemainOnChannel},
588 {MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL, aisFsmRunEventCancelRemainOnChannel},
589 {MID_MNY_AIS_MGMT_TX, aisFsmRunEventMgmtFrameTx}
590
591
592 };
593
594 /*******************************************************************************
595 * M A C R O S
596 ********************************************************************************
597 */
598
599 #if DBG
600 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
601 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
602 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
603 DBGLOG(CNM, LOUD, ("DO MSG [%d: %s]\n", prMsg->eMsgId, apucDebugMsg[prMsg->eMsgId])); \
604 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
605 } \
606 else { \
607 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
608 cnmMemFree(prAdapter, prMsg); \
609 } \
610 } while (0)
611 #else
612 #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \
613 ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \
614 if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \
615 DBGLOG(CNM, LOUD, ("DO MSG [%d]\n", prMsg->eMsgId)); \
616 arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \
617 } \
618 else { \
619 DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \
620 cnmMemFree(prAdapter, prMsg); \
621 } \
622 } while (0)
623 #endif
624 /*******************************************************************************
625 * F U N C T I O N D E C L A R A T I O N S
626 ********************************************************************************
627 */
628
629 /*******************************************************************************
630 * F U N C T I O N S
631 ********************************************************************************
632 */
633
634
635 /*----------------------------------------------------------------------------*/
636 /*!
637 * \brief
638 *
639 * \param[in]
640 *
641 * \return none
642 */
643 /*----------------------------------------------------------------------------*/
644 VOID mboxInitMsgMap(VOID)
645 {
646 UINT_32 i, idx;
647 MSG_HNDL_ENTRY_T rTempEntry;
648
649 ASSERT((sizeof(arMsgMapTable) / sizeof(MSG_HNDL_ENTRY_T)) == MID_TOTAL_NUM);
650
651 for (i = 0; i < MID_TOTAL_NUM; i++) {
652 if (arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i) {
653 continue;
654 }
655 for (idx = i + 1; idx < MID_TOTAL_NUM; idx++) {
656 if (arMsgMapTable[idx].eMsgId == (ENUM_MSG_ID_T) i) {
657 break;
658 }
659 }
660 ASSERT(idx < MID_TOTAL_NUM);
661 if (idx >= MID_TOTAL_NUM) {
662 continue;
663 }
664
665 /* Swap target entry and current entry */
666 rTempEntry.eMsgId = arMsgMapTable[idx].eMsgId;
667 rTempEntry.pfMsgHndl = arMsgMapTable[idx].pfMsgHndl;
668
669 arMsgMapTable[idx].eMsgId = arMsgMapTable[i].eMsgId;
670 arMsgMapTable[idx].pfMsgHndl = arMsgMapTable[i].pfMsgHndl;
671
672 arMsgMapTable[i].eMsgId = rTempEntry.eMsgId;
673 arMsgMapTable[i].pfMsgHndl = rTempEntry.pfMsgHndl;
674 }
675
676 /* Verify the correctness of final message map */
677 for (i = 0; i < MID_TOTAL_NUM; i++) {
678 ASSERT(arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i);
679 while (arMsgMapTable[i].eMsgId != (ENUM_MSG_ID_T) i) {
680 ;
681 }
682 }
683
684 }
685
686 /*----------------------------------------------------------------------------*/
687 /*!
688 * \brief
689 *
690 * \param[in]
691 *
692 * \return none
693 */
694 /*----------------------------------------------------------------------------*/
695 VOID mboxSetup(IN P_ADAPTER_T prAdapter, IN ENUM_MBOX_ID_T eMboxId)
696 {
697 P_MBOX_T prMbox;
698 KAL_SPIN_LOCK_DECLARATION();
699
700 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
701 ASSERT(prAdapter);
702
703 prMbox = &(prAdapter->arMbox[eMboxId]);
704
705 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
706 LINK_INITIALIZE(&prMbox->rLinkHead);
707 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
708 }
709
710 /*----------------------------------------------------------------------------*/
711 /*!
712 * \brief
713 *
714 * \param[in]
715 *
716 * \return none
717 */
718 /*----------------------------------------------------------------------------*/
719 VOID
720 mboxSendMsg(IN P_ADAPTER_T prAdapter,
721 IN ENUM_MBOX_ID_T eMboxId, IN P_MSG_HDR_T prMsg, IN EUNM_MSG_SEND_METHOD_T eMethod)
722 {
723 P_MBOX_T prMbox;
724 KAL_SPIN_LOCK_DECLARATION();
725
726 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
727 ASSERT(prMsg);
728 ASSERT(prAdapter);
729
730 prMbox = &(prAdapter->arMbox[eMboxId]);
731
732 switch (eMethod) {
733 case MSG_SEND_METHOD_BUF:
734 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
735 LINK_INSERT_TAIL(&prMbox->rLinkHead, &prMsg->rLinkEntry);
736 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
737
738 /* to wake up main service thread */
739 GLUE_SET_EVENT(prAdapter->prGlueInfo);
740
741 break;
742
743 case MSG_SEND_METHOD_UNBUF:
744 MBOX_HNDL_MSG(prAdapter, prMsg);
745 break;
746
747 default:
748 ASSERT(0);
749 break;
750 }
751 }
752
753 /*----------------------------------------------------------------------------*/
754 /*!
755 * \brief
756 *
757 * \param[in]
758 *
759 * \return none
760 */
761 /*----------------------------------------------------------------------------*/
762 VOID mboxRcvAllMsg(IN P_ADAPTER_T prAdapter, ENUM_MBOX_ID_T eMboxId)
763 {
764 P_MBOX_T prMbox;
765 P_MSG_HDR_T prMsg;
766 KAL_SPIN_LOCK_DECLARATION();
767
768 ASSERT(eMboxId < MBOX_ID_TOTAL_NUM);
769 ASSERT(prAdapter);
770
771 prMbox = &(prAdapter->arMbox[eMboxId]);
772
773 while (!LINK_IS_EMPTY(&prMbox->rLinkHead)) {
774 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
775 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
776 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
777
778 ASSERT(prMsg);
779 MBOX_HNDL_MSG(prAdapter, prMsg);
780 }
781
782 }
783
784 /*----------------------------------------------------------------------------*/
785 /*!
786 * \brief
787 *
788 * \param[in]
789 *
790 * \return none
791 */
792 /*----------------------------------------------------------------------------*/
793 VOID mboxInitialize(IN P_ADAPTER_T prAdapter)
794 {
795 UINT_32 i;
796
797 ASSERT(prAdapter);
798
799 /* Initialize Mailbox */
800 mboxInitMsgMap();
801
802 /* Setup/initialize each mailbox */
803 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
804 mboxSetup(prAdapter, i);
805 }
806
807 }
808
809 /*----------------------------------------------------------------------------*/
810 /*!
811 * \brief
812 *
813 * \param[in]
814 *
815 * \return none
816 */
817 /*----------------------------------------------------------------------------*/
818 VOID mboxDestroy(IN P_ADAPTER_T prAdapter)
819 {
820 P_MBOX_T prMbox;
821 P_MSG_HDR_T prMsg;
822 UINT_8 i;
823 KAL_SPIN_LOCK_DECLARATION();
824
825 ASSERT(prAdapter);
826
827 for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) {
828 prMbox = &(prAdapter->arMbox[i]);
829
830 while (!LINK_IS_EMPTY(&prMbox->rLinkHead)) {
831 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
832 LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T);
833 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX);
834
835 ASSERT(prMsg);
836 cnmMemFree(prAdapter, prMsg);
837 }
838 }
839 }
840
841 /*----------------------------------------------------------------------------*/
842 /*!
843 * \brief This is dummy function to prevent empty arMsgMapTable[] for compiling.
844 *
845 * \param[in]
846 *
847 * \return none
848 */
849 /*----------------------------------------------------------------------------*/
850 VOID mboxDummy(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
851 {
852 ASSERT(prAdapter);
853
854 cnmMemFree(prAdapter, prMsgHdr);
855
856 return;
857 }