import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6620 / wlan / nic / nic_cmd_event.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic_cmd_event.c#1 $
3 */
4
5 /*! \file nic_cmd_event.c
6 \brief Callback functions for Command packets.
7
8 Various Event packet handlers which will be setup in the callback function of
9 a command packet.
10 */
11
12
13
14 /*
15 ** $Log: nic_cmd_event.c $
16 *
17 * 04 10 2012 yuche.tsai
18 * NULL
19 * Update address for wifi direct connection issue.
20 *
21 * 06 15 2011 cm.chang
22 * [WCXRP00000785] [MT6620 Wi-Fi][Driver][FW] P2P/BOW MAC address is XOR with AIS MAC address
23 * P2P/BOW mac address XOR with local bit instead of OR
24 *
25 * 03 05 2011 wh.su
26 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
27 * add the code to get the check rsponse and indicate to app.
28 *
29 * 03 02 2011 wh.su
30 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
31 * Add security check code.
32 *
33 * 02 24 2011 cp.wu
34 * [WCXRP00000493] [MT6620 Wi-Fi][Driver] Do not indicate redundant disconnection to host when entering into RF test mode
35 * only indicate DISCONNECTION to host when entering RF test if necessary (connected -> disconnected cases)
36 *
37 * 01 20 2011 eddie.chen
38 * [WCXRP00000374] [MT6620 Wi-Fi][DRV] SW debug control
39 * Add Oid for sw control debug command
40 *
41 * 12 31 2010 cp.wu
42 * [WCXRP00000335] [MT6620 Wi-Fi][Driver] change to use milliseconds sleep instead of delay to avoid blocking to system scheduling
43 * change to use msleep() and shorten waiting interval to reduce blocking to other task while Wi-Fi driver is being loaded
44 *
45 * 12 01 2010 cp.wu
46 * [WCXRP00000223] MT6620 Wi-Fi][Driver][FW] Adopt NVRAM parameters when enter/exit RF test mode
47 * reload NVRAM settings before entering RF test mode and leaving from RF test mode.
48 *
49 * 11 01 2010 cp.wu
50 * [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
51 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
52 * 2) Remove CNM CH-RECOVER event handling
53 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
54 *
55 * 10 20 2010 cp.wu
56 * [WCXRP00000117] [MT6620 Wi-Fi][Driver] Add logic for suspending driver when MT6620 is not responding anymore
57 * use OID_CUSTOM_TEST_MODE as indication for driver reset
58 * by dropping pending TX packets
59 *
60 * 10 18 2010 cp.wu
61 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
62 * complete implementation of Android NVRAM access
63 *
64 * 09 21 2010 cp.wu
65 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
66 * Do a complete reset with STA-REC null checking for RF test re-entry
67 *
68 * 09 15 2010 yuche.tsai
69 * NULL
70 * Start to test AT GO only when P2P state is not IDLE.
71 *
72 * 09 09 2010 yuche.tsai
73 * NULL
74 * Add AT GO Test mode after MAC address available.
75 *
76 * 09 03 2010 kevin.huang
77 * NULL
78 * Refine #include sequence and solve recursive/nested #include issue
79 *
80 * 08 30 2010 cp.wu
81 * NULL
82 * eliminate klockwork errors
83 *
84 * 08 16 2010 cp.wu
85 * NULL
86 * Replace CFG_SUPPORT_BOW by CFG_ENABLE_BT_OVER_WIFI.
87 * There is no CFG_SUPPORT_BOW in driver domain source.
88 *
89 * 08 12 2010 cp.wu
90 * NULL
91 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
92 *
93 * 08 11 2010 yuche.tsai
94 * NULL
95 * Add support for P2P Device Address query from FW.
96 *
97 * 08 03 2010 cp.wu
98 * NULL
99 * Centralize mgmt/system service procedures into independent calls.
100 *
101 * 08 02 2010 cp.wu
102 * NULL
103 * reset FSMs before entering RF test mode.
104 *
105 * 07 22 2010 cp.wu
106 *
107 * 1) refine AIS-FSM indent.
108 * 2) when entering RF Test mode, flush 802.1X frames as well
109 * 3) when entering D3 state, flush 802.1X frames as well
110 *
111 * 07 08 2010 cp.wu
112 *
113 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
114 *
115 * 07 05 2010 cp.wu
116 * [WPD00003833][MT6620 and MT5931] Driver migration
117 * 1) change fake BSS_DESC from channel 6 to channel 1 due to channel switching is not done yet.
118 * 2) after MAC address is queried from firmware, all related variables in driver domain should be updated as well
119 *
120 * 06 21 2010 wh.su
121 * [WPD00003840][MT6620 5931] Security migration
122 * remove duplicate variable for migration.
123 *
124 * 06 06 2010 kevin.huang
125 * [WPD00003832][MT6620 5931] Create driver base
126 * [MT6620 5931] Create driver base
127 *
128 * 05 29 2010 cp.wu
129 * [WPD00001943]Create WiFi test driver framework on WinXP
130 * change upon request: indicate as disconnected in driver domain when leaving from RF test mode
131 *
132 * 05 24 2010 cp.wu
133 * [WPD00001943]Create WiFi test driver framework on WinXP
134 * do not clear scanning list array after disassociation
135 *
136 * 05 22 2010 cp.wu
137 * [WPD00001943]Create WiFi test driver framework on WinXP
138 * 1) disable NETWORK_LAYER_ADDRESSES handling temporally.
139 * 2) finish statistics OIDs
140 *
141 * 05 22 2010 cp.wu
142 * [WPD00001943]Create WiFi test driver framework on WinXP
143 * change OID behavior to meet WHQL requirement.
144 *
145 * 05 20 2010 cp.wu
146 * [WPD00001943]Create WiFi test driver framework on WinXP
147 * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
148 * 2) buffer statistics data for 2 seconds
149 * 3) use default value for adhoc parameters instead of 0
150 *
151 * 05 19 2010 cp.wu
152 * [WPD00001943]Create WiFi test driver framework on WinXP
153 * 1) do not take timeout mechanism for power mode oids
154 * 2) retrieve network type from connection status
155 * 3) after disassciation, set radio state to off
156 * 4) TCP option over IPv6 is supported
157 *
158 * 05 17 2010 cp.wu
159 * [WPD00001943]Create WiFi test driver framework on WinXP
160 * correct OID_802_11_DISASSOCIATE handling.
161 *
162 * 05 17 2010 cp.wu
163 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
164 * 1) add timeout handler mechanism for pending command packets
165 * 2) add p2p add/removal key
166 *
167 * 04 16 2010 cp.wu
168 * [WPD00001943]Create WiFi test driver framework on WinXP
169 * treat BUS access failure as kind of card removal.
170 *
171 * 04 14 2010 cp.wu
172 * [WPD00001943]Create WiFi test driver framework on WinXP
173 * information buffer for query oid/ioctl is now buffered in prCmdInfo
174 * * * * * * instead of glue-layer variable to improve multiple oid/ioctl capability
175 *
176 * 04 13 2010 cp.wu
177 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
178 * add framework for BT-over-Wi-Fi support.
179 * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
180 * * * * * * * * * * * * * * 2) command sequence number is now increased atomically
181 * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
182 *
183 * 04 07 2010 cp.wu
184 * [WPD00001943]Create WiFi test driver framework on WinXP
185 * accessing to firmware load/start address, and access to OID handling information
186 * are now handled in glue layer
187 *
188 * 04 07 2010 cp.wu
189 * [WPD00001943]Create WiFi test driver framework on WinXP
190 * rWlanInfo should be placed at adapter rather than glue due to most operations
191 * * * * are done in adapter layer.
192 *
193 * 04 06 2010 cp.wu
194 * [WPD00001943]Create WiFi test driver framework on WinXP
195 * add KAL API: kalFlushPendingTxPackets(), and take use of the API
196 *
197 * 04 06 2010 cp.wu
198 * [WPD00001943]Create WiFi test driver framework on WinXP
199 * eliminate direct access to prGlueInfo->rWlanInfo.eLinkAttr.ucMediaStreamMode from non-glue layer.
200 *
201 * 04 06 2010 jeffrey.chang
202 * [WPD00003826]Initial import for Linux port
203 * improve none-glude code portability
204 *
205 * 04 06 2010 cp.wu
206 * [WPD00001943]Create WiFi test driver framework on WinXP
207 * sync statistics data structure definition with firmware implementation
208 *
209 * 04 06 2010 cp.wu
210 * [WPD00001943]Create WiFi test driver framework on WinXP
211 * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
212 *
213 * 04 06 2010 cp.wu
214 * [WPD00001943]Create WiFi test driver framework on WinXP
215 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
216 *
217 * 03 30 2010 cp.wu
218 * [WPD00001943]Create WiFi test driver framework on WinXP
219 * statistics information OIDs are now handled by querying from firmware domain
220 *
221 * 03 26 2010 cp.wu
222 * [WPD00001943]Create WiFi test driver framework on WinXP
223 * indicate media stream mode after set is done
224 *
225 * 03 24 2010 jeffrey.chang
226 * [WPD00003826]Initial import for Linux port
227 * initial import for Linux port
228 *
229 * 03 03 2010 cp.wu
230 * [WPD00001943]Create WiFi test driver framework on WinXP
231 * implement custom OID: EEPROM read/write access
232 *
233 * 03 03 2010 cp.wu
234 * [WPD00001943]Create WiFi test driver framework on WinXP
235 * implement OID_802_3_MULTICAST_LIST oid handling
236 *
237 * 02 25 2010 cp.wu
238 * [WPD00001943]Create WiFi test driver framework on WinXP
239 * limit RSSI return value to microsoft defined range.
240 *
241 * 02 09 2010 cp.wu
242 * [WPD00001943]Create WiFi test driver framework on WinXP
243 * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
244 * * * * * * * 2. follow MSDN defined behavior when associates to another AP
245 * * * * * * * 3. for firmware download, packet size could be up to 2048 bytes
246 *
247 * 01 29 2010 cp.wu
248 * [WPD00001943]Create WiFi test driver framework on WinXP
249 * block until firmware finished RF test enter/leave then indicate completion to upper layer
250 *
251 * 01 29 2010 cp.wu
252 * [WPD00001943]Create WiFi test driver framework on WinXP
253 * when entering RF test mode and leaving from RF test mode, wait for W_FUNC_RDY bit to be asserted forever until it is set or card is removed.
254 *
255 * 01 27 2010 cp.wu
256 * [WPD00001943]Create WiFi test driver framework on WinXP
257 * 1. eliminate improper variable in rHifInfo
258 * * * * * * * * 2. block TX/ordinary OID when RF test mode is engaged
259 * * * * * * * * 3. wait until firmware finish operation when entering into and leaving from RF test mode
260 * * * * * * * * 4. correct some HAL implementation
261 *
262 * 01 26 2010 cp.wu
263 * [WPD00001943]Create WiFi test driver framework on WinXP
264 * Under WinXP with SDIO, use prGlueInfo->rHifInfo.pvInformationBuffer instead of prGlueInfo->pvInformationBuffer
265 *
266 * 01 22 2010 cp.wu
267 * [WPD00001943]Create WiFi test driver framework on WinXP
268 * implement following 802.11 OIDs:
269 * * * * * OID_802_11_RSSI,
270 * * * * * OID_802_11_RSSI_TRIGGER,
271 * * * * * OID_802_11_STATISTICS,
272 * * * * * OID_802_11_DISASSOCIATE,
273 * * * * * OID_802_11_POWER_MODE
274 *
275 * 01 21 2010 cp.wu
276 * [WPD00001943]Create WiFi test driver framework on WinXP
277 * implement OID_802_11_MEDIA_STREAM_MODE
278 *
279 * 12 30 2009 cp.wu
280 * [WPD00001943]Create WiFi test driver framework on WinXP
281 * 1) According to CMD/EVENT documentation v0.8,
282 * * * * * * * * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
283 * * * * * * * * and result is retrieved by get ATInfo instead
284 * * * * * * * * 2) add 4 counter for recording aggregation statistics
285 ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-12-10 16:47:47 GMT mtk02752
286 ** only handle MCR read when accessing FW domain register
287 ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-12-08 17:37:28 GMT mtk02752
288 ** * refine nicCmdEventQueryMcrRead
289 ** + add TxStatus/RxStatus for RF test QueryInformation OIDs
290 ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-12-02 22:05:45 GMT mtk02752
291 ** kalOidComplete() will decrease i4OidPendingCount
292 ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-12-01 23:02:57 GMT mtk02752
293 ** remove unnecessary spin locks
294 ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-12-01 22:51:18 GMT mtk02752
295 ** maintein i4OidPendingCount
296 ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-11-30 10:55:03 GMT mtk02752
297 ** modify for compatibility
298 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-11-23 14:46:32 GMT mtk02752
299 ** add another version of command-done handler upon new event structure
300 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-29 15:42:33 GMT mtk01461
301 ** Add comment
302 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-04-21 19:32:42 GMT mtk01461
303 ** Add nicCmdEventSetCommon() for general set OID
304 ** \main\maintrunk.MT6620WiFiDriver_Prj\1 2009-04-21 01:40:35 GMT mtk01461
305 ** Command Done Handler
306 */
307
308 /*******************************************************************************
309 * C O M P I L E R F L A G S
310 ********************************************************************************
311 */
312
313 /*******************************************************************************
314 * E X T E R N A L R E F E R E N C E S
315 ********************************************************************************
316 */
317 #include "precomp.h"
318
319
320 /*******************************************************************************
321 * C O N S T A N T S
322 ********************************************************************************
323 */
324
325 /*******************************************************************************
326 * D A T A T Y P E S
327 ********************************************************************************
328 */
329
330 /*******************************************************************************
331 * P U B L I C D A T A
332 ********************************************************************************
333 */
334
335 VOID
336 nicCmdEventQueryMcrRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
337 {
338 UINT_32 u4QueryInfoLen;
339 P_PARAM_CUSTOM_MCR_RW_STRUC_T prMcrRdInfo;
340 P_GLUE_INFO_T prGlueInfo;
341 P_CMD_ACCESS_REG prCmdAccessReg;
342
343
344 ASSERT(prAdapter);
345 ASSERT(prCmdInfo);
346 ASSERT(pucEventBuf);
347
348 /* 4 <2> Update information of OID */
349 if (prCmdInfo->fgIsOid) {
350 prGlueInfo = prAdapter->prGlueInfo;
351 prCmdAccessReg = (P_CMD_ACCESS_REG) (pucEventBuf);
352
353 u4QueryInfoLen = sizeof(PARAM_CUSTOM_MCR_RW_STRUC_T);
354
355 prMcrRdInfo = (P_PARAM_CUSTOM_MCR_RW_STRUC_T) prCmdInfo->pvInformationBuffer;
356 prMcrRdInfo->u4McrOffset = prCmdAccessReg->u4Address;
357 prMcrRdInfo->u4McrData = prCmdAccessReg->u4Data;
358
359 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
360 WLAN_STATUS_SUCCESS);
361 }
362
363 return;
364
365 }
366
367
368 VOID
369 nicCmdEventQuerySwCtrlRead(IN P_ADAPTER_T prAdapter,
370 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
371 {
372 UINT_32 u4QueryInfoLen;
373 P_PARAM_CUSTOM_SW_CTRL_STRUC_T prSwCtrlInfo;
374 P_GLUE_INFO_T prGlueInfo;
375 P_CMD_SW_DBG_CTRL_T prCmdSwCtrl;
376
377 ASSERT(prAdapter);
378 ASSERT(prCmdInfo);
379 ASSERT(pucEventBuf);
380
381 /* 4 <2> Update information of OID */
382 if (prCmdInfo->fgIsOid) {
383 prGlueInfo = prAdapter->prGlueInfo;
384 prCmdSwCtrl = (P_CMD_SW_DBG_CTRL_T) (pucEventBuf);
385
386 u4QueryInfoLen = sizeof(PARAM_CUSTOM_SW_CTRL_STRUC_T);
387
388 prSwCtrlInfo = (P_PARAM_CUSTOM_SW_CTRL_STRUC_T) prCmdInfo->pvInformationBuffer;
389 prSwCtrlInfo->u4Id = prCmdSwCtrl->u4Id;
390 prSwCtrlInfo->u4Data = prCmdSwCtrl->u4Data;
391
392 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
393 WLAN_STATUS_SUCCESS);
394 }
395
396 return;
397
398 }
399
400
401
402 VOID
403 nicCmdEventSetCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
404 {
405 ASSERT(prAdapter);
406 ASSERT(prCmdInfo);
407
408 if (prCmdInfo->fgIsOid) {
409 /* Update Set Infomation Length */
410 kalOidComplete(prAdapter->prGlueInfo,
411 prCmdInfo->fgSetQuery,
412 prCmdInfo->u4InformationBufferLength, WLAN_STATUS_SUCCESS);
413 }
414
415 return;
416 }
417
418 VOID
419 nicCmdEventSetDisassociate(IN P_ADAPTER_T prAdapter,
420 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
421 {
422 ASSERT(prAdapter);
423 ASSERT(prCmdInfo);
424
425 if (prCmdInfo->fgIsOid) {
426 /* Update Set Infomation Length */
427 kalOidComplete(prAdapter->prGlueInfo,
428 prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
429 }
430
431 kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
432
433 #if !defined(LINUX)
434 prAdapter->fgIsRadioOff = TRUE;
435 #endif
436
437 return;
438 }
439
440 VOID
441 nicCmdEventSetIpAddress(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
442 {
443 UINT_32 u4Count;
444
445 ASSERT(prAdapter);
446 ASSERT(prCmdInfo);
447
448 u4Count = (prCmdInfo->u4SetInfoLen - OFFSET_OF(CMD_SET_NETWORK_ADDRESS_LIST, arNetAddress))
449 / sizeof(IPV4_NETWORK_ADDRESS);
450
451 if (prCmdInfo->fgIsOid) {
452 /* Update Set Infomation Length */
453 kalOidComplete(prAdapter->prGlueInfo,
454 prCmdInfo->fgSetQuery,
455 OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress) + u4Count *
456 (OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) +
457 sizeof(PARAM_NETWORK_ADDRESS_IP)), WLAN_STATUS_SUCCESS);
458 }
459
460 return;
461 }
462
463 VOID
464 nicCmdEventQueryRfTestATInfo(IN P_ADAPTER_T prAdapter,
465 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
466 {
467 P_EVENT_TEST_STATUS prTestStatus, prQueryBuffer;
468 P_GLUE_INFO_T prGlueInfo;
469 UINT_32 u4QueryInfoLen;
470
471 ASSERT(prAdapter);
472 ASSERT(prCmdInfo);
473
474 prTestStatus = (P_EVENT_TEST_STATUS) pucEventBuf;
475
476 if (prCmdInfo->fgIsOid) {
477 prGlueInfo = prAdapter->prGlueInfo;
478 prQueryBuffer = (P_EVENT_TEST_STATUS) prCmdInfo->pvInformationBuffer;
479
480 kalMemCopy(prQueryBuffer, prTestStatus, sizeof(EVENT_TEST_STATUS));
481
482 u4QueryInfoLen = sizeof(EVENT_TEST_STATUS);
483
484 /* Update Query Infomation Length */
485 kalOidComplete(prGlueInfo,
486 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
487 }
488
489 return;
490 }
491
492 VOID
493 nicCmdEventQueryLinkQuality(IN P_ADAPTER_T prAdapter,
494 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
495 {
496 PARAM_RSSI rRssi, *prRssi;
497 P_EVENT_LINK_QUALITY prLinkQuality;
498 P_GLUE_INFO_T prGlueInfo;
499 UINT_32 u4QueryInfoLen;
500
501 ASSERT(prAdapter);
502 ASSERT(prCmdInfo);
503
504 prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
505
506 rRssi = (PARAM_RSSI) prLinkQuality->cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
507
508 if (prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState ==
509 PARAM_MEDIA_STATE_CONNECTED) {
510 if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
511 rRssi = PARAM_WHQL_RSSI_MAX_DBM;
512 else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
513 rRssi = PARAM_WHQL_RSSI_MIN_DBM;
514 } else {
515 rRssi = PARAM_WHQL_RSSI_MIN_DBM;
516 }
517
518 if (prCmdInfo->fgIsOid) {
519 prGlueInfo = prAdapter->prGlueInfo;
520 prRssi = (PARAM_RSSI *) prCmdInfo->pvInformationBuffer;
521
522 kalMemCopy(prRssi, &rRssi, sizeof(PARAM_RSSI));
523 u4QueryInfoLen = sizeof(PARAM_RSSI);
524
525 kalOidComplete(prGlueInfo,
526 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
527 }
528 }
529
530
531 /*----------------------------------------------------------------------------*/
532 /*!
533 * @brief This routine is in response of OID_GEN_LINK_SPEED query request
534 *
535 * @param prAdapter Pointer to the Adapter structure.
536 * @param prCmdInfo Pointer to the pending command info
537 * @param pucEventBuf
538 *
539 * @retval none
540 */
541 /*----------------------------------------------------------------------------*/
542 VOID
543 nicCmdEventQueryLinkSpeed(IN P_ADAPTER_T prAdapter,
544 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
545 {
546 P_EVENT_LINK_QUALITY prLinkQuality;
547 P_GLUE_INFO_T prGlueInfo;
548 UINT_32 u4QueryInfoLen;
549 PUINT_32 pu4LinkSpeed;
550
551 ASSERT(prAdapter);
552 ASSERT(prCmdInfo);
553
554 prLinkQuality = (P_EVENT_LINK_QUALITY) pucEventBuf;
555
556 if (prCmdInfo->fgIsOid) {
557 prGlueInfo = prAdapter->prGlueInfo;
558 pu4LinkSpeed = (PUINT_32) (prCmdInfo->pvInformationBuffer);
559
560 if (prLinkQuality->u2LinkSpeed == 0) {
561 *pu4LinkSpeed = 10000; /* 10K * 100bps = 1Mbps */
562 } else {
563 *pu4LinkSpeed = prLinkQuality->u2LinkSpeed * 5000;
564 }
565
566 u4QueryInfoLen = sizeof(UINT_32);
567
568 kalOidComplete(prGlueInfo,
569 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
570 }
571 }
572
573
574 VOID
575 nicCmdEventQueryStatistics(IN P_ADAPTER_T prAdapter,
576 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
577 {
578 P_PARAM_802_11_STATISTICS_STRUCT_T prStatistics;
579 P_EVENT_STATISTICS prEventStatistics;
580 P_GLUE_INFO_T prGlueInfo;
581 UINT_32 u4QueryInfoLen;
582
583 ASSERT(prAdapter);
584 ASSERT(prCmdInfo);
585
586 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
587
588 if (prCmdInfo->fgIsOid) {
589 prGlueInfo = prAdapter->prGlueInfo;
590
591 u4QueryInfoLen = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
592 prStatistics = (P_PARAM_802_11_STATISTICS_STRUCT_T) prCmdInfo->pvInformationBuffer;
593
594 prStatistics->u4Length = sizeof(PARAM_802_11_STATISTICS_STRUCT_T);
595 prStatistics->rTransmittedFragmentCount
596 = prEventStatistics->rTransmittedFragmentCount;
597 prStatistics->rMulticastTransmittedFrameCount
598 = prEventStatistics->rMulticastTransmittedFrameCount;
599 prStatistics->rFailedCount = prEventStatistics->rFailedCount;
600 prStatistics->rRetryCount = prEventStatistics->rRetryCount;
601 prStatistics->rMultipleRetryCount = prEventStatistics->rMultipleRetryCount;
602 prStatistics->rRTSSuccessCount = prEventStatistics->rRTSSuccessCount;
603 prStatistics->rRTSFailureCount = prEventStatistics->rRTSFailureCount;
604 prStatistics->rACKFailureCount = prEventStatistics->rACKFailureCount;
605 prStatistics->rFrameDuplicateCount = prEventStatistics->rFrameDuplicateCount;
606 prStatistics->rReceivedFragmentCount = prEventStatistics->rReceivedFragmentCount;
607 prStatistics->rMulticastReceivedFrameCount
608 = prEventStatistics->rMulticastReceivedFrameCount;
609 prStatistics->rFCSErrorCount = prEventStatistics->rFCSErrorCount;
610 prStatistics->rTKIPLocalMICFailures.QuadPart = 0;
611 prStatistics->rTKIPICVErrors.QuadPart = 0;
612 prStatistics->rTKIPCounterMeasuresInvoked.QuadPart = 0;
613 prStatistics->rTKIPReplays.QuadPart = 0;
614 prStatistics->rCCMPFormatErrors.QuadPart = 0;
615 prStatistics->rCCMPReplays.QuadPart = 0;
616 prStatistics->rCCMPDecryptErrors.QuadPart = 0;
617 prStatistics->rFourWayHandshakeFailures.QuadPart = 0;
618 prStatistics->rWEPUndecryptableCount.QuadPart = 0;
619 prStatistics->rWEPICVErrorCount.QuadPart = 0;
620 prStatistics->rDecryptSuccessCount.QuadPart = 0;
621 prStatistics->rDecryptFailureCount.QuadPart = 0;
622
623 kalOidComplete(prGlueInfo,
624 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
625 }
626 }
627
628 VOID
629 nicCmdEventEnterRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
630 {
631 UINT_32 u4WHISR = 0, u4Value = 0;
632 UINT_8 aucTxCount[8];
633
634 ASSERT(prAdapter);
635 ASSERT(prCmdInfo);
636
637 /* [driver-land] */
638 prAdapter->fgTestMode = TRUE;
639
640 /* 0. always indicate disconnection */
641 if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
642 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
643 WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
644 }
645 /* 1. Remove pending TX */
646 nicTxRelease(prAdapter);
647
648 /* 1.1 clear pending Security / Management Frames */
649 kalClearSecurityFrames(prAdapter->prGlueInfo);
650 kalClearMgmtFrames(prAdapter->prGlueInfo);
651
652 /* 1.2 clear pending TX packet queued in glue layer */
653 kalFlushPendingTxPackets(prAdapter->prGlueInfo);
654
655 /* 2. Reset driver-domain FSMs */
656 nicUninitMGMT(prAdapter);
657
658 nicResetSystemService(prAdapter);
659 nicInitMGMT(prAdapter, NULL);
660
661 /* 3. Disable Interrupt */
662 HAL_INTR_DISABLE(prAdapter);
663
664 /* 4. Block til firmware completed entering into RF test mode */
665 kalMsleep(500);
666 while (1) {
667 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
668
669 if (u4Value & WCIR_WLAN_READY) {
670 break;
671 } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
672 || fgIsBusAccessFailed == TRUE) {
673 if (prCmdInfo->fgIsOid) {
674 /* Update Set Infomation Length */
675 kalOidComplete(prAdapter->prGlueInfo,
676 prCmdInfo->fgSetQuery,
677 prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
678
679 }
680 return;
681 } else
682 kalMsleep(10);
683 }
684
685 /* 5. Clear Interrupt Status */
686 HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8) & u4WHISR);
687 if (HAL_IS_TX_DONE_INTR(u4WHISR)) {
688 HAL_READ_TX_RELEASED_COUNT(prAdapter, aucTxCount);
689 }
690 /* 6. Reset TX Counter */
691 nicTxResetResource(prAdapter);
692
693 /* 7. Re-enable Interrupt */
694 HAL_INTR_ENABLE(prAdapter);
695
696 /* 8. completion indication */
697 if (prCmdInfo->fgIsOid) {
698 /* Update Set Infomation Length */
699 kalOidComplete(prAdapter->prGlueInfo,
700 prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
701 }
702 #if CFG_SUPPORT_NVRAM
703 /* 9. load manufacture data */
704 wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
705 #endif
706
707 return;
708 }
709
710 VOID
711 nicCmdEventLeaveRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
712 {
713 UINT_32 u4WHISR = 0, u4Value = 0;
714 UINT_8 aucTxCount[8];
715
716 ASSERT(prAdapter);
717 ASSERT(prCmdInfo);
718
719 /* 1. Disable Interrupt */
720 HAL_INTR_DISABLE(prAdapter);
721
722 /* 2. Block til firmware completed leaving from RF test mode */
723 kalMsleep(500);
724 while (1) {
725 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
726
727 if (u4Value & WCIR_WLAN_READY) {
728 break;
729 } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
730 || fgIsBusAccessFailed == TRUE) {
731 if (prCmdInfo->fgIsOid) {
732 /* Update Set Infomation Length */
733 kalOidComplete(prAdapter->prGlueInfo,
734 prCmdInfo->fgSetQuery,
735 prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);
736
737 }
738 return;
739 } else {
740 kalMsleep(10);
741 }
742 }
743
744 /* 3. Clear Interrupt Status */
745 HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8) & u4WHISR);
746 if (HAL_IS_TX_DONE_INTR(u4WHISR)) {
747 HAL_READ_TX_RELEASED_COUNT(prAdapter, aucTxCount);
748 }
749 /* 4. Reset TX Counter */
750 nicTxResetResource(prAdapter);
751
752 /* 5. Re-enable Interrupt */
753 HAL_INTR_ENABLE(prAdapter);
754
755 /* 6. set driver-land variable */
756 prAdapter->fgTestMode = FALSE;
757
758 /* 7. completion indication */
759 if (prCmdInfo->fgIsOid) {
760 /* Update Set Infomation Length */
761 kalOidComplete(prAdapter->prGlueInfo,
762 prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
763 }
764
765 /* 8. Indicate as disconnected */
766 if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
767
768 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
769 WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
770
771 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
772 }
773 #if CFG_SUPPORT_NVRAM
774 /* 9. load manufacture data */
775 wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
776 #endif
777
778 /* 10. Override network address */
779 wlanUpdateNetworkAddress(prAdapter);
780
781 return;
782 }
783
784 VOID
785 nicCmdEventQueryAddress(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
786 {
787 UINT_32 u4QueryInfoLen;
788 P_GLUE_INFO_T prGlueInfo;
789 P_EVENT_BASIC_CONFIG prEventBasicConfig;
790
791 ASSERT(prAdapter);
792 ASSERT(prCmdInfo);
793 ASSERT(pucEventBuf);
794
795 prEventBasicConfig = (P_EVENT_BASIC_CONFIG) (pucEventBuf);
796
797 /* copy to adapter */
798 kalMemCopy(&(prAdapter->rMyMacAddr), &(prEventBasicConfig->rMyMacAddr), MAC_ADDR_LEN);
799
800 /* 4 <2> Update information of OID */
801 if (prCmdInfo->fgIsOid) {
802 prGlueInfo = prAdapter->prGlueInfo;
803
804 kalMemCopy(prCmdInfo->pvInformationBuffer, &(prEventBasicConfig->rMyMacAddr),
805 MAC_ADDR_LEN);
806 u4QueryInfoLen = MAC_ADDR_LEN;
807
808 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
809 WLAN_STATUS_SUCCESS);
810 }
811 /* 4 <3> Update new MAC address and all 3 networks */
812 COPY_MAC_ADDR(prAdapter->rWifiVar.aucMacAddress, prAdapter->rMyMacAddr);
813 COPY_MAC_ADDR(prAdapter->rWifiVar.aucDeviceAddress, prAdapter->rMyMacAddr);
814 prAdapter->rWifiVar.aucDeviceAddress[0] ^= MAC_ADDR_LOCAL_ADMIN;
815
816 COPY_MAC_ADDR(prAdapter->rWifiVar.aucInterfaceAddress, prAdapter->rMyMacAddr);
817 prAdapter->rWifiVar.aucInterfaceAddress[0] ^= MAC_ADDR_LOCAL_ADMIN;
818
819 COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].aucOwnMacAddr,
820 prAdapter->rMyMacAddr);
821
822 #if CFG_ENABLE_WIFI_DIRECT
823 if (prAdapter->fgIsP2PRegistered) {
824 COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX].aucOwnMacAddr,
825 prAdapter->rWifiVar.aucDeviceAddress);
826 }
827 #endif
828
829 #if CFG_ENABLE_BT_OVER_WIFI
830 COPY_MAC_ADDR(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX].aucOwnMacAddr,
831 prAdapter->rWifiVar.aucDeviceAddress);
832 #endif
833
834 #if CFG_TEST_WIFI_DIRECT_GO
835 if (prAdapter->rWifiVar.prP2pFsmInfo->eCurrentState == P2P_STATE_IDLE) {
836 wlanEnableP2pFunction(prAdapter);
837
838 wlanEnableATGO(prAdapter);
839 }
840 #endif
841
842 kalUpdateMACAddress(prAdapter->prGlueInfo, prAdapter->rWifiVar.aucMacAddress);
843
844 return;
845 }
846
847 VOID
848 nicCmdEventQueryMcastAddr(IN P_ADAPTER_T prAdapter,
849 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
850 {
851 UINT_32 u4QueryInfoLen;
852 P_GLUE_INFO_T prGlueInfo;
853 P_EVENT_MAC_MCAST_ADDR prEventMacMcastAddr;
854
855 ASSERT(prAdapter);
856 ASSERT(prCmdInfo);
857 ASSERT(pucEventBuf);
858
859 /* 4 <2> Update information of OID */
860 if (prCmdInfo->fgIsOid) {
861 prGlueInfo = prAdapter->prGlueInfo;
862 prEventMacMcastAddr = (P_EVENT_MAC_MCAST_ADDR) (pucEventBuf);
863
864 u4QueryInfoLen = prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN;
865
866 /* buffer length check */
867 if (prCmdInfo->u4InformationBufferLength < u4QueryInfoLen) {
868 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
869 WLAN_STATUS_BUFFER_TOO_SHORT);
870 } else {
871 kalMemCopy(prCmdInfo->pvInformationBuffer,
872 prEventMacMcastAddr->arAddress,
873 prEventMacMcastAddr->u4NumOfGroupAddr * MAC_ADDR_LEN);
874
875 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
876 WLAN_STATUS_SUCCESS);
877 }
878 }
879 }
880
881 VOID
882 nicCmdEventQueryEepromRead(IN P_ADAPTER_T prAdapter,
883 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
884 {
885 UINT_32 u4QueryInfoLen;
886 P_PARAM_CUSTOM_EEPROM_RW_STRUC_T prEepromRdInfo;
887 P_GLUE_INFO_T prGlueInfo;
888 P_EVENT_ACCESS_EEPROM prEventAccessEeprom;
889
890 ASSERT(prAdapter);
891 ASSERT(prCmdInfo);
892 ASSERT(pucEventBuf);
893
894 /* 4 <2> Update information of OID */
895 if (prCmdInfo->fgIsOid) {
896 prGlueInfo = prAdapter->prGlueInfo;
897 prEventAccessEeprom = (P_EVENT_ACCESS_EEPROM) (pucEventBuf);
898
899 u4QueryInfoLen = sizeof(PARAM_CUSTOM_EEPROM_RW_STRUC_T);
900
901 prEepromRdInfo = (P_PARAM_CUSTOM_EEPROM_RW_STRUC_T) prCmdInfo->pvInformationBuffer;
902 prEepromRdInfo->ucEepromIndex = (UINT_8) (prEventAccessEeprom->u2Offset);
903 prEepromRdInfo->u2EepromData = prEventAccessEeprom->u2Data;
904
905 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
906 WLAN_STATUS_SUCCESS);
907 }
908
909 return;
910
911 }
912
913
914 VOID
915 nicCmdEventSetMediaStreamMode(IN P_ADAPTER_T prAdapter,
916 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
917 {
918 PARAM_MEDIA_STREAMING_INDICATION rParamMediaStreamIndication;
919
920 ASSERT(prAdapter);
921 ASSERT(prCmdInfo);
922
923 if (prCmdInfo->fgIsOid) {
924 /* Update Set Infomation Length */
925 kalOidComplete(prAdapter->prGlueInfo,
926 prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
927 }
928
929 rParamMediaStreamIndication.rStatus.eStatusType = ENUM_STATUS_TYPE_MEDIA_STREAM_MODE;
930 rParamMediaStreamIndication.eMediaStreamMode =
931 prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode == 0 ?
932 ENUM_MEDIA_STREAM_OFF : ENUM_MEDIA_STREAM_ON;
933
934 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
935 WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
936 (PVOID) & rParamMediaStreamIndication,
937 sizeof(PARAM_MEDIA_STREAMING_INDICATION));
938 }
939
940
941 /* Statistics responder */
942 VOID
943 nicCmdEventQueryXmitOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
944 {
945 P_EVENT_STATISTICS prEventStatistics;
946 P_GLUE_INFO_T prGlueInfo;
947 UINT_32 u4QueryInfoLen;
948 PUINT_32 pu4Data;
949 PUINT_64 pu8Data;
950
951 ASSERT(prAdapter);
952 ASSERT(prCmdInfo);
953
954 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
955
956 if (prCmdInfo->fgIsOid) {
957 prGlueInfo = prAdapter->prGlueInfo;
958
959 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
960 u4QueryInfoLen = sizeof(UINT_32);
961
962 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
963 *pu4Data = (UINT_32) prEventStatistics->rTransmittedFragmentCount.QuadPart;
964 } else {
965 u4QueryInfoLen = sizeof(UINT_64);
966
967 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
968 *pu8Data = prEventStatistics->rTransmittedFragmentCount.QuadPart;
969 }
970
971 kalOidComplete(prGlueInfo,
972 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
973 }
974 }
975
976
977 VOID
978 nicCmdEventQueryRecvOk(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
979 {
980 P_EVENT_STATISTICS prEventStatistics;
981 P_GLUE_INFO_T prGlueInfo;
982 UINT_32 u4QueryInfoLen;
983 PUINT_32 pu4Data;
984 PUINT_64 pu8Data;
985
986 ASSERT(prAdapter);
987 ASSERT(prCmdInfo);
988
989 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
990
991 if (prCmdInfo->fgIsOid) {
992 prGlueInfo = prAdapter->prGlueInfo;
993
994 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
995 u4QueryInfoLen = sizeof(UINT_32);
996
997 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
998 *pu4Data = (UINT_32) prEventStatistics->rReceivedFragmentCount.QuadPart;
999 } else {
1000 u4QueryInfoLen = sizeof(UINT_64);
1001
1002 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1003 *pu8Data = prEventStatistics->rReceivedFragmentCount.QuadPart;
1004 }
1005
1006 kalOidComplete(prGlueInfo,
1007 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1008 }
1009 }
1010
1011 VOID
1012 nicCmdEventQueryXmitError(IN P_ADAPTER_T prAdapter,
1013 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1014 {
1015 P_EVENT_STATISTICS prEventStatistics;
1016 P_GLUE_INFO_T prGlueInfo;
1017 UINT_32 u4QueryInfoLen;
1018 PUINT_32 pu4Data;
1019 PUINT_64 pu8Data;
1020
1021 ASSERT(prAdapter);
1022 ASSERT(prCmdInfo);
1023
1024 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1025
1026 if (prCmdInfo->fgIsOid) {
1027 prGlueInfo = prAdapter->prGlueInfo;
1028
1029 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1030 u4QueryInfoLen = sizeof(UINT_32);
1031
1032 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1033 *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
1034 } else {
1035 u4QueryInfoLen = sizeof(UINT_64);
1036
1037 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1038 *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
1039 }
1040
1041 kalOidComplete(prGlueInfo,
1042 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1043 }
1044 }
1045
1046
1047 VOID
1048 nicCmdEventQueryRecvError(IN P_ADAPTER_T prAdapter,
1049 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1050 {
1051 P_EVENT_STATISTICS prEventStatistics;
1052 P_GLUE_INFO_T prGlueInfo;
1053 UINT_32 u4QueryInfoLen;
1054 PUINT_32 pu4Data;
1055 PUINT_64 pu8Data;
1056
1057 ASSERT(prAdapter);
1058 ASSERT(prCmdInfo);
1059
1060 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1061
1062 if (prCmdInfo->fgIsOid) {
1063 prGlueInfo = prAdapter->prGlueInfo;
1064
1065 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1066 u4QueryInfoLen = sizeof(UINT_32);
1067
1068 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1069 *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
1070 /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
1071 } else {
1072 u4QueryInfoLen = sizeof(UINT_64);
1073
1074 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1075 *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
1076 /* @FIXME, RX_ERROR_DROP_COUNT/RX_FIFO_FULL_DROP_COUNT is not calculated */
1077 }
1078
1079 kalOidComplete(prGlueInfo,
1080 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1081 }
1082 }
1083
1084
1085 VOID
1086 nicCmdEventQueryRecvNoBuffer(IN P_ADAPTER_T prAdapter,
1087 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1088 {
1089 P_EVENT_STATISTICS prEventStatistics;
1090 P_GLUE_INFO_T prGlueInfo;
1091 UINT_32 u4QueryInfoLen;
1092 PUINT_32 pu4Data;
1093 PUINT_64 pu8Data;
1094
1095 ASSERT(prAdapter);
1096 ASSERT(prCmdInfo);
1097
1098 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1099
1100 if (prCmdInfo->fgIsOid) {
1101 prGlueInfo = prAdapter->prGlueInfo;
1102
1103 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1104 u4QueryInfoLen = sizeof(UINT_32);
1105
1106 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1107 *pu4Data = 0; /* @FIXME? */
1108 } else {
1109 u4QueryInfoLen = sizeof(UINT_64);
1110
1111 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1112 *pu8Data = 0; /* @FIXME? */
1113 }
1114
1115 kalOidComplete(prGlueInfo,
1116 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1117 }
1118 }
1119
1120
1121 VOID
1122 nicCmdEventQueryRecvCrcError(IN P_ADAPTER_T prAdapter,
1123 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1124 {
1125 P_EVENT_STATISTICS prEventStatistics;
1126 P_GLUE_INFO_T prGlueInfo;
1127 UINT_32 u4QueryInfoLen;
1128 PUINT_32 pu4Data;
1129 PUINT_64 pu8Data;
1130
1131 ASSERT(prAdapter);
1132 ASSERT(prCmdInfo);
1133
1134 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1135
1136 if (prCmdInfo->fgIsOid) {
1137 prGlueInfo = prAdapter->prGlueInfo;
1138
1139 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1140 u4QueryInfoLen = sizeof(UINT_32);
1141
1142 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1143 *pu4Data = (UINT_32) prEventStatistics->rFCSErrorCount.QuadPart;
1144 } else {
1145 u4QueryInfoLen = sizeof(UINT_64);
1146
1147 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1148 *pu8Data = prEventStatistics->rFCSErrorCount.QuadPart;
1149 }
1150
1151 kalOidComplete(prGlueInfo,
1152 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1153 }
1154 }
1155
1156
1157 VOID
1158 nicCmdEventQueryRecvErrorAlignment(IN P_ADAPTER_T prAdapter,
1159 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1160 {
1161 P_EVENT_STATISTICS prEventStatistics;
1162 P_GLUE_INFO_T prGlueInfo;
1163 UINT_32 u4QueryInfoLen;
1164 PUINT_32 pu4Data;
1165 PUINT_64 pu8Data;
1166
1167 ASSERT(prAdapter);
1168 ASSERT(prCmdInfo);
1169
1170 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1171
1172 if (prCmdInfo->fgIsOid) {
1173 prGlueInfo = prAdapter->prGlueInfo;
1174
1175 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1176 u4QueryInfoLen = sizeof(UINT_32);
1177
1178 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1179 *pu4Data = (UINT_32) 0; /* @FIXME */
1180 } else {
1181 u4QueryInfoLen = sizeof(UINT_64);
1182
1183 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1184 *pu8Data = 0; /* @FIXME */
1185 }
1186
1187 kalOidComplete(prGlueInfo,
1188 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1189 }
1190 }
1191
1192
1193 VOID
1194 nicCmdEventQueryXmitOneCollision(IN P_ADAPTER_T prAdapter,
1195 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1196 {
1197 P_EVENT_STATISTICS prEventStatistics;
1198 P_GLUE_INFO_T prGlueInfo;
1199 UINT_32 u4QueryInfoLen;
1200 PUINT_32 pu4Data;
1201 PUINT_64 pu8Data;
1202
1203 ASSERT(prAdapter);
1204 ASSERT(prCmdInfo);
1205
1206 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1207
1208 if (prCmdInfo->fgIsOid) {
1209 prGlueInfo = prAdapter->prGlueInfo;
1210
1211 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1212 u4QueryInfoLen = sizeof(UINT_32);
1213
1214 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1215 *pu4Data =
1216 (UINT_32) (prEventStatistics->rMultipleRetryCount.QuadPart -
1217 prEventStatistics->rRetryCount.QuadPart);
1218 } else {
1219 u4QueryInfoLen = sizeof(UINT_64);
1220
1221 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1222 *pu8Data =
1223 (UINT_64) (prEventStatistics->rMultipleRetryCount.QuadPart -
1224 prEventStatistics->rRetryCount.QuadPart);
1225 }
1226
1227 kalOidComplete(prGlueInfo,
1228 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1229 }
1230 }
1231
1232
1233 VOID
1234 nicCmdEventQueryXmitMoreCollisions(IN P_ADAPTER_T prAdapter,
1235 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1236 {
1237 P_EVENT_STATISTICS prEventStatistics;
1238 P_GLUE_INFO_T prGlueInfo;
1239 UINT_32 u4QueryInfoLen;
1240 PUINT_32 pu4Data;
1241 PUINT_64 pu8Data;
1242
1243 ASSERT(prAdapter);
1244 ASSERT(prCmdInfo);
1245
1246 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1247
1248 if (prCmdInfo->fgIsOid) {
1249 prGlueInfo = prAdapter->prGlueInfo;
1250
1251 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1252 u4QueryInfoLen = sizeof(UINT_32);
1253
1254 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1255 *pu4Data = (UINT_32) prEventStatistics->rMultipleRetryCount.QuadPart;
1256 } else {
1257 u4QueryInfoLen = sizeof(UINT_64);
1258
1259 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1260 *pu8Data = (UINT_64) prEventStatistics->rMultipleRetryCount.QuadPart;
1261 }
1262
1263 kalOidComplete(prGlueInfo,
1264 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1265 }
1266 }
1267
1268
1269 VOID
1270 nicCmdEventQueryXmitMaxCollisions(IN P_ADAPTER_T prAdapter,
1271 IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1272 {
1273 P_EVENT_STATISTICS prEventStatistics;
1274 P_GLUE_INFO_T prGlueInfo;
1275 UINT_32 u4QueryInfoLen;
1276 PUINT_32 pu4Data;
1277 PUINT_64 pu8Data;
1278
1279 ASSERT(prAdapter);
1280 ASSERT(prCmdInfo);
1281
1282 prEventStatistics = (P_EVENT_STATISTICS) pucEventBuf;
1283
1284 if (prCmdInfo->fgIsOid) {
1285 prGlueInfo = prAdapter->prGlueInfo;
1286
1287 if (prCmdInfo->u4InformationBufferLength == sizeof(UINT_32)) {
1288 u4QueryInfoLen = sizeof(UINT_32);
1289
1290 pu4Data = (PUINT_32) prCmdInfo->pvInformationBuffer;
1291 *pu4Data = (UINT_32) prEventStatistics->rFailedCount.QuadPart;
1292 } else {
1293 u4QueryInfoLen = sizeof(UINT_64);
1294
1295 pu8Data = (PUINT_64) prCmdInfo->pvInformationBuffer;
1296 *pu8Data = (UINT_64) prEventStatistics->rFailedCount.QuadPart;
1297 }
1298
1299 kalOidComplete(prGlueInfo,
1300 prCmdInfo->fgSetQuery, u4QueryInfoLen, WLAN_STATUS_SUCCESS);
1301 }
1302 }
1303
1304
1305 /*----------------------------------------------------------------------------*/
1306 /*!
1307 * @brief This function is called when command by OID/ioctl has been timeout
1308 *
1309 * @param prAdapter Pointer to the Adapter structure.
1310 * @param prCmdInfo Pointer to the command information
1311 *
1312 * @return TRUE
1313 * FALSE
1314 */
1315 /*----------------------------------------------------------------------------*/
1316 VOID nicOidCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
1317 {
1318 ASSERT(prAdapter);
1319
1320 kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
1321 }
1322
1323
1324 /*----------------------------------------------------------------------------*/
1325 /*!
1326 * @brief This function is a generic command timeout handler
1327 *
1328 * @param pfnOidHandler Pointer to the OID handler
1329 *
1330 * @return none
1331 */
1332 /*----------------------------------------------------------------------------*/
1333 VOID nicCmdTimeoutCommon(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
1334 {
1335 ASSERT(prAdapter);
1336 }
1337
1338
1339 /*----------------------------------------------------------------------------*/
1340 /*!
1341 * @brief This function is called when command for entering RF test has
1342 * failed sending due to timeout (highly possibly by firmware crash)
1343 *
1344 * @param prAdapter Pointer to the Adapter structure.
1345 * @param prCmdInfo Pointer to the command information
1346 *
1347 * @return none
1348 *
1349 */
1350 /*----------------------------------------------------------------------------*/
1351 VOID nicOidCmdEnterRFTestTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
1352 {
1353 ASSERT(prAdapter);
1354
1355 /* 1. Remove pending TX frames */
1356 nicTxRelease(prAdapter);
1357
1358 /* 1.1 clear pending Security / Management Frames */
1359 kalClearSecurityFrames(prAdapter->prGlueInfo);
1360 kalClearMgmtFrames(prAdapter->prGlueInfo);
1361
1362 /* 1.2 clear pending TX packet queued in glue layer */
1363 kalFlushPendingTxPackets(prAdapter->prGlueInfo);
1364
1365 /* 2. indiate for OID failure */
1366 kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
1367 }
1368
1369
1370 /*----------------------------------------------------------------------------*/
1371 /*!
1372 * @brief This function is called when command for memory dump has
1373 * replied a event.
1374 *
1375 * @param prAdapter Pointer to the Adapter structure.
1376 * @param prCmdInfo Pointer to the command information
1377 * @param pucEventBuf Pointer to event buffer
1378 *
1379 * @return none
1380 *
1381 */
1382 /*----------------------------------------------------------------------------*/
1383 VOID
1384 nicCmdEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1385 {
1386 UINT_32 u4QueryInfoLen;
1387 P_PARAM_CUSTOM_MEM_DUMP_STRUC_T prMemDumpInfo;
1388 P_GLUE_INFO_T prGlueInfo;
1389 P_EVENT_DUMP_MEM_T prEventDumpMem;
1390 static UINT_8 aucPath[256];
1391 static UINT_32 u4CurTimeTick;
1392
1393 ASSERT(prAdapter);
1394 ASSERT(prCmdInfo);
1395 ASSERT(pucEventBuf);
1396
1397 /* 4 <2> Update information of OID */
1398 if (prCmdInfo->fgIsOid) {
1399 prGlueInfo = prAdapter->prGlueInfo;
1400 prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);
1401
1402 u4QueryInfoLen = sizeof(P_PARAM_CUSTOM_MEM_DUMP_STRUC_T);
1403
1404 prMemDumpInfo = (P_PARAM_CUSTOM_MEM_DUMP_STRUC_T) prCmdInfo->pvInformationBuffer;
1405 prMemDumpInfo->u4Address = prEventDumpMem->u4Address;
1406 prMemDumpInfo->u4Length = prEventDumpMem->u4Length;
1407 prMemDumpInfo->u4RemainLength = prEventDumpMem->u4RemainLength;
1408 prMemDumpInfo->ucFragNum = prEventDumpMem->ucFragNum;
1409
1410 #if 0
1411 do {
1412 UINT_32 i = 0;
1413 printk("Rx dump address 0x%X, Length %d, FragNum %d, remain %d\n",
1414 prEventDumpMem->u4Address,
1415 prEventDumpMem->u4Length,
1416 prEventDumpMem->ucFragNum, prEventDumpMem->u4RemainLength);
1417 #if 0
1418 for (i = 0; i < prEventDumpMem->u4Length; i++) {
1419 printk("%02X ", prEventDumpMem->aucBuffer[i]);
1420 if (i % 32 == 31) {
1421 printk("\n");
1422 }
1423 }
1424 #endif
1425 } while (FALSE);
1426 #endif
1427
1428 if (prEventDumpMem->ucFragNum == 1) {
1429 /* Store memory dump into sdcard,
1430 * path /sdcard/dump_<current system tick>_<memory address>_<memory length>.hex
1431 */
1432 u4CurTimeTick = kalGetTimeTick();
1433 sprintf(aucPath, "/sdcard/dump_%ld_0x%08lX_%ld.hex",
1434 u4CurTimeTick,
1435 prEventDumpMem->u4Address,
1436 prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
1437 kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0],
1438 prEventDumpMem->u4Length);
1439 } else {
1440 /* Append current memory dump to the hex file */
1441 kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0],
1442 prEventDumpMem->u4Length);
1443 }
1444
1445 if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
1446 /* The request is finished or firmware response a error */
1447 /* Reply time tick to iwpriv */
1448 *((PUINT_32) prCmdInfo->pvInformationBuffer) = u4CurTimeTick;
1449 kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
1450 WLAN_STATUS_SUCCESS);
1451 } else {
1452 /* The memory dump request is not finished, Send next command */
1453 wlanSendMemDumpCmd(prAdapter,
1454 prCmdInfo->pvInformationBuffer,
1455 prCmdInfo->u4InformationBufferLength);
1456 }
1457 }
1458
1459 return;
1460
1461 }