Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /* |
2 | ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/hem_mbox.c#3 $ | |
3 | */ | |
4 | ||
5 | /*! \file "hem_mbox.c" | |
6 | \brief | |
7 | ||
8 | */ | |
9 | ||
10 | ||
11 | ||
12 | /* | |
13 | ** $Log: hem_mbox.c $ | |
14 | ** | |
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. | |
18 | ** | |
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. | |
22 | ** | |
23 | ** 07 19 2012 yuche.tsai | |
24 | ** NULL | |
25 | ** Code update for JB. | |
26 | * | |
27 | * 07 17 2012 yuche.tsai | |
28 | * NULL | |
29 | * Compile no error before trial run. | |
30 | * | |
31 | * 05 03 2012 cp.wu | |
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. | |
34 | * | |
35 | * 03 02 2012 terry.wu | |
36 | * NULL | |
37 | * Sync CFG80211 modification from branch 2,2. | |
38 | * | |
39 | * 01 17 2012 yuche.tsai | |
40 | * NULL | |
41 | * Update mgmt frame filter setting. | |
42 | * Please also update FW 2.1 | |
43 | * | |
44 | * 01 13 2012 yuche.tsai | |
45 | * NULL | |
46 | * WiFi Hot Spot Tethering for ICS ALPHA testing version. | |
47 | * | |
48 | * 11 24 2011 wh.su | |
49 | * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG | |
50 | * Adjust code for DBG and CONFIG_XLOG. | |
51 | * | |
52 | * 11 15 2011 cm.chang | |
53 | * NULL | |
54 | * Add exception handle for NULL function pointer of mailbox message | |
55 | * | |
56 | * 11 11 2011 wh.su | |
57 | * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG | |
58 | * modify the xlog related code. | |
59 | * | |
60 | * 11 02 2011 wh.su | |
61 | * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG | |
62 | * adding the code for XLOG. | |
63 | * | |
64 | * 07 18 2011 cp.wu | |
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 | |
67 | * | |
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. | |
71 | * | |
72 | * 04 18 2011 terry.wu | |
73 | * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED | |
74 | * Remove flag CFG_WIFI_DIRECT_MOVED. | |
75 | * | |
76 | * 03 29 2011 cm.chang | |
77 | * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning | |
78 | * As CR title | |
79 | * | |
80 | * 02 24 2011 cp.wu | |
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 | |
83 | * | |
84 | * 02 15 2011 chinghwa.yu | |
85 | * [WCXRP00000065] Update BoW design and settings | |
86 | * Update bowString and channel grant. | |
87 | * | |
88 | * 01 26 2011 cm.chang | |
89 | * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument | |
90 | * Allocate system RAM if fixed message or mgmt buffer is not available | |
91 | * | |
92 | * 01 26 2011 yuche.tsai | |
93 | * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record. | |
94 | * . | |
95 | * | |
96 | * 01 25 2011 yuche.tsai | |
97 | * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record. | |
98 | * Fix Compile Error when DBG is disabled. | |
99 | * | |
100 | * 01 24 2011 cp.wu | |
101 | * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving | |
102 | * 1. add an extra counter for tracking pending forward frames. | |
103 | * 2. notify TX service thread as well when there is pending forward frame | |
104 | * 3. correct build errors leaded by introduction of Wi-Fi direct separation module | |
105 | * | |
106 | * 12 08 2010 chinghwa.yu | |
107 | * [WCXRP00000065] Update BoW design and settings | |
108 | * Support concurrent networks. | |
109 | * | |
110 | * 11 08 2010 cm.chang | |
111 | * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID | |
112 | * Remove CNM channel reover message ID | |
113 | * | |
114 | * 11 01 2010 cp.wu | |
115 | * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] 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. | |
119 | * | |
120 | * 10 08 2010 wh.su | |
121 | * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine | |
122 | * update the frog's new p2p state machine. | |
123 | * | |
124 | * 09 28 2010 wh.su | |
125 | * NULL | |
126 | * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo. | |
127 | * | |
128 | * 09 16 2010 cm.chang | |
129 | * NULL | |
130 | * Remove unused message ID | |
131 | * | |
132 | * 08 30 2010 cp.wu | |
133 | * NULL | |
134 | * eliminate klockwork errors | |
135 | * | |
136 | * 08 26 2010 yuche.tsai | |
137 | * NULL | |
138 | * Add P2P Connection Abort Event Message handler. | |
139 | * | |
140 | * 08 25 2010 george.huang | |
141 | * NULL | |
142 | * update OID/ registry control path for PM related settings | |
143 | * | |
144 | * 08 24 2010 yarco.yang | |
145 | * NULL | |
146 | * Fixed Driver ASSERT at mboxInitMsgMap() | |
147 | * | |
148 | * 08 24 2010 chinghwa.yu | |
149 | * NULL | |
150 | * Update for MID_SCN_BOW_SCAN_DONE mboxDummy. | |
151 | * Update saa_fsm for BOW. | |
152 | * | |
153 | * 08 23 2010 chinghwa.yu | |
154 | * NULL | |
155 | * Add CFG_ENABLE_BT_OVER_WIFI. | |
156 | * | |
157 | * 08 23 2010 chinghwa.yu | |
158 | * NULL | |
159 | * Update for BOW. | |
160 | * | |
161 | * 08 16 2010 cp.wu | |
162 | * NULL | |
163 | * add interface for RLM to trigger OBSS-SCAN. | |
164 | * | |
165 | * 08 16 2010 yuche.tsai | |
166 | * NULL | |
167 | * Add debug message for newly add P2P message. | |
168 | * | |
169 | * 08 11 2010 yuche.tsai | |
170 | * NULL | |
171 | * Add some function entry for P2P FSM under provisioning phase.. | |
172 | * | |
173 | * 08 11 2010 yuche.tsai | |
174 | * NULL | |
175 | * Add some events to P2P Module. | |
176 | * | |
177 | * 08 05 2010 yuche.tsai | |
178 | * NULL | |
179 | * Add message box event for P2P device switch on & device discovery. | |
180 | * | |
181 | * 08 04 2010 cp.wu | |
182 | * NULL | |
183 | * remove unused mailbox message definitions. | |
184 | * | |
185 | * 08 02 2010 yuche.tsai | |
186 | * NULL | |
187 | * P2P Group Negotiation Code Check in. | |
188 | * | |
189 | * 07 19 2010 cp.wu | |
190 | * | |
191 | * [WPD00003833] [MT6620 and MT5931] Driver migration. | |
192 | * message table should not be commented out by compilation option without modifying header file | |
193 | * | |
194 | * 07 19 2010 cp.wu | |
195 | * | |
196 | * [WPD00003833] [MT6620 and MT5931] Driver migration. | |
197 | * Add Ad-Hoc support to AIS-FSM | |
198 | * | |
199 | * 07 19 2010 yuche.tsai | |
200 | * | |
201 | * Add wifi direct scan done callback. | |
202 | * | |
203 | * 07 09 2010 cp.wu | |
204 | * | |
205 | * change handler of MID_MNY_CNM_CONNECTION_ABORT from NULL to mboxDummy. | |
206 | * | |
207 | * 07 08 2010 cp.wu | |
208 | * | |
209 | * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository. | |
210 | * | |
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 | |
214 | * | |
215 | * 07 01 2010 cp.wu | |
216 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
217 | * AIS-FSM integration with CNM channel request messages | |
218 | * | |
219 | * 07 01 2010 cp.wu | |
220 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
221 | * implementation of DRV-SCN and related mailbox message handling. | |
222 | * | |
223 | * 07 01 2010 cm.chang | |
224 | * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver | |
225 | * Modify CNM message handler for new flow | |
226 | * | |
227 | * 06 15 2010 cp.wu | |
228 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
229 | * enable currently migrated message call-backs. | |
230 | * | |
231 | * 06 14 2010 cp.wu | |
232 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
233 | * restore utility function invoking via hem_mbox to direct calls | |
234 | * | |
235 | * 06 10 2010 cp.wu | |
236 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
237 | * add buildable & linkable ais_fsm.c | |
238 | * | |
239 | * related reference are still waiting to be resolved | |
240 | * | |
241 | * 06 08 2010 cp.wu | |
242 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
243 | * hem_mbox is migrated. | |
244 | * | |
245 | * 06 08 2010 cp.wu | |
246 | * [WPD00003833][MT6620 and MT5931] Driver migration | |
247 | * add hem_mbox.c and cnm_mem.h (but disabled some feature) for further migration | |
248 | * | |
249 | * 05 12 2010 kevin.huang | |
250 | * [BORA00000794][WIFISYS][New Feature]Power Management Support | |
251 | * Fix file merge error | |
252 | * | |
253 | * 05 12 2010 kevin.huang | |
254 | * [BORA00000794][WIFISYS][New Feature]Power Management Support | |
255 | * Add Power Management - Legacy PS-POLL support. | |
256 | * | |
257 | * 04 29 2010 tehuang.liu | |
258 | * [BORA00000605][WIFISYS] Phase3 Integration | |
259 | * Removed MID_RXM_MQM_QOS_ACTION_FRAME | |
260 | * | |
261 | * 04 29 2010 tehuang.liu | |
262 | * [BORA00000605][WIFISYS] Phase3 Integration | |
263 | * Removed MID_RXM_MQM_BA_ACTION_FRAME | |
264 | * | |
265 | * 04 27 2010 tehuang.liu | |
266 | * [BORA00000605][WIFISYS] Phase3 Integration | |
267 | * MID_RXM_MQM_BA_ACTION_FRAME | |
268 | * | |
269 | * 03 30 2010 cm.chang | |
270 | * [BORA00000018]Integrate WIFI part into BORA for the 1st time | |
271 | * Support 2.4G OBSS scan | |
272 | * | |
273 | * 03 16 2010 kevin.huang | |
274 | * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support | |
275 | * Add AdHoc Mode | |
276 | * | |
277 | * 03 10 2010 kevin.huang | |
278 | * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support | |
279 | * | |
280 | * * * * * * * * * * * * * * Add Channel Manager for arbitration of JOIN and SCAN Req | |
281 | * | |
282 | * 03 05 2010 cm.chang | |
283 | * [BORA00000018]Integrate WIFI part into BORA for the 1st time | |
284 | * Develop partial DPD code | |
285 | * | |
286 | * 02 11 2010 tehuang.liu | |
287 | * [BORA00000569][WIFISYS] Phase 2 Integration Test | |
288 | * Updated arMsgMapTable for MID_RXM_MQM_QOS_ACTION_FRAME | |
289 | * | |
290 | * 01 11 2010 kevin.huang | |
291 | * [BORA00000018]Integrate WIFI part into BORA for the 1st time | |
292 | * Add Deauth and Disassoc Handler | |
293 | * | |
294 | * Dec 9 2009 mtk01461 | |
295 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
296 | * Add hemRunEventScanDone() to arMsgMapTable[] | |
297 | * | |
298 | * Dec 4 2009 mtk01461 | |
299 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
300 | * Fix mboxDummy() didn't free prMsgHdr | |
301 | * | |
302 | * Dec 3 2009 mtk01461 | |
303 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
304 | * Add saaAisJoinComplete event handler | |
305 | * | |
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 | |
309 | * | |
310 | * Dec 2 2009 MTK02468 | |
311 | * [BORA00000337] To check in codes for FPGA emulation | |
312 | * Added MID_RXM_MQM_BA_ACTION_FRAME to MsgMapTable | |
313 | * | |
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) | |
317 | * | |
318 | * Nov 16 2009 mtk01461 | |
319 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
320 | * Add aisFsmRunEventAbort() event handler | |
321 | * | |
322 | * Nov 11 2009 mtk01461 | |
323 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
324 | * Fix typo | |
325 | * | |
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() | |
329 | * | |
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[] | |
333 | * | |
334 | * Nov 2 2009 mtk01104 | |
335 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
336 | * Fix sorting algorithm in mboxInitMsgMap() | |
337 | * | |
338 | * Oct 28 2009 mtk01104 | |
339 | * [BORA00000018] Integrate WIFI part into BORA for the 1st time | |
340 | * | |
341 | ** | |
342 | */ | |
343 | ||
344 | /******************************************************************************* | |
345 | * C O M P I L E R F L A G S | |
346 | ******************************************************************************** | |
347 | */ | |
348 | ||
349 | /******************************************************************************* | |
350 | * E X T E R N A L R E F E R E N C E S | |
351 | ******************************************************************************** | |
352 | */ | |
353 | #include "precomp.h" | |
354 | ||
355 | /******************************************************************************* | |
356 | * C O N S T A N T S | |
357 | ******************************************************************************** | |
358 | */ | |
359 | ||
360 | /******************************************************************************* | |
361 | * D A T A T Y P E S | |
362 | ******************************************************************************** | |
363 | */ | |
364 | ||
365 | /******************************************************************************* | |
366 | * P U B L I C D A T A | |
367 | ******************************************************************************** | |
368 | */ | |
369 | ||
370 | /******************************************************************************* | |
371 | * P R I V A T E D A T A | |
372 | ******************************************************************************** | |
373 | */ | |
374 | #if DBG | |
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"), | |
382 | ||
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"), | |
399 | ||
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"), | |
405 | ||
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"), | |
410 | #endif | |
411 | ||
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"), | |
416 | ||
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"), | |
431 | #endif | |
432 | ||
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 */ | |
440 | ||
441 | (PUINT_8)DISP_STRING("MID_SAA_AIS_FSM_ABORT"), | |
442 | (PUINT_8)DISP_STRING("MID_MNY_AIS_REMAIN_ON_CHANNEL"), | |
443 | (PUINT_8)DISP_STRING("MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL"), | |
444 | (PUINT_8)DISP_STRING("MID_MNY_AIS_MGMT_TX") | |
445 | }; | |
446 | /*lint -restore */ | |
447 | #endif /* DBG */ | |
448 | ||
449 | /* This message entry will be re-ordered based on the message ID order | |
450 | * by invoking mboxInitMsgMap() | |
451 | */ | |
452 | static MSG_HNDL_ENTRY_T arMsgMapTable[] = { | |
453 | { MID_MNY_CNM_CH_REQ, cnmChMngrRequestPrivilege }, | |
454 | { MID_MNY_CNM_CH_ABORT, cnmChMngrAbortPrivilege }, | |
455 | { MID_CNM_AIS_CH_GRANT, aisFsmRunEventChGrant }, | |
456 | #if CFG_ENABLE_WIFI_DIRECT | |
457 | { MID_CNM_P2P_CH_GRANT, p2pFsmRunEventChGrant }, /*set in gl_p2p_init.c*/ | |
458 | #else | |
459 | { MID_CNM_P2P_CH_GRANT, mboxDummy }, | |
460 | #endif | |
461 | ||
462 | #if CFG_ENABLE_BT_OVER_WIFI | |
463 | { MID_CNM_BOW_CH_GRANT, bowRunEventChGrant }, | |
464 | #else | |
465 | { MID_CNM_BOW_CH_GRANT, mboxDummy }, | |
466 | #endif | |
467 | ||
468 | /*--------------------------------------------------*/ | |
469 | /* SCN Module Mailbox Messages */ | |
470 | /*--------------------------------------------------*/ | |
471 | { MID_AIS_SCN_SCAN_REQ, scnFsmMsgStart }, | |
472 | { MID_AIS_SCN_SCAN_REQ_V2, scnFsmMsgStart }, | |
473 | { MID_AIS_SCN_SCAN_CANCEL, scnFsmMsgAbort }, | |
474 | { MID_P2P_SCN_SCAN_REQ, scnFsmMsgStart }, | |
475 | { MID_P2P_SCN_SCAN_REQ_V2, scnFsmMsgStart }, | |
476 | { MID_P2P_SCN_SCAN_CANCEL, scnFsmMsgAbort }, | |
477 | { MID_BOW_SCN_SCAN_REQ, scnFsmMsgStart }, | |
478 | { MID_BOW_SCN_SCAN_REQ_V2, scnFsmMsgStart }, | |
479 | { MID_BOW_SCN_SCAN_CANCEL, scnFsmMsgAbort }, | |
480 | { MID_RLM_SCN_SCAN_REQ, scnFsmMsgStart }, | |
481 | { MID_RLM_SCN_SCAN_REQ_V2, scnFsmMsgStart }, | |
482 | { MID_RLM_SCN_SCAN_CANCEL, scnFsmMsgAbort }, | |
483 | { MID_SCN_AIS_SCAN_DONE, aisFsmRunEventScanDone }, | |
484 | #if CFG_ENABLE_WIFI_DIRECT | |
485 | { MID_SCN_P2P_SCAN_DONE, p2pFsmRunEventScanDone }, /*set in gl_p2p_init.c*/ | |
486 | #else | |
487 | { MID_SCN_P2P_SCAN_DONE, mboxDummy }, | |
488 | #endif | |
489 | ||
490 | #if CFG_ENABLE_BT_OVER_WIFI | |
491 | { MID_SCN_BOW_SCAN_DONE, bowResponderScanDone }, | |
492 | #else | |
493 | { MID_SCN_BOW_SCAN_DONE, mboxDummy }, | |
494 | #endif | |
495 | { MID_SCN_RLM_SCAN_DONE, rlmObssScanDone }, | |
496 | ||
497 | /*--------------------------------------------------*/ | |
498 | /* AIS Module Mailbox Messages */ | |
499 | /*--------------------------------------------------*/ | |
500 | { MID_OID_AIS_FSM_JOIN_REQ, aisFsmRunEventAbort }, | |
501 | { MID_OID_AIS_FSM_ABORT, aisFsmRunEventAbort }, | |
502 | { MID_AIS_SAA_FSM_START, saaFsmRunEventStart }, | |
503 | { MID_AIS_SAA_FSM_ABORT, saaFsmRunEventAbort }, | |
504 | { MID_SAA_AIS_JOIN_COMPLETE, aisFsmRunEventJoinComplete }, | |
505 | ||
506 | #if CFG_ENABLE_BT_OVER_WIFI | |
507 | /*--------------------------------------------------*/ | |
508 | /* BOW Module Mailbox Messages */ | |
509 | /*--------------------------------------------------*/ | |
510 | { MID_BOW_SAA_FSM_START, saaFsmRunEventStart }, | |
511 | { MID_BOW_SAA_FSM_ABORT, saaFsmRunEventAbort }, | |
512 | { MID_SAA_BOW_JOIN_COMPLETE, bowFsmRunEventJoinComplete }, | |
513 | #endif | |
514 | ||
515 | #if CFG_ENABLE_WIFI_DIRECT /*set in gl_p2p_init.c*/ | |
516 | { MID_P2P_SAA_FSM_START, saaFsmRunEventStart }, | |
517 | { MID_P2P_SAA_FSM_ABORT, saaFsmRunEventAbort }, | |
518 | { MID_SAA_P2P_JOIN_COMPLETE, p2pFsmRunEventJoinComplete },// TODO: p2pFsmRunEventJoinComplete | |
519 | ||
520 | { MID_MNY_P2P_FUN_SWITCH, p2pFsmRunEventSwitchOPMode }, | |
521 | { MID_MNY_P2P_DEVICE_DISCOVERY, p2pFsmRunEventScanRequest }, | |
522 | { MID_MNY_P2P_CONNECTION_REQ, p2pFsmRunEventConnectionRequest }, | |
523 | { MID_MNY_P2P_CONNECTION_ABORT, p2pFsmRunEventConnectionAbort }, | |
524 | { MID_MNY_P2P_BEACON_UPDATE, p2pFsmRunEventBeaconUpdate }, | |
525 | { MID_MNY_P2P_STOP_AP, p2pFsmRunEventStopAP }, | |
526 | { MID_MNY_P2P_CHNL_REQ, p2pFsmRunEventChannelRequest }, | |
527 | { MID_MNY_P2P_CHNL_ABORT, p2pFsmRunEventChannelAbort }, | |
528 | { MID_MNY_P2P_MGMT_TX, p2pFsmRunEventMgmtFrameTx }, | |
529 | { MID_MNY_P2P_GROUP_DISSOLVE, p2pFsmRunEventDissolve }, | |
530 | { MID_MNY_P2P_MGMT_FRAME_REGISTER, p2pFsmRunEventMgmtFrameRegister }, | |
531 | { MID_MNY_P2P_NET_DEV_REGISTER, p2pFsmRunEventNetDeviceRegister }, | |
532 | { MID_MNY_P2P_START_AP, p2pFsmRunEventStartAP }, | |
533 | { MID_MNY_P2P_MGMT_FRAME_UPDATE, p2pFsmRunEventUpdateMgmtFrame }, | |
534 | #if CFG_SUPPORT_WFD | |
535 | { MID_MNY_P2P_WFD_CFG_UPDATE, p2pFsmRunEventWfdSettingUpdate }, | |
536 | #endif | |
537 | ||
538 | #endif | |
539 | ||
540 | #if CFG_SUPPORT_ADHOC | |
541 | { MID_SCN_AIS_FOUND_IBSS, aisFsmRunEventFoundIBSSPeer }, | |
542 | #endif /* CFG_SUPPORT_ADHOC */ | |
543 | ||
544 | { MID_SAA_AIS_FSM_ABORT, aisFsmRunEventAbort }, | |
545 | { MID_MNY_AIS_REMAIN_ON_CHANNEL,aisFsmRunEventRemainOnChannel }, | |
546 | { MID_MNY_AIS_CANCEL_REMAIN_ON_CHANNEL, aisFsmRunEventCancelRemainOnChannel }, | |
547 | { MID_MNY_AIS_MGMT_TX, aisFsmRunEventMgmtFrameTx } | |
548 | }; | |
549 | ||
550 | /******************************************************************************* | |
551 | * M A C R O S | |
552 | ******************************************************************************** | |
553 | */ | |
554 | ||
555 | #if DBG | |
556 | #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \ | |
557 | ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \ | |
558 | if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \ | |
559 | DBGLOG(CNM, LOUD, ("DO MSG [%d: %s]\n", prMsg->eMsgId, apucDebugMsg[prMsg->eMsgId])); \ | |
560 | arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \ | |
561 | } \ | |
562 | else { \ | |
563 | DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \ | |
564 | cnmMemFree(prAdapter, prMsg); \ | |
565 | } \ | |
566 | } while (0) | |
567 | #else | |
568 | #define MBOX_HNDL_MSG(prAdapter, prMsg) do { \ | |
569 | ASSERT(arMsgMapTable[prMsg->eMsgId].pfMsgHndl); \ | |
570 | if (arMsgMapTable[prMsg->eMsgId].pfMsgHndl) { \ | |
571 | DBGLOG(CNM, LOUD, ("DO MSG [%d]\n", prMsg->eMsgId)); \ | |
572 | arMsgMapTable[prMsg->eMsgId].pfMsgHndl(prAdapter, prMsg); \ | |
573 | } \ | |
574 | else { \ | |
575 | DBGLOG(CNM, ERROR, ("NULL fptr for MSG [%d]\n", prMsg->eMsgId)); \ | |
576 | cnmMemFree(prAdapter, prMsg); \ | |
577 | } \ | |
578 | } while (0) | |
579 | #endif | |
580 | /******************************************************************************* | |
581 | * F U N C T I O N D E C L A R A T I O N S | |
582 | ******************************************************************************** | |
583 | */ | |
584 | ||
585 | /******************************************************************************* | |
586 | * F U N C T I O N S | |
587 | ******************************************************************************** | |
588 | */ | |
589 | ||
590 | ||
591 | /*----------------------------------------------------------------------------*/ | |
592 | /*! | |
593 | * \brief | |
594 | * | |
595 | * \param[in] | |
596 | * | |
597 | * \return none | |
598 | */ | |
599 | /*----------------------------------------------------------------------------*/ | |
600 | VOID | |
601 | mboxInitMsgMap ( | |
602 | VOID | |
603 | ) | |
604 | { | |
605 | UINT_32 i, idx; | |
606 | MSG_HNDL_ENTRY_T rTempEntry; | |
607 | ||
608 | ASSERT((sizeof(arMsgMapTable) / sizeof(MSG_HNDL_ENTRY_T)) == MID_TOTAL_NUM); | |
609 | ||
610 | for (i = 0; i < MID_TOTAL_NUM; i++) { | |
611 | if (arMsgMapTable[i].eMsgId == (ENUM_MSG_ID_T) i) { | |
612 | continue; | |
613 | } | |
614 | for (idx = i + 1; idx < MID_TOTAL_NUM; idx++) { | |
615 | if (arMsgMapTable[idx].eMsgId == (ENUM_MSG_ID_T) i) { | |
616 | break; | |
617 | } | |
618 | } | |
619 | ASSERT(idx < MID_TOTAL_NUM); | |
620 | if (idx >= MID_TOTAL_NUM) { | |
621 | continue; | |
622 | } | |
623 | ||
624 | /* Swap target entry and current entry */ | |
625 | rTempEntry.eMsgId = arMsgMapTable[idx].eMsgId; | |
626 | rTempEntry.pfMsgHndl= arMsgMapTable[idx].pfMsgHndl; | |
627 | ||
628 | arMsgMapTable[idx].eMsgId = arMsgMapTable[i].eMsgId; | |
629 | arMsgMapTable[idx].pfMsgHndl = arMsgMapTable[i].pfMsgHndl; | |
630 | ||
631 | arMsgMapTable[i].eMsgId = rTempEntry.eMsgId; | |
632 | arMsgMapTable[i].pfMsgHndl = rTempEntry.pfMsgHndl; | |
633 | } | |
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 | /*! | |
645 | * \brief | |
646 | * | |
647 | * \param[in] | |
648 | * | |
649 | * \return none | |
650 | */ | |
651 | /*----------------------------------------------------------------------------*/ | |
652 | VOID | |
653 | mboxSetup ( | |
654 | IN P_ADAPTER_T prAdapter, | |
655 | IN ENUM_MBOX_ID_T eMboxId | |
656 | ) | |
657 | { | |
658 | P_MBOX_T prMbox; | |
659 | KAL_SPIN_LOCK_DECLARATION(); | |
660 | ||
661 | ASSERT(eMboxId < MBOX_ID_TOTAL_NUM); | |
662 | ASSERT(prAdapter); | |
663 | ||
664 | prMbox = &(prAdapter->arMbox[eMboxId]); | |
665 | ||
666 | KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
667 | LINK_INITIALIZE(&prMbox->rLinkHead); | |
668 | KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
669 | } | |
670 | ||
671 | /*----------------------------------------------------------------------------*/ | |
672 | /*! | |
673 | * \brief | |
674 | * | |
675 | * \param[in] | |
676 | * | |
677 | * \return none | |
678 | */ | |
679 | /*----------------------------------------------------------------------------*/ | |
680 | VOID | |
681 | mboxSendMsg ( | |
682 | IN P_ADAPTER_T prAdapter, | |
683 | IN ENUM_MBOX_ID_T eMboxId, | |
684 | IN P_MSG_HDR_T prMsg, | |
685 | IN EUNM_MSG_SEND_METHOD_T eMethod | |
686 | ) | |
687 | { | |
688 | P_MBOX_T prMbox; | |
689 | KAL_SPIN_LOCK_DECLARATION(); | |
690 | ||
691 | ASSERT(eMboxId < MBOX_ID_TOTAL_NUM); | |
692 | ASSERT(prMsg); | |
693 | ASSERT(prAdapter); | |
694 | ||
695 | prMbox = &(prAdapter->arMbox[eMboxId]); | |
696 | ||
697 | switch (eMethod) { | |
698 | case MSG_SEND_METHOD_BUF: | |
699 | KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
700 | LINK_INSERT_TAIL(&prMbox->rLinkHead, &prMsg->rLinkEntry); | |
701 | KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
702 | ||
703 | // to wake up main service thread | |
704 | GLUE_SET_EVENT(prAdapter->prGlueInfo); | |
705 | ||
706 | break; | |
707 | ||
708 | case MSG_SEND_METHOD_UNBUF: | |
709 | MBOX_HNDL_MSG(prAdapter, prMsg); | |
710 | break; | |
711 | ||
712 | default: | |
713 | ASSERT(0); | |
714 | break; | |
715 | } | |
716 | } | |
717 | ||
718 | /*----------------------------------------------------------------------------*/ | |
719 | /*! | |
720 | * \brief | |
721 | * | |
722 | * \param[in] | |
723 | * | |
724 | * \return none | |
725 | */ | |
726 | /*----------------------------------------------------------------------------*/ | |
727 | VOID | |
728 | mboxRcvAllMsg ( | |
729 | IN P_ADAPTER_T prAdapter, | |
730 | ENUM_MBOX_ID_T eMboxId | |
731 | ) | |
732 | { | |
733 | P_MBOX_T prMbox; | |
734 | P_MSG_HDR_T prMsg; | |
735 | KAL_SPIN_LOCK_DECLARATION(); | |
736 | ||
737 | ASSERT(eMboxId < MBOX_ID_TOTAL_NUM); | |
738 | ASSERT(prAdapter); | |
739 | ||
740 | prMbox = &(prAdapter->arMbox[eMboxId]); | |
741 | ||
742 | while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) { | |
743 | KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
744 | LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T); | |
745 | KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
746 | ||
747 | ASSERT(prMsg); | |
748 | MBOX_HNDL_MSG(prAdapter, prMsg); | |
749 | } | |
750 | ||
751 | } | |
752 | ||
753 | /*----------------------------------------------------------------------------*/ | |
754 | /*! | |
755 | * \brief | |
756 | * | |
757 | * \param[in] | |
758 | * | |
759 | * \return none | |
760 | */ | |
761 | /*----------------------------------------------------------------------------*/ | |
762 | VOID | |
763 | mboxInitialize ( | |
764 | IN P_ADAPTER_T prAdapter | |
765 | ) | |
766 | { | |
767 | UINT_32 i; | |
768 | ||
769 | ASSERT(prAdapter); | |
770 | ||
771 | /* Initialize Mailbox */ | |
772 | mboxInitMsgMap(); | |
773 | ||
774 | /* Setup/initialize each mailbox */ | |
775 | for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) { | |
776 | mboxSetup(prAdapter, i); | |
777 | } | |
778 | ||
779 | } | |
780 | ||
781 | /*----------------------------------------------------------------------------*/ | |
782 | /*! | |
783 | * \brief | |
784 | * | |
785 | * \param[in] | |
786 | * | |
787 | * \return none | |
788 | */ | |
789 | /*----------------------------------------------------------------------------*/ | |
790 | VOID | |
791 | mboxDestroy ( | |
792 | IN P_ADAPTER_T prAdapter | |
793 | ) | |
794 | { | |
795 | P_MBOX_T prMbox; | |
796 | P_MSG_HDR_T prMsg; | |
797 | UINT_8 i; | |
798 | KAL_SPIN_LOCK_DECLARATION(); | |
799 | ||
800 | ASSERT(prAdapter); | |
801 | ||
802 | for (i = 0; i < MBOX_ID_TOTAL_NUM; i++) { | |
803 | prMbox = &(prAdapter->arMbox[i]); | |
804 | ||
805 | while (!LINK_IS_EMPTY(&prMbox->rLinkHead) ) { | |
806 | KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
807 | LINK_REMOVE_HEAD(&prMbox->rLinkHead, prMsg, P_MSG_HDR_T); | |
808 | KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_MAILBOX); | |
809 | ||
810 | ASSERT(prMsg); | |
811 | cnmMemFree(prAdapter, prMsg); | |
812 | } | |
813 | } | |
814 | } | |
815 | ||
816 | /*----------------------------------------------------------------------------*/ | |
817 | /*! | |
818 | * \brief This is dummy function to prevent empty arMsgMapTable[] for compiling. | |
819 | * | |
820 | * \param[in] | |
821 | * | |
822 | * \return none | |
823 | */ | |
824 | /*----------------------------------------------------------------------------*/ | |
825 | VOID | |
826 | mboxDummy ( | |
827 | IN P_ADAPTER_T prAdapter, | |
828 | IN P_MSG_HDR_T prMsgHdr | |
829 | ) | |
830 | { | |
831 | ASSERT(prAdapter); | |
832 | ||
833 | cnmMemFree(prAdapter, prMsgHdr); | |
834 | ||
835 | return; | |
836 | } | |
837 |