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