swcr.c 36 KB

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