import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6620 / wlan / mgmt / swcr.c
CommitLineData
6fa3eb70
S
1/*
2** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/swcr.c#1 $
3*/
4
5/*! \file "swcr.c"
6 \brief
7
8*/
9
10
11
12/*
13** $Log: swcr.c $
14 *
15 * 06 04 2012 tsaiyuan.hsu
16 * [WCXRP00001249] [ALPS.ICS] Daily build warning on "wlan/mgmt/swcr.c#1"
17 * resolve build waring for "WNM_UNIT_TEST not defined".
18 *
19 * 03 02 2012 terry.wu
20 * NULL
21 * Sync CFG80211 modification from branch 2,2.
22 *
23 * 01 05 2012 tsaiyuan.hsu
24 * [WCXRP00001157] [MT6620 Wi-Fi][FW][DRV] add timing measurement support for 802.11v
25 * add timing measurement support for 802.11v.
26 *
27 * 11 22 2011 tsaiyuan.hsu
28 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
29 * keep debug counter setting after wake up.
30 *
31 * 11 15 2011 cm.chang
32 * NULL
33 * Fix compiling warning
34 *
35 * 11 11 2011 tsaiyuan.hsu
36 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
37 * fix debug counters of rx in driver.
38 *
39 * 11 11 2011 tsaiyuan.hsu
40 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
41 * add debug counters of bb and ar for xlog.
42 *
43 * 11 10 2011 eddie.chen
44 * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
45 * Modify the QM xlog level and remove LOG_FUNC.
46 *
47 * 11 08 2011 tsaiyuan.hsu
48 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
49 * add debug counters, eCurPsProf, for PS.
50 *
51 * 11 07 2011 tsaiyuan.hsu
52 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
53 * add debug counters and periodically dump counters for debugging.
54 *
55 * 11 03 2011 wh.su
56 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
57 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
58 *
59 * 08 31 2011 tsaiyuan.hsu
60 * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
61 * remove obsolete code.
62 *
63 * 08 15 2011 tsaiyuan.hsu
64 * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
65 * add swcr in driver reg, 0x9fxx0000, to disable roaming .
66 *
67 * 05 11 2011 eddie.chen
68 * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
69 * Fix dest type when GO packet copying.
70 *
71 * 05 09 2011 eddie.chen
72 * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
73 * Check free number before copying broadcast packet.
74 *
75 * 04 14 2011 eddie.chen
76 * [WCXRP00000603] [MT6620 Wi-Fi][DRV] Fix Klocwork warning
77 * Check the SW RFB free. Fix the compile warning..
78 *
79 * 04 12 2011 eddie.chen
80 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
81 * Fix the sta index in processing security frame
82 * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
83 * Add debug message.
84 *
85 * 03 28 2011 eddie.chen
86 * [WCXRP00000603] [MT6620 Wi-Fi][DRV] Fix Klocwork warning
87 * Fix Klockwork warning.
88 *
89 * 03 15 2011 eddie.chen
90 * [WCXRP00000554] [MT6620 Wi-Fi][DRV] Add sw control debug counter
91 * Add sw debug counter for QM.
92 *
93 * 01 11 2011 eddie.chen
94 * [WCXRP00000322] Add WMM IE in beacon,
95Add per station flow control when STA is in PS
96
97 * Add swcr for test.
98 *
99*
100*/
101
102
103/*******************************************************************************
104* C O M P I L E R F L A G S
105********************************************************************************
106*/
107
108/*******************************************************************************
109* E X T E R N A L R E F E R E N C E S
110********************************************************************************
111*/
112#include "precomp.h"
113
114#if CFG_SUPPORT_SWCR
115
116#ifdef __GNUC__
117#pragma GCC diagnostic ignored "-Wformat"
118#endif
119/*******************************************************************************
120* D A T A T Y P E S
121********************************************************************************
122*/
123
124/*******************************************************************************
125* P U B L I C D A T A
126********************************************************************************
127*/
128#if 0
129extern SWCR_MAP_ENTRY_T g_arRlmArSwCrMap[];
130SWCR_MOD_MAP_ENTRY_T g_arSwCrAllMaps[] = {
131 {SWCR_MAP_NUM(g_arRlmArSwCrMap), g_arRlmArSwCrMap}, /* 0x00nn */
132 {0, NULL}
133};
134#endif
135
136VOID swCtrlCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
137 UINT_8 ucOpt1);
138VOID swCtrlCmdCategory1(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
139 UINT_8 ucOpt1);
140VOID testPsCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
141 UINT_8 ucOpt1);
142VOID testPsCmdCategory1(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
143 UINT_8 ucOpt1);
144void testWNMCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
145 UINT_8 ucOpt1);
146VOID swCtrlSwCr(P_ADAPTER_T prAdapter, UINT_8 ucRead, UINT_16 u2Addr, UINT_32 *pu4Data);
147
148/* Support Debug */
149VOID swCrDebugCheck(P_ADAPTER_T prAdapter, P_CMD_SW_DBG_CTRL_T prCmdSwCtrl);
150VOID swCrDebugCheckTimeout(IN P_ADAPTER_T prAdapter, UINT_32 u4Param);
151VOID swCrDebugQuery(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf);
152VOID swCrDebugQueryTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo);
153
154UINT_32 g_au4SwCr[SWCR_CR_NUM]; /*: 0: command other: data */
155
156/* JB mDNS Filter*/
157UINT_32 g_u4mDNSRXFilter = 0; /* [31] 0: stop 1: start, [3] IPv6 [2] IPv4 */
158
159static TIMER_T g_rSwcrDebugTimer;
160static BOOLEAN g_fgSwcrDebugTimer = FALSE;
161static UINT_32 g_u4SwcrDebugCheckTimeout;
162static ENUM_SWCR_DBG_TYPE_T g_ucSwcrDebugCheckType;
163static UINT_32 g_u4SwcrDebugFrameDumpType;
164
165/*******************************************************************************
166* P R I V A T E D A T A
167********************************************************************************
168*/
169#define TEST_PS 1
170
171const static PFN_CMD_RW_T g_arSwCtrlCmd[] = {
172 swCtrlCmdCategory0,
173 swCtrlCmdCategory1
174#if TEST_PS
175 , testPsCmdCategory0, testPsCmdCategory1
176#endif
177#if CFG_SUPPORT_802_11V
178#if (CFG_SUPPORT_802_11V_TIMING_MEASUREMENT == 1) && (WNM_UNIT_TEST == 1)
179 , testWNMCmdCategory0
180#endif
181#endif
182};
183
184
185const PFN_SWCR_RW_T g_arSwCrModHandle[] = {
186 swCtrlSwCr,
187 NULL
188};
189
190
191/*******************************************************************************
192* M A C R O S
193********************************************************************************
194*/
195
196enum {
197 SWCTRL_MAGIC,
198 SWCTRL_DEBUG,
199 SWCTRL_WIFI_VAR,
200 SWCTRL_ENABLE_INT,
201 SWCTRL_DISABLE_INT,
202 SWCTRL_TXM_INFO,
203 SWCTRL_RXM_INFO,
204 SWCTRL_DUMP_BSS,
205 SWCTRL_QM_INFO,
206 SWCTRL_DUMP_ALL_QUEUE_LEN,
207 SWCTRL_DUMP_MEM,
208 SWCTRL_TX_CTRL_INFO,
209 SWCTRL_DUMP_QUEUE,
210 SWCTRL_DUMP_QM_DBG_CNT,
211 SWCTRL_QM_DBG_CNT,
212 SWCTRL_RX_PKTS_DUMP,
213 SWCTRL_RX_MDNS_FILTER,
214 SWCTRL_CATA0_INDEX_NUM
215};
216
217enum {
218 SWCTRL_STA_INFO,
219 SWCTRL_DUMP_STA,
220 SWCTRL_STA_QUE_INFO,
221 SWCTRL_CATA1_INDEX_NUM
222};
223
224/* JB mDNS Filter*/
225#define RX_MDNS_FILTER_START (1<<31)
226#define RX_MDNS_FILTER_IPV4 (1<<2)
227#define RX_MDNS_FILTER_IPV6 (1<<3)
228typedef enum _ENUM_SWCR_RX_MDNS_FILTER_CMD_T {
229 SWCR_RX_MDNS_FILTER_CMD_STOP = 0,
230 SWCR_RX_MDNS_FILTER_CMD_START,
231 SWCR_RX_MDNS_FILTER_CMD_ADD,
232 SWCR_RX_MDNS_FILTER_CMD_REMOVE,
233 SWCR_RX_MDNS_FILTER_NUM
234} ENUM_SWCR_RX_MDNS_FILTER_CMD_T;
235
236#if TEST_PS
237enum {
238 TEST_PS_MAGIC,
239 TEST_PS_SETUP_BSS,
240 TEST_PS_ENABLE_BEACON,
241 TEST_PS_TRIGGER_BMC,
242 TEST_PS_SEND_NULL,
243 TEST_PS_BUFFER_BMC,
244 TEST_PS_UPDATE_BEACON,
245 TEST_PS_CATA0_INDEX_NUM
246};
247
248enum {
249 TEST_PS_STA_PS,
250 TEST_PS_STA_ENTER_PS,
251 TEST_PS_STA_EXIT_PS,
252 TEST_PS_STA_TRIGGER_PSPOLL,
253 TEST_PS_STA_TRIGGER_FRAME,
254 TEST_PS_CATA1_INDEX_NUM
255};
256#endif
257
258#if CFG_SUPPORT_802_11V
259#if WNM_UNIT_TEST
260enum {
261 TEST_WNM_TIMING_MEAS,
262 TEST_WNM_CATA0_INDEX_NUM
263};
264#endif
265#endif
266
267
268#define _SWCTRL_MAGIC 0x66201642
269
270/*******************************************************************************
271* F U N C T I O N D E C L A R A T I O N S
272********************************************************************************
273*/
274
275
276/*******************************************************************************
277* F U N C T I O N S
278********************************************************************************
279*/
280
281void dumpQueue(P_ADAPTER_T prAdapter)
282{
283
284 P_TX_CTRL_T prTxCtrl;
285 P_QUE_MGT_T prQM;
286 P_GLUE_INFO_T prGlueInfo;
287 UINT_32 i;
288 UINT_32 j;
289
290
291 DEBUGFUNC("dumpQueue");
292
293 prTxCtrl = &prAdapter->rTxCtrl;
294 prQM = &prAdapter->rQM;
295 prGlueInfo = prAdapter->prGlueInfo;
296
297 for (i = TC0_INDEX; i <= TC5_INDEX; i++) {
298 DBGLOG(SW4, INFO, ("TC %u\n", i));
299 DBGLOG(SW4, INFO, ("Max %u Free %u\n",
300 prTxCtrl->rTc.aucMaxNumOfBuffer[i],
301 prTxCtrl->rTc.aucFreeBufferCount[i]));
302
303 DBGLOG(SW4, INFO,
304 ("Average %u minReserved %u CurrentTcResource %u GuaranteedTcResource %u\n",
305 QM_GET_TX_QUEUE_LEN(prAdapter, i), prQM->au4MinReservedTcResource[i],
306 prQM->au4CurrentTcResource[i], prQM->au4GuaranteedTcResource[i]));
307
308 }
309
310
311 for (i = 0; i < NUM_OF_PER_STA_TX_QUEUES; i++) {
312 DBGLOG(SW4, INFO,
313 ("TC %u HeadStaIdx %u ForwardCount %u\n", i, prQM->au4HeadStaRecIndex[i],
314 prQM->au4ForwardCount[i]));
315 }
316
317 DBGLOG(SW4, INFO, ("BMC or unknown TxQueue Len %u\n", prQM->arTxQueue[0].u4NumElem));
318 DBGLOG(SW4, INFO, ("Pending %d\n", prGlueInfo->i4TxPendingFrameNum));
319 DBGLOG(SW4, INFO, ("Pending Security %d\n", prGlueInfo->i4TxPendingSecurityFrameNum));
320#if defined(LINUX)
321 for (i = 0; i < 4; i++) {
322 for (j = 0; j < CFG_MAX_TXQ_NUM; j++) {
323 DBGLOG(SW4, INFO,
324 ("Pending Q[%u][%u] %d\n", i, j,
325 prGlueInfo->ai4TxPendingFrameNumPerQueue[i][j]));
326 }
327 }
328#endif
329
330 DBGLOG(SW4, INFO, (" rFreeSwRfbList %u\n", prAdapter->rRxCtrl.rFreeSwRfbList.u4NumElem));
331 DBGLOG(SW4, INFO,
332 (" rReceivedRfbList %u\n", prAdapter->rRxCtrl.rReceivedRfbList.u4NumElem));
333 DBGLOG(SW4, INFO,
334 (" rIndicatedRfbList %u\n", prAdapter->rRxCtrl.rIndicatedRfbList.u4NumElem));
335 DBGLOG(SW4, INFO, (" ucNumIndPacket %u\n", prAdapter->rRxCtrl.ucNumIndPacket));
336 DBGLOG(SW4, INFO, (" ucNumRetainedPacket %u\n", prAdapter->rRxCtrl.ucNumRetainedPacket));
337
338
339}
340
341
342void dumpSTA(P_ADAPTER_T prAdapter, P_STA_RECORD_T prStaRec)
343{
344 UINT_8 ucWTEntry;
345 UINT_32 i;
346 P_BSS_INFO_T prBssInfo;
347
348 DEBUGFUNC("dumpSTA");
349
350 ASSERT(prStaRec);
351 ucWTEntry = prStaRec->ucWTEntry;
352
353 prBssInfo = &prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex];
354 ASSERT(prBssInfo);
355
356 DBGLOG(SW4, INFO,
357 ("Mac address: " MACSTR " Rcpi %u" "\n", MAC2STR(prStaRec->aucMacAddr),
358 prStaRec->ucRCPI));
359
360 DBGLOG(SW4, INFO, ("Idx %u Wtbl %u Used %u State %u Bss Phy 0x%x Sta DesiredPhy 0x%x\n",
361 prStaRec->ucIndex, ucWTEntry,
362 prStaRec->fgIsInUse, prStaRec->ucStaState,
363 prBssInfo->ucPhyTypeSet, prStaRec->ucDesiredPhyTypeSet));
364
365 DBGLOG(SW4, INFO,
366 ("Sta Operation 0x%x DesiredNontHtRateSet 0x%x Mcs 0x%x u2HtCapInfo 0x%x\n",
367 prStaRec->u2OperationalRateSet, prStaRec->u2DesiredNonHTRateSet, prStaRec->ucMcsSet,
368 prStaRec->u2HtCapInfo));
369
370
371 for (i = 0; i < NUM_OF_PER_STA_TX_QUEUES; i++) {
372 DBGLOG(SW4, INFO, ("TC %u Queue Len %u\n", i, prStaRec->arTxQueue[i].u4NumElem));
373 }
374
375 DBGLOG(SW4, INFO, ("BmpDeliveryAC %x\n", prStaRec->ucBmpDeliveryAC));
376 DBGLOG(SW4, INFO, ("BmpTriggerAC %x\n", prStaRec->ucBmpTriggerAC));
377 DBGLOG(SW4, INFO, ("UapsdSpSupproted %u\n", prStaRec->fgIsUapsdSupported));
378 DBGLOG(SW4, INFO, ("IsQoS %u\n", prStaRec->fgIsQoS));
379 DBGLOG(SW4, INFO, ("AssocId %u\n", prStaRec->u2AssocId));
380
381 DBGLOG(SW4, INFO, ("fgIsInPS %u\n", prStaRec->fgIsInPS));
382 DBGLOG(SW4, INFO, ("ucFreeQuota %u\n", prStaRec->ucFreeQuota));
383 DBGLOG(SW4, INFO, ("ucFreeQuotaForDelivery %u\n", prStaRec->ucFreeQuotaForDelivery));
384 DBGLOG(SW4, INFO, ("ucFreeQuotaForNonDelivery %u\n", prStaRec->ucFreeQuotaForNonDelivery));
385
386
387#if 0
388 DBGLOG(SW4, INFO, ("IsQmmSup %u\n", prStaRec->fgIsWmmSupported));
389 DBGLOG(SW4, INFO, ("IsUapsdSup %u\n", prStaRec->fgIsUapsdSupported));
390 DBGLOG(SW4, INFO, ("AvailabaleDeliverPkts %u\n", prStaRec->ucAvailableDeliverPkts));
391 DBGLOG(SW4, INFO, ("BmpDeliverPktsAC %u\n", prStaRec->u4BmpDeliverPktsAC));
392 DBGLOG(SW4, INFO, ("BmpBufferAC %u\n", prStaRec->u4BmpBufferAC));
393 DBGLOG(SW4, INFO, ("BmpNonDeliverPktsAC %u\n", prStaRec->u4BmpNonDeliverPktsAC));
394#endif
395
396 for (i = 0; i < CFG_RX_MAX_BA_TID_NUM; i++) {
397 if (prStaRec->aprRxReorderParamRefTbl[i]) {
398 DBGLOG(SW4, INFO,
399 ("RxReorder fgIsValid: %u\n",
400 prStaRec->aprRxReorderParamRefTbl[i]->fgIsValid));
401 DBGLOG(SW4, INFO,
402 ("RxReorder Tid: %u\n",
403 prStaRec->aprRxReorderParamRefTbl[i]->ucTid));
404 DBGLOG(SW4, INFO,
405 ("RxReorder rReOrderQue Len: %u\n",
406 prStaRec->aprRxReorderParamRefTbl[i]->rReOrderQue.u4NumElem));
407 DBGLOG(SW4, INFO,
408 ("RxReorder WinStart: %u\n",
409 prStaRec->aprRxReorderParamRefTbl[i]->u2WinStart));
410 DBGLOG(SW4, INFO,
411 ("RxReorder WinEnd: %u\n",
412 prStaRec->aprRxReorderParamRefTbl[i]->u2WinEnd));
413 DBGLOG(SW4, INFO,
414 ("RxReorder WinSize: %u\n",
415 prStaRec->aprRxReorderParamRefTbl[i]->u2WinSize));
416 }
417 }
418
419}
420
421
422VOID dumpBss(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo)
423{
424
425 DBGLOG(SW4, INFO, ("SSID %s\n", prBssInfo->aucSSID));
426 DBGLOG(SW4, INFO, ("OWN " MACSTR "\n", MAC2STR(prBssInfo->aucOwnMacAddr)));
427 DBGLOG(SW4, INFO, ("BSSID " MACSTR "\n", MAC2STR(prBssInfo->aucBSSID)));
428 DBGLOG(SW4, INFO, ("ucNetTypeIndex %u\n", prBssInfo->ucNetTypeIndex));
429 DBGLOG(SW4, INFO, ("eConnectionState %u\n", prBssInfo->eConnectionState));
430 DBGLOG(SW4, INFO, ("eCurrentOPMode %u\n", prBssInfo->eCurrentOPMode));
431 DBGLOG(SW4, INFO, ("fgIsQBSS %u\n", prBssInfo->fgIsQBSS));
432 DBGLOG(SW4, INFO, ("fgIsShortPreambleAllowed %u\n", prBssInfo->fgIsShortPreambleAllowed));
433 DBGLOG(SW4, INFO, ("fgUseShortPreamble %u\n", prBssInfo->fgUseShortPreamble));
434 DBGLOG(SW4, INFO, ("fgUseShortSlotTime %u\n", prBssInfo->fgUseShortSlotTime));
435 DBGLOG(SW4, INFO, ("ucNonHTBasicPhyType %x\n", prBssInfo->ucNonHTBasicPhyType));
436 DBGLOG(SW4, INFO, ("u2OperationalRateSet %x\n", prBssInfo->u2OperationalRateSet));
437 DBGLOG(SW4, INFO, ("u2BSSBasicRateSet %x\n", prBssInfo->u2BSSBasicRateSet));
438 DBGLOG(SW4, INFO, ("ucPhyTypeSet %x\n", prBssInfo->ucPhyTypeSet));
439 DBGLOG(SW4, INFO, ("rStaRecOfClientList %d\n", prBssInfo->rStaRecOfClientList.u4NumElem));
440 DBGLOG(SW4, INFO, ("u2CapInfo %x\n", prBssInfo->u2CapInfo));
441 DBGLOG(SW4, INFO, ("u2ATIMWindow %x\n", prBssInfo->u2ATIMWindow));
442 DBGLOG(SW4, INFO, ("u2AssocId %x\n", prBssInfo->u2AssocId));
443 DBGLOG(SW4, INFO, ("ucDTIMPeriod %x\n", prBssInfo->ucDTIMPeriod));
444 DBGLOG(SW4, INFO, ("ucDTIMCount %x\n", prBssInfo->ucDTIMCount));
445 DBGLOG(SW4, INFO, ("fgIsNetAbsent %x\n", prBssInfo->fgIsNetAbsent));
446 DBGLOG(SW4, INFO, ("eBand %d\n", prBssInfo->eBand));
447 DBGLOG(SW4, INFO, ("ucPrimaryChannel %d\n", prBssInfo->ucPrimaryChannel));
448 DBGLOG(SW4, INFO, ("ucHtOpInfo1 %d\n", prBssInfo->ucHtOpInfo1));
449 DBGLOG(SW4, INFO, ("ucHtOpInfo2 %d\n", prBssInfo->u2HtOpInfo2));
450 DBGLOG(SW4, INFO, ("ucHtOpInfo3 %d\n", prBssInfo->u2HtOpInfo3));
451 DBGLOG(SW4, INFO, ("fgErpProtectMode %d\n", prBssInfo->fgErpProtectMode));
452 DBGLOG(SW4, INFO, ("eHtProtectMode %d\n", prBssInfo->eHtProtectMode));
453 DBGLOG(SW4, INFO, ("eGfOperationMode %d\n", prBssInfo->eGfOperationMode));
454 DBGLOG(SW4, INFO, ("eRifsOperationMode %d\n", prBssInfo->eRifsOperationMode));
455 DBGLOG(SW4, INFO, ("fgObssErpProtectMode %d\n", prBssInfo->fgObssErpProtectMode));
456 DBGLOG(SW4, INFO, ("eObssHtProtectMode %d\n", prBssInfo->eObssHtProtectMode));
457 DBGLOG(SW4, INFO, ("eObssGfProtectMode %d\n", prBssInfo->eObssGfOperationMode));
458 DBGLOG(SW4, INFO, ("fgObssRifsOperationMode %d\n", prBssInfo->fgObssRifsOperationMode));
459 DBGLOG(SW4, INFO, ("fgAssoc40mBwAllowed %d\n", prBssInfo->fgAssoc40mBwAllowed));
460 DBGLOG(SW4, INFO, ("fg40mBwAllowed %d\n", prBssInfo->fg40mBwAllowed));
461 DBGLOG(SW4, INFO, ("eBssSCO %d\n", prBssInfo->eBssSCO));
462
463
464}
465
466
467
468VOID swCtrlCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
469 UINT_8 ucOpt1)
470{
471 UINT_8 ucIndex, ucRead;
472 UINT_32 i;
473
474 DEBUGFUNC("swCtrlCmdCategory0");
475
476 SWCR_GET_RW_INDEX(ucAction, ucRead, ucIndex);
477
478 i = 0;
479
480 if (ucIndex >= SWCTRL_CATA0_INDEX_NUM)
481 return;
482
483 if (ucRead == SWCR_WRITE) {
484 switch (ucIndex) {
485 case SWCTRL_DEBUG:
486#if DBG
487 aucDebugModule[ucOpt0] = (UINT_8) g_au4SwCr[1];
488#endif
489 break;
490 case SWCTRL_WIFI_VAR:
491 break;
492
493#if QM_DEBUG_COUNTER
494 case SWCTRL_DUMP_QM_DBG_CNT:
495 for (i = 0; i < QM_DBG_CNT_NUM; i++) {
496 prAdapter->rQM.au4QmDebugCounters[i] = 0;
497 }
498 break;
499 case SWCTRL_QM_DBG_CNT:
500 prAdapter->rQM.au4QmDebugCounters[ucOpt0] = g_au4SwCr[1];
501
502 break;
503#endif
504#if CFG_RX_PKTS_DUMP
505 case SWCTRL_RX_PKTS_DUMP:
506 /* DBGLOG(SW4, INFO,("SWCTRL_RX_PKTS_DUMP: mask %x\n", g_au4SwCr[1])); */
507 prAdapter->rRxCtrl.u4RxPktsDumpTypeMask = g_au4SwCr[1];
508 break;
509#endif
510 case SWCTRL_RX_MDNS_FILTER:
511 {
512 UINT_32 u4rxfilter;
513 BOOLEAN fgUpdate = FALSE;
514 WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
515
516 if (ucOpt0 == SWCR_RX_MDNS_FILTER_CMD_STOP) {
517 g_u4mDNSRXFilter &= ~(RX_MDNS_FILTER_START);
518
519 u4rxfilter = prAdapter->u4OsPacketFilter;
520 fgUpdate = TRUE;
521 } else if (ucOpt0 == SWCR_RX_MDNS_FILTER_CMD_START) {
522 g_u4mDNSRXFilter |= (RX_MDNS_FILTER_START);
523
524 u4rxfilter = prAdapter->u4OsPacketFilter;
525 if ((g_u4mDNSRXFilter & RX_MDNS_FILTER_IPV4) ||
526 (g_u4mDNSRXFilter & RX_MDNS_FILTER_IPV6)) {
527 u4rxfilter |= PARAM_PACKET_FILTER_ALL_MULTICAST;
528 }
529 fgUpdate = TRUE;
530 } else if (ucOpt0 == SWCR_RX_MDNS_FILTER_CMD_ADD) {
531 if (ucOpt1 < 31) {
532 g_u4mDNSRXFilter |= (1 << ucOpt1);
533 }
534 } else if (ucOpt0 == SWCR_RX_MDNS_FILTER_CMD_REMOVE) {
535 if (ucOpt1 < 31) {
536 g_u4mDNSRXFilter &= ~(1 << ucOpt1);
537 }
538 }
539
540 if (fgUpdate == TRUE) {
541 rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
542 CMD_ID_SET_RX_FILTER, /* ucCID */
543 TRUE, /* fgSetQuery */
544 FALSE, /* fgNeedResp */
545 FALSE, /* fgIsOid */
546 NULL, /* pfCmdDoneHandler */
547 NULL, /* pfCmdTimeoutHandler */
548 sizeof(UINT_32), /* u4SetQueryInfoLen */
549 (PUINT_8) & u4rxfilter, /* pucInfoBuffer */
550 NULL, /* pvSetQueryBuffer */
551 0 /* un4SetQueryBufferLen */
552 );
553 }
554/* DBGLOG(SW4, INFO,("SWCTRL_RX_MDNS_FILTER: g_u4mDNSRXFilter %x ucOpt0 %x ucOpt1 %x fgUpdate %x u4rxfilter %x, rStatus %x\n", */
555/* g_u4mDNSRXFilter, ucOpt0, ucOpt1, fgUpdate, u4rxfilter, rStatus)); */
556 }
557 break;
558 default:
559 break;
560 }
561 } else {
562 switch (ucIndex) {
563 case SWCTRL_DEBUG:
564#if DBG
565 g_au4SwCr[1] = aucDebugModule[ucOpt0];
566#endif
567 break;
568 case SWCTRL_MAGIC:
569 g_au4SwCr[1] = _SWCTRL_MAGIC;
570 DBGLOG(SW4, INFO, ("BUILD TIME: %s %s\n", __DATE__, __TIME__));
571 break;
572 case SWCTRL_QM_INFO:
573 {
574 P_QUE_MGT_T prQM = &prAdapter->rQM;
575 switch (ucOpt0) {
576 case 0:
577 g_au4SwCr[1] = (QM_GET_TX_QUEUE_LEN(prAdapter, ucOpt1));
578 g_au4SwCr[2] = prQM->au4MinReservedTcResource[ucOpt1];
579 g_au4SwCr[3] = prQM->au4CurrentTcResource[ucOpt1];
580 g_au4SwCr[4] = prQM->au4GuaranteedTcResource[ucOpt1];
581 break;
582
583 case 1:
584 g_au4SwCr[1] = prQM->au4ForwardCount[ucOpt1];
585 g_au4SwCr[2] = prQM->au4HeadStaRecIndex[ucOpt1];
586 break;
587
588 case 2:
589 g_au4SwCr[1] = prQM->arTxQueue[ucOpt1].u4NumElem; /* only one */
590
591
592 break;
593 }
594
595 }
596 case SWCTRL_TX_CTRL_INFO:
597 {
598 P_TX_CTRL_T prTxCtrl;
599 prTxCtrl = &prAdapter->rTxCtrl;
600 switch (ucOpt0) {
601 case 0:
602 g_au4SwCr[1] =
603 prAdapter->rTxCtrl.rTc.aucFreeBufferCount[ucOpt1];
604 g_au4SwCr[2] =
605 prAdapter->rTxCtrl.rTc.aucMaxNumOfBuffer[ucOpt1];
606 break;
607 }
608
609 }
610 break;
611 case SWCTRL_DUMP_QUEUE:
612 dumpQueue(prAdapter);
613
614 break;
615#if QM_DEBUG_COUNTER
616 case SWCTRL_DUMP_QM_DBG_CNT:
617 for (i = 0; i < QM_DBG_CNT_NUM; i++) {
618 DBGLOG(SW4, INFO,
619 ("QM:DBG %u %u\n", i, prAdapter->rQM.au4QmDebugCounters[i]));
620 }
621 break;
622
623 case SWCTRL_QM_DBG_CNT:
624 g_au4SwCr[1] = prAdapter->rQM.au4QmDebugCounters[ucOpt0];
625 break;
626#endif
627 case SWCTRL_DUMP_BSS:
628 {
629 dumpBss(prAdapter, &(prAdapter->rWifiVar.arBssInfo[ucOpt0]));
630 }
631 break;
632
633 default:
634 break;
635 }
636
637 }
638}
639
640
641VOID swCtrlCmdCategory1(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
642 UINT_8 ucOpt1)
643{
644 UINT_8 ucIndex, ucRead;
645 UINT_8 ucWTEntry;
646 P_STA_RECORD_T prStaRec;
647
648 DEBUGFUNC("swCtrlCmdCategory1");
649
650 SWCR_GET_RW_INDEX(ucAction, ucRead, ucIndex);
651
652 if (ucOpt0 >= CFG_STA_REC_NUM)
653 return;
654
655 /* prStaRec = cnmGetStaRecByIndex (prAdapter, ucOpt0); */
656 prStaRec = &prAdapter->arStaRec[ucOpt0];
657 ucWTEntry = prStaRec->ucWTEntry;
658 if (ucRead == SWCR_WRITE) {
659 } else {
660 /* Read */
661 switch (ucIndex) {
662 case SWCTRL_STA_QUE_INFO:
663 {
664 g_au4SwCr[1] = prStaRec->arTxQueue[ucOpt1].u4NumElem;
665 }
666 break;
667 case SWCTRL_STA_INFO:
668 switch (ucOpt1) {
669 case 0:
670 g_au4SwCr[1] = prStaRec->fgIsInPS;
671 break;
672 }
673
674 break;
675
676 case SWCTRL_DUMP_STA:
677 {
678 dumpSTA(prAdapter, prStaRec);
679 }
680 break;
681
682 default:
683
684 break;
685 }
686 }
687
688
689}
690
691#if TEST_PS
692
693VOID
694testPsSendQoSNullFrame(IN P_ADAPTER_T prAdapter,
695 IN P_STA_RECORD_T prStaRec,
696 IN UINT_8 ucUP,
697 IN UINT_8 ucNetTypeIndex,
698 IN BOOLEAN fgBMC,
699 IN BOOLEAN fgIsBurstEnd,
700 IN BOOLEAN ucPacketType, IN BOOLEAN ucPsSessionID, IN BOOLEAN fgSetEOSP)
701{
702 P_MSDU_INFO_T prMsduInfo;
703 UINT_16 u2EstimatedFrameLen;
704 P_WLAN_MAC_HEADER_QOS_T prQoSNullFrame;
705
706
707 DEBUGFUNC("testPsSendQoSNullFrame");
708 DBGLOG(SW4, LOUD, ("\n"));
709
710 /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
711 /* Init with MGMT Header Length */
712 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_QOS_LEN;
713
714 /* Allocate a MSDU_INFO_T */
715 if ((prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
716 DBGLOG(SW4, WARN, ("No PKT_INFO_T for sending Null Frame.\n"));
717 return;
718 }
719 /* 4 <2> Compose Null frame in MSDU_INfO_T. */
720 bssComposeQoSNullFrame(prAdapter,
721 (PUINT_8) ((UINT_32) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
722 prStaRec, ucUP, fgSetEOSP);
723
724
725 prMsduInfo->eSrc = TX_PACKET_MGMT;
726 /* prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_DATA; */
727 prMsduInfo->ucPacketType = ucPacketType;
728 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
729 prMsduInfo->ucNetworkType = ucNetTypeIndex;
730 prMsduInfo->ucMacHeaderLength = WLAN_MAC_HEADER_QOS_LEN;
731 prMsduInfo->fgIs802_1x = FALSE;
732 prMsduInfo->fgIs802_11 = TRUE;
733 prMsduInfo->u2FrameLength = WLAN_MAC_HEADER_QOS_LEN;
734 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
735 prMsduInfo->pfTxDoneHandler = NULL;
736 prMsduInfo->fgIsBasicRate = TRUE;
737 prMsduInfo->fgIsBurstEnd = fgIsBurstEnd;
738 prMsduInfo->ucUserPriority = ucUP;
739 prMsduInfo->ucPsSessionID = ucPsSessionID /* 0~7 Test 7 means NOACK */;
740
741 prQoSNullFrame =
742 (P_WLAN_MAC_HEADER_QOS_T) ((PUINT_8)
743 ((UINT_32) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD));
744
745 if (fgBMC) {
746 prQoSNullFrame->aucAddr1[0] = 0xfd;
747 } else {
748 prQoSNullFrame->aucAddr1[5] = 0xdd;
749 }
750
751 /* 4 <4> Inform TXM to send this Null frame. */
752 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
753
754}
755
756
757
758VOID testPsSetupBss(IN P_ADAPTER_T prAdapter, IN UINT_8 ucNetworkTypeIndex)
759{
760 P_BSS_INFO_T prBssInfo;
761 UINT_8 _aucZeroMacAddr[] = NULL_MAC_ADDR;
762
763 DEBUGFUNC("testPsSetupBss()");
764 DBGLOG(SW4, INFO, ("index %d\n", ucNetworkTypeIndex));
765
766 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[ucNetworkTypeIndex]);
767
768 /* 4 <1.2> Initiate PWR STATE */
769 /* SET_NET_PWR_STATE_IDLE(prAdapter, ucNetworkTypeIndex); */
770
771
772 /* 4 <2> Initiate BSS_INFO_T - common part */
773 BSS_INFO_INIT(prAdapter, ucNetworkTypeIndex);
774
775 prBssInfo->eConnectionState = PARAM_MEDIA_STATE_DISCONNECTED;
776 prBssInfo->eConnectionStateIndicated = PARAM_MEDIA_STATE_DISCONNECTED;
777 prBssInfo->eCurrentOPMode = OP_MODE_ACCESS_POINT;
778 prBssInfo->fgIsNetActive = TRUE;
779 prBssInfo->ucNetTypeIndex = (ucNetworkTypeIndex);
780 prBssInfo->ucReasonOfDisconnect = DISCONNECT_REASON_CODE_RESERVED;
781
782 prBssInfo->ucPhyTypeSet = PHY_TYPE_SET_802_11BG; /* Depend on eBand */
783 prBssInfo->ucConfigAdHocAPMode = AP_MODE_MIXED_11BG; /* Depend on eCurrentOPMode and ucPhyTypeSet */
784 prBssInfo->u2BSSBasicRateSet = RATE_SET_ERP;
785 prBssInfo->u2OperationalRateSet = RATE_SET_OFDM;
786 prBssInfo->fgErpProtectMode = FALSE;
787 prBssInfo->fgIsQBSS = TRUE;
788
789 /* 4 <1.5> Setup MIB for current BSS */
790 prBssInfo->u2BeaconInterval = 100;
791 prBssInfo->ucDTIMPeriod = DOT11_DTIM_PERIOD_DEFAULT;
792 prBssInfo->u2ATIMWindow = 0;
793
794 prBssInfo->ucBeaconTimeoutCount = 0;
795
796
797 bssInitForAP(prAdapter, prBssInfo, TRUE);
798
799 COPY_MAC_ADDR(prBssInfo->aucBSSID, _aucZeroMacAddr);
800 LINK_INITIALIZE(&prBssInfo->rStaRecOfClientList);
801 prBssInfo->fgIsBeaconActivated = TRUE;
802 prBssInfo->ucHwDefaultFixedRateCode = RATE_CCK_1M_LONG;
803
804
805 COPY_MAC_ADDR(prBssInfo->aucOwnMacAddr, prAdapter->rWifiVar.aucMacAddress);
806
807 /* 4 <3> Initiate BSS_INFO_T - private part */
808 /* TODO */
809 prBssInfo->eBand = BAND_2G4;
810 prBssInfo->ucPrimaryChannel = 1;
811 prBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
812
813
814 /* prBssInfo->fgErpProtectMode = eErpProectMode; */
815 /* prBssInfo->eHtProtectMode = eHtProtectMode; */
816 /* prBssInfo->eGfOperationMode = eGfOperationMode; */
817
818
819 /* 4 <4> Allocate MSDU_INFO_T for Beacon */
820 prBssInfo->prBeacon = cnmMgtPktAlloc(prAdapter,
821 OFFSET_OF(WLAN_BEACON_FRAME_T,
822 aucInfoElem[0]) + MAX_IE_LENGTH);
823
824 if (prBssInfo->prBeacon) {
825 prBssInfo->prBeacon->eSrc = TX_PACKET_MGMT;
826 prBssInfo->prBeacon->ucNetworkType = ucNetworkTypeIndex;
827 } else {
828 DBGLOG(SW4, INFO, ("prBeacon allocation fail\n"));
829 }
830
831#if 0
832 prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC = PM_UAPSD_ALL;
833 prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC = PM_UAPSD_ALL;
834 prBssInfo->rPmProfSetupInfo.ucUapsdSp = WMM_MAX_SP_LENGTH_2;
835#else
836 prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC = (UINT_8) prAdapter->u4UapsdAcBmp;
837 prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC = (UINT_8) prAdapter->u4UapsdAcBmp;
838 prBssInfo->rPmProfSetupInfo.ucUapsdSp = (UINT_8) prAdapter->u4MaxSpLen;
839#endif
840
841#if 0
842 for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
843
844 prBssInfo->arACQueParms[eAci].fgIsACMSet = FALSE;
845 prBssInfo->arACQueParms[eAci].u2Aifsn = (UINT_16) eAci;
846 prBssInfo->arACQueParms[eAci].u2CWmin = 7;
847 prBssInfo->arACQueParms[eAci].u2CWmax = 31;
848 prBssInfo->arACQueParms[eAci].u2TxopLimit = eAci + 1;
849 DBGLOG(SW4, INFO,
850 ("MQM: eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
851 eAci, prBssInfo->arACQueParms[eAci].fgIsACMSet,
852 prBssInfo->arACQueParms[eAci].u2Aifsn,
853 prBssInfo->arACQueParms[eAci].u2CWmin,
854 prBssInfo->arACQueParms[eAci].u2CWmax,
855 prBssInfo->arACQueParms[eAci].u2TxopLimit));
856
857 }
858#endif
859
860
861 DBGLOG(SW4, INFO, ("[2] ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x, ucUapsdSp:0x%x",
862 prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC,
863 prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC,
864 prBssInfo->rPmProfSetupInfo.ucUapsdSp));
865
866 return;
867}
868
869
870
871
872VOID testPsCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
873 UINT_8 ucOpt1)
874{
875 UINT_8 ucIndex, ucRead;
876 P_STA_RECORD_T prStaRec;
877
878 DEBUGFUNC("testPsCmdCategory0");
879 SWCR_GET_RW_INDEX(ucAction, ucRead, ucIndex);
880
881 DBGLOG(SW4, LOUD, ("Read %u Index %u\n", ucRead, ucIndex));
882
883 prStaRec = cnmGetStaRecByIndex(prAdapter, 0);
884
885 if (ucIndex >= TEST_PS_CATA0_INDEX_NUM)
886 return;
887
888 if (ucRead == SWCR_WRITE) {
889 switch (ucIndex) {
890 case TEST_PS_SETUP_BSS:
891 testPsSetupBss(prAdapter, ucOpt0);
892 break;
893
894 case TEST_PS_ENABLE_BEACON:
895 break;
896
897 case TEST_PS_TRIGGER_BMC:
898 /* txmForwardQueuedBmcPkts (ucOpt0); */
899 break;
900 case TEST_PS_SEND_NULL:
901 {
902
903 testPsSendQoSNullFrame(prAdapter, prStaRec, (UINT_8) (g_au4SwCr[1] & 0xFF), /* UP */
904 ucOpt0, (BOOLEAN) ((g_au4SwCr[1] >> 8) & 0xFF), /* BMC */
905 (BOOLEAN) ((g_au4SwCr[1] >> 16) & 0xFF), /* BurstEnd */
906 (BOOLEAN) ((g_au4SwCr[1] >> 24) & 0xFF), /* Packet type */
907 (UINT_8) ((g_au4SwCr[2]) & 0xFF), /* PS sesson ID 7: NOACK */
908 FALSE /* EOSP */
909 );
910 }
911 break;
912 case TEST_PS_BUFFER_BMC:
913 /* g_aprBssInfo[ucOpt0]->fgApToBufferBMC = (g_au4SwCr[1] & 0xFF); */
914 break;
915 case TEST_PS_UPDATE_BEACON:
916 bssUpdateBeaconContent(prAdapter, ucOpt0 /*networktype */);
917 break;
918
919 default:
920 break;
921 }
922 } else {
923 switch (ucIndex) {
924
925 case TEST_PS_MAGIC:
926 g_au4SwCr[1] = 0x88660011;
927 break;
928
929 }
930 }
931}
932
933#endif /* TEST_PS */
934
935#if TEST_PS
936
937VOID testPsCmdCategory1(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
938 UINT_8 ucOpt1)
939{
940 UINT_8 ucIndex, ucRead;
941 UINT_8 ucWTEntry;
942 P_STA_RECORD_T prStaRec;
943
944 DEBUGFUNC("testPsCmdCategory1");
945
946 SWCR_GET_RW_INDEX(ucAction, ucRead, ucIndex);
947
948 if (ucOpt0 >= CFG_STA_REC_NUM)
949 return;
950
951 prStaRec = cnmGetStaRecByIndex(prAdapter, ucOpt0);
952 ucWTEntry = prStaRec->ucWTEntry;
953 if (ucRead == SWCR_WRITE) {
954
955 switch (ucIndex) {
956 case TEST_PS_STA_PS:
957 prStaRec->fgIsInPS = (BOOLEAN) (g_au4SwCr[1] & 0x1);
958 prStaRec->fgIsQoS = (BOOLEAN) (g_au4SwCr[1] >> 8 & 0xFF);
959 prStaRec->fgIsUapsdSupported = (BOOLEAN) (g_au4SwCr[1] >> 16 & 0xFF);
960 prStaRec->ucBmpDeliveryAC = (BOOLEAN) (g_au4SwCr[1] >> 24 & 0xFF);
961 break;
962
963 }
964
965 } else {
966 /* Read */
967 switch (ucIndex) {
968 default:
969 break;
970 }
971 }
972
973
974}
975
976#endif /* TEST_PS */
977
978#if CFG_SUPPORT_802_11V
979#if (CFG_SUPPORT_802_11V_TIMING_MEASUREMENT == 1) && (WNM_UNIT_TEST == 1)
980VOID testWNMCmdCategory0(P_ADAPTER_T prAdapter, UINT_8 ucCate, UINT_8 ucAction, UINT_8 ucOpt0,
981 UINT_8 ucOpt1)
982{
983 UINT_8 ucIndex, ucRead;
984 P_STA_RECORD_T prStaRec;
985
986 DEBUGFUNC("testWNMCmdCategory0");
987 SWCR_GET_RW_INDEX(ucAction, ucRead, ucIndex);
988
989 DBGLOG(SW4, INFO, ("Read %u Index %u\n", ucRead, ucIndex));
990
991 if (ucIndex >= TEST_WNM_CATA0_INDEX_NUM)
992 return;
993
994 if (ucRead == SWCR_WRITE) {
995 switch (ucIndex) {
996 case TEST_WNM_TIMING_MEAS:
997 wnmTimingMeasUnitTest1(prAdapter, ucOpt0);
998 break;
999
1000 default:
1001 break;
1002 }
1003 }
1004}
1005#endif /* TEST_WNM */
1006#endif /* CFG_SUPPORT_802_11V */
1007
1008VOID swCtrlSwCr(P_ADAPTER_T prAdapter, UINT_8 ucRead, UINT_16 u2Addr, UINT_32 *pu4Data)
1009{
1010 /* According other register STAIDX */
1011 UINT_8 ucOffset;
1012 ucOffset = (u2Addr >> 2) & 0x3F;
1013
1014 if (ucOffset >= SWCR_CR_NUM)
1015 return;
1016
1017 if (ucRead == SWCR_WRITE) {
1018 g_au4SwCr[ucOffset] = *pu4Data;
1019 if (ucOffset == 0x0) {
1020 /* Commmand [31:24]: Category */
1021 /* Commmand [23:23]: 1(W) 0(R) */
1022 /* Commmand [22:16]: Index */
1023 /* Commmand [15:08]: Option0 */
1024 /* Commmand [07:00]: Option1 */
1025 UINT_8 ucCate;
1026 UINT_32 u4Cmd;
1027 u4Cmd = g_au4SwCr[0];
1028 ucCate = (UINT_8) (u4Cmd >> 24);
1029 if (ucCate < sizeof(g_arSwCtrlCmd) / sizeof(g_arSwCtrlCmd[0])) {
1030 if (g_arSwCtrlCmd[ucCate] != NULL) {
1031 g_arSwCtrlCmd[ucCate] (prAdapter, ucCate,
1032 (UINT_8) (u4Cmd >> 16 & 0xFF),
1033 (UINT_8) ((u4Cmd >> 8) & 0xFF),
1034 (UINT_8) (u4Cmd & 0xFF));
1035 }
1036 }
1037 }
1038 } else {
1039 *pu4Data = g_au4SwCr[ucOffset];
1040 }
1041}
1042
1043VOID swCrReadWriteCmd(P_ADAPTER_T prAdapter, UINT_8 ucRead, UINT_16 u2Addr, UINT_32 *pu4Data)
1044{
1045 UINT_8 ucMod;
1046
1047 ucMod = u2Addr >> 8;
1048 /* Address [15:8] MOD ID */
1049 /* Address [7:0] OFFSET */
1050
1051 DEBUGFUNC("swCrReadWriteCmd");
1052 DBGLOG(SW4, INFO, ("%u addr 0x%x data 0x%x\n", ucRead, u2Addr, *pu4Data));
1053
1054 if (ucMod < (sizeof(g_arSwCrModHandle) / sizeof(g_arSwCrModHandle[0]))) {
1055
1056 if (g_arSwCrModHandle[ucMod] != NULL) {
1057 g_arSwCrModHandle[ucMod] (prAdapter, ucRead, u2Addr, pu4Data);
1058 }
1059 } /* ucMod */
1060}
1061
1062/* Debug Support */
1063VOID swCrFrameCheckEnable(P_ADAPTER_T prAdapter, UINT_32 u4DumpType)
1064{
1065 g_u4SwcrDebugFrameDumpType = u4DumpType;
1066 prAdapter->rRxCtrl.u4RxPktsDumpTypeMask = u4DumpType;
1067}
1068
1069VOID swCrDebugInit(P_ADAPTER_T prAdapter)
1070{
1071 /* frame dump */
1072 if (g_u4SwcrDebugFrameDumpType) {
1073 swCrFrameCheckEnable(prAdapter, g_u4SwcrDebugFrameDumpType);
1074 }
1075 /* debug counter */
1076 g_fgSwcrDebugTimer = FALSE;
1077
1078 cnmTimerInitTimer(prAdapter,
1079 &g_rSwcrDebugTimer,
1080 (PFN_MGMT_TIMEOUT_FUNC) swCrDebugCheckTimeout, (UINT_32) NULL);
1081
1082 if (g_u4SwcrDebugCheckTimeout) {
1083 swCrDebugCheckEnable(prAdapter, TRUE, g_ucSwcrDebugCheckType,
1084 g_u4SwcrDebugCheckTimeout);
1085 }
1086}
1087
1088VOID swCrDebugUninit(P_ADAPTER_T prAdapter)
1089{
1090 cnmTimerStopTimer(prAdapter, &g_rSwcrDebugTimer);
1091
1092 g_fgSwcrDebugTimer = FALSE;
1093}
1094
1095VOID swCrDebugCheckEnable(P_ADAPTER_T prAdapter, BOOLEAN fgIsEnable, UINT_8 ucType,
1096 UINT_32 u4Timeout)
1097{
1098 if (fgIsEnable) {
1099 g_ucSwcrDebugCheckType = ucType;
1100 g_u4SwcrDebugCheckTimeout = u4Timeout;
1101 if (g_fgSwcrDebugTimer == FALSE) {
1102 swCrDebugCheckTimeout(prAdapter, 0);
1103 }
1104 } else {
1105 cnmTimerStopTimer(prAdapter, &g_rSwcrDebugTimer);
1106 g_u4SwcrDebugCheckTimeout = 0;
1107 }
1108
1109 g_fgSwcrDebugTimer = fgIsEnable;
1110}
1111
1112VOID swCrDebugCheck(P_ADAPTER_T prAdapter, P_CMD_SW_DBG_CTRL_T prCmdSwCtrl)
1113{
1114 P_RX_CTRL_T prRxCtrl;
1115 P_TX_CTRL_T prTxCtrl;
1116
1117 ASSERT(prAdapter);
1118
1119 prTxCtrl = &prAdapter->rTxCtrl;
1120 prRxCtrl = &prAdapter->rRxCtrl;
1121
1122 /* dump counters */
1123 if (prCmdSwCtrl) {
1124 if (prCmdSwCtrl->u4Data == SWCR_DBG_TYPE_ALL) {
1125
1126 /* TX Counter from fw */
1127 DBGLOG(SW4, INFO, ("TX0\n"
1128 "%08x %08x %08x %08x\n"
1129 "%08x %08x %08x %08x\n",
1130 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_CNT],
1131 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_BCN_CNT],
1132 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_FAILED_CNT],
1133 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_RETRY_CNT],
1134 prCmdSwCtrl->
1135 u4DebugCnt[SWCR_DBG_ALL_TX_AGING_TIMEOUT_CNT],
1136 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_PS_OVERFLOW_CNT],
1137 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_MGNT_DROP_CNT],
1138 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_TX_ERROR_CNT]));
1139#if 1
1140 /* TX Counter from drv */
1141 DBGLOG(SW4, INFO, ("TX1\n"
1142 "%08x %08x %08x %08x\n",
1143 (UINT_32) TX_GET_CNT(prTxCtrl, TX_INACTIVE_BSS_DROP),
1144 (UINT_32) TX_GET_CNT(prTxCtrl, TX_INACTIVE_STA_DROP),
1145 (UINT_32) TX_GET_CNT(prTxCtrl, TX_FORWARD_OVERFLOW_DROP),
1146 (UINT_32) TX_GET_CNT(prTxCtrl, TX_AP_BORADCAST_DROP)));
1147#endif
1148
1149 /* RX Counter */
1150 DBGLOG(SW4, INFO, ("RX0\n"
1151 "%08x %08x %08x %08x\n"
1152 "%08x %08x %08x %08x\n"
1153 "%08x %08x %08x %08x\n"
1154 "%08x %08x %08x %08x\n",
1155 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_CNT],
1156 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_DROP_CNT],
1157 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_DUP_DROP_CNT],
1158 prCmdSwCtrl->
1159 u4DebugCnt[SWCR_DBG_ALL_RX_TYPE_ERROR_DROP_CNT],
1160 prCmdSwCtrl->
1161 u4DebugCnt[SWCR_DBG_ALL_RX_CLASS_ERROR_DROP_CNT],
1162 prCmdSwCtrl->
1163 u4DebugCnt[SWCR_DBG_ALL_RX_AMPDU_ERROR_DROP_CNT],
1164 prCmdSwCtrl->
1165 u4DebugCnt[SWCR_DBG_ALL_RX_STATUS_ERROR_DROP_CNT],
1166 prCmdSwCtrl->
1167 u4DebugCnt[SWCR_DBG_ALL_RX_FORMAT_ERROR_DROP_CNT],
1168 prCmdSwCtrl->
1169 u4DebugCnt[SWCR_DBG_ALL_RX_ICV_ERROR_DROP_CNT],
1170 prCmdSwCtrl->
1171 u4DebugCnt[SWCR_DBG_ALL_RX_KEY_ERROR_DROP_CNT],
1172 prCmdSwCtrl->
1173 u4DebugCnt[SWCR_DBG_ALL_RX_TKIP_ERROR_DROP_CNT],
1174 prCmdSwCtrl->
1175 u4DebugCnt[SWCR_DBG_ALL_RX_MIC_ERROR_DROP_CNT],
1176 prCmdSwCtrl->
1177 u4DebugCnt[SWCR_DBG_ALL_RX_BIP_ERROR_DROP_CNT],
1178 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_FCSERR_CNT],
1179 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_FIFOFULL_CNT],
1180 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_RX_PFDROP_CNT]));
1181
1182 DBGLOG(SW4, INFO, ("RX1\n"
1183 "%08x %08x %08x %08x\n"
1184 "%08x %08x %08x %08x\n",
1185 (UINT_32) RX_GET_CNT(prRxCtrl, RX_MPDU_TOTAL_COUNT),
1186 (UINT_32) RX_GET_CNT(prRxCtrl, RX_DATA_INDICATION_COUNT),
1187 (UINT_32) RX_GET_CNT(prRxCtrl, RX_DATA_RETURNED_COUNT),
1188 (UINT_32) RX_GET_CNT(prRxCtrl, RX_DATA_RETAINED_COUNT),
1189 (UINT_32) RX_GET_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT),
1190 (UINT_32) RX_GET_CNT(prRxCtrl, RX_TYPE_ERR_DROP_COUNT),
1191 (UINT_32) RX_GET_CNT(prRxCtrl, RX_CLASS_ERR_DROP_COUNT),
1192 (UINT_32) RX_GET_CNT(prRxCtrl, RX_DST_NULL_DROP_COUNT)));
1193
1194 DBGLOG(SW4, INFO, ("PWR\n"
1195 "%08x %08x %08x %08x\n"
1196 "%08x %08x %08x %08x\n",
1197 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_PS_POLL_CNT],
1198 prCmdSwCtrl->
1199 u4DebugCnt[SWCR_DBG_ALL_PWR_TRIGGER_NULL_CNT],
1200 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_BCN_IND_CNT],
1201 prCmdSwCtrl->
1202 u4DebugCnt[SWCR_DBG_ALL_PWR_BCN_TIMEOUT_CNT],
1203 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_PM_STATE0],
1204 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_PM_STATE1],
1205 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_CUR_PS_PROF0],
1206 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_PWR_CUR_PS_PROF1]));
1207
1208 DBGLOG(SW4, INFO, ("ARM\n"
1209 "%08x %08x %08x %08x\n"
1210 "%08x %08x\n",
1211 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_AR_STA0_RATE],
1212 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_AR_STA0_BWGI],
1213 prCmdSwCtrl->
1214 u4DebugCnt[SWCR_DBG_ALL_AR_STA0_RX_RATE_RCPI],
1215 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_ROAMING_ENABLE],
1216 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_ROAMING_ROAM_CNT],
1217 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_ROAMING_INT_CNT]));
1218
1219 DBGLOG(SW4, INFO, ("BB\n"
1220 "%08x %08x %08x %08x\n"
1221 "%08x %08x %08x %08x\n",
1222 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_RX_MDRDY_CNT],
1223 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_RX_FCSERR_CNT],
1224 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_CCK_PD_CNT],
1225 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_OFDM_PD_CNT],
1226 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_CCK_SFDERR_CNT],
1227 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_CCK_SIGERR_CNT],
1228 prCmdSwCtrl->u4DebugCnt[SWCR_DBG_ALL_BB_OFDM_TAGERR_CNT],
1229 prCmdSwCtrl->
1230 u4DebugCnt[SWCR_DBG_ALL_BB_OFDM_SIGERR_CNT]));
1231
1232 }
1233 }
1234 /* start the next check */
1235 if (g_u4SwcrDebugCheckTimeout) {
1236 cnmTimerStartTimer(prAdapter, &g_rSwcrDebugTimer,
1237 g_u4SwcrDebugCheckTimeout * MSEC_PER_SEC);
1238 }
1239}
1240
1241VOID swCrDebugCheckTimeout(IN P_ADAPTER_T prAdapter, UINT_32 u4Param)
1242{
1243 CMD_SW_DBG_CTRL_T rCmdSwCtrl;
1244 WLAN_STATUS rStatus;
1245
1246 rCmdSwCtrl.u4Id = (0xb000 << 16) + g_ucSwcrDebugCheckType;
1247 rCmdSwCtrl.u4Data = 0;
1248 rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
1249 CMD_ID_SW_DBG_CTRL, /* ucCID */
1250 FALSE, /* fgSetQuery */
1251 TRUE, /* fgNeedResp */
1252 FALSE, /* fgIsOid */
1253 swCrDebugQuery, /* pfCmdDoneHandler */
1254 swCrDebugQueryTimeout, /* pfCmdTimeoutHandler */
1255 sizeof(CMD_SW_DBG_CTRL_T), /* u4SetQueryInfoLen */
1256 (PUINT_8) & rCmdSwCtrl, /* pucInfoBuffer */
1257 NULL, /* pvSetQueryBuffer */
1258 0 /* u4SetQueryBufferLen */
1259 );
1260
1261 ASSERT(rStatus == WLAN_STATUS_PENDING);
1262
1263 return;
1264}
1265
1266VOID swCrDebugQuery(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
1267{
1268 ASSERT(prAdapter);
1269
1270 swCrDebugCheck(prAdapter, (P_CMD_SW_DBG_CTRL_T) (pucEventBuf));
1271}
1272
1273VOID swCrDebugQueryTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
1274{
1275 ASSERT(prAdapter);
1276
1277 swCrDebugCheck(prAdapter, NULL);
1278}
1279
1280#endif /* CFG_SUPPORT_SWCR */