mib.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * File: mib.c
  20. *
  21. * Purpose: Implement MIB Data Structure
  22. *
  23. * Author: Tevin Chen
  24. *
  25. * Date: May 21, 1996
  26. *
  27. * Functions:
  28. * STAvClearAllCounter - Clear All MIB Counter
  29. * STAvUpdateIstStatCounter - Update ISR statistic counter
  30. * STAvUpdateRDStatCounter - Update Rx statistic counter
  31. * STAvUpdateRDStatCounterEx - Update Rx statistic counter and copy rcv data
  32. * STAvUpdateTDStatCounter - Update Tx statistic counter
  33. * STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data
  34. * STAvUpdate802_11Counter - Update 802.11 mib counter
  35. *
  36. * Revision History:
  37. *
  38. */
  39. #include "upc.h"
  40. #include "mac.h"
  41. #include "tether.h"
  42. #include "mib.h"
  43. #include "wctl.h"
  44. #include "baseband.h"
  45. /*--------------------- Static Definitions -------------------------*/
  46. static int msglevel =MSG_LEVEL_INFO;
  47. /*--------------------- Static Classes ----------------------------*/
  48. /*--------------------- Static Variables --------------------------*/
  49. /*--------------------- Static Functions --------------------------*/
  50. /*--------------------- Export Variables --------------------------*/
  51. /*--------------------- Export Functions --------------------------*/
  52. /*
  53. * Description: Clear All Statistic Counter
  54. *
  55. * Parameters:
  56. * In:
  57. * pStatistic - Pointer to Statistic Counter Data Structure
  58. * Out:
  59. * none
  60. *
  61. * Return Value: none
  62. *
  63. */
  64. void STAvClearAllCounter (PSStatCounter pStatistic)
  65. {
  66. // set memory to zero
  67. memset(pStatistic, 0, sizeof(SStatCounter));
  68. }
  69. /*
  70. * Description: Update Isr Statistic Counter
  71. *
  72. * Parameters:
  73. * In:
  74. * pStatistic - Pointer to Statistic Counter Data Structure
  75. * wisr - Interrupt status
  76. * Out:
  77. * none
  78. *
  79. * Return Value: none
  80. *
  81. */
  82. void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, unsigned long dwIsr)
  83. {
  84. /**********************/
  85. /* ABNORMAL interrupt */
  86. /**********************/
  87. // not any IMR bit invoke irq
  88. if (dwIsr == 0) {
  89. pStatistic->ISRStat.dwIsrUnknown++;
  90. return;
  91. }
  92. //Added by Kyle
  93. if (dwIsr & ISR_TXDMA0) // ISR, bit0
  94. pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful
  95. if (dwIsr & ISR_AC0DMA) // ISR, bit1
  96. pStatistic->ISRStat.dwIsrAC0TxOK++; // AC0DMA successful
  97. if (dwIsr & ISR_BNTX) // ISR, bit2
  98. pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful
  99. if (dwIsr & ISR_RXDMA0) // ISR, bit3
  100. pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful
  101. if (dwIsr & ISR_TBTT) // ISR, bit4
  102. pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful
  103. if (dwIsr & ISR_SOFTTIMER) // ISR, bit6
  104. pStatistic->ISRStat.dwIsrSTIMERInt++;
  105. if (dwIsr & ISR_WATCHDOG) // ISR, bit7
  106. pStatistic->ISRStat.dwIsrWatchDog++;
  107. if (dwIsr & ISR_FETALERR) // ISR, bit8
  108. pStatistic->ISRStat.dwIsrUnrecoverableError++;
  109. if (dwIsr & ISR_SOFTINT) // ISR, bit9
  110. pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt
  111. if (dwIsr & ISR_MIBNEARFULL) // ISR, bit10
  112. pStatistic->ISRStat.dwIsrMIBNearfull++;
  113. if (dwIsr & ISR_RXNOBUF) // ISR, bit11
  114. pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff
  115. if (dwIsr & ISR_RXDMA1) // ISR, bit12
  116. pStatistic->ISRStat.dwIsrRx1OK++; // Rx1 successful
  117. // if (dwIsr & ISR_ATIMTX) // ISR, bit13
  118. // pStatistic->ISRStat.dwIsrATIMTxOK++; // ATIMTX successful
  119. // if (dwIsr & ISR_SYNCTX) // ISR, bit14
  120. // pStatistic->ISRStat.dwIsrSYNCTxOK++; // SYNCTX successful
  121. // if (dwIsr & ISR_CFPEND) // ISR, bit18
  122. // pStatistic->ISRStat.dwIsrCFPEnd++;
  123. // if (dwIsr & ISR_ATIMEND) // ISR, bit19
  124. // pStatistic->ISRStat.dwIsrATIMEnd++;
  125. // if (dwIsr & ISR_SYNCFLUSHOK) // ISR, bit20
  126. // pStatistic->ISRStat.dwIsrSYNCFlushOK++;
  127. if (dwIsr & ISR_SOFTTIMER1) // ISR, bit21
  128. pStatistic->ISRStat.dwIsrSTIMER1Int++;
  129. }
  130. /*
  131. * Description: Update Rx Statistic Counter
  132. *
  133. * Parameters:
  134. * In:
  135. * pStatistic - Pointer to Statistic Counter Data Structure
  136. * byRSR - Rx Status
  137. * byNewRSR - Rx Status
  138. * pbyBuffer - Rx Buffer
  139. * cbFrameLength - Rx Length
  140. * Out:
  141. * none
  142. *
  143. * Return Value: none
  144. *
  145. */
  146. void STAvUpdateRDStatCounter (PSStatCounter pStatistic,
  147. unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate,
  148. unsigned char *pbyBuffer, unsigned int cbFrameLength)
  149. {
  150. //need change
  151. PS802_11Header pHeader = (PS802_11Header)pbyBuffer;
  152. if (byRSR & RSR_ADDROK)
  153. pStatistic->dwRsrADDROk++;
  154. if (byRSR & RSR_CRCOK) {
  155. pStatistic->dwRsrCRCOk++;
  156. pStatistic->ullRsrOK++;
  157. if (cbFrameLength >= ETH_ALEN) {
  158. // update counters in case that successful transmit
  159. if (byRSR & RSR_ADDRBROAD) {
  160. pStatistic->ullRxBroadcastFrames++;
  161. pStatistic->ullRxBroadcastBytes += (unsigned long long) cbFrameLength;
  162. }
  163. else if (byRSR & RSR_ADDRMULTI) {
  164. pStatistic->ullRxMulticastFrames++;
  165. pStatistic->ullRxMulticastBytes += (unsigned long long) cbFrameLength;
  166. }
  167. else {
  168. pStatistic->ullRxDirectedFrames++;
  169. pStatistic->ullRxDirectedBytes += (unsigned long long) cbFrameLength;
  170. }
  171. }
  172. }
  173. if(byRxRate==22) {
  174. pStatistic->CustomStat.ullRsr11M++;
  175. if(byRSR & RSR_CRCOK) {
  176. pStatistic->CustomStat.ullRsr11MCRCOk++;
  177. }
  178. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr11M, (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
  179. }
  180. else if(byRxRate==11) {
  181. pStatistic->CustomStat.ullRsr5M++;
  182. if(byRSR & RSR_CRCOK) {
  183. pStatistic->CustomStat.ullRsr5MCRCOk++;
  184. }
  185. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr5M, (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
  186. }
  187. else if(byRxRate==4) {
  188. pStatistic->CustomStat.ullRsr2M++;
  189. if(byRSR & RSR_CRCOK) {
  190. pStatistic->CustomStat.ullRsr2MCRCOk++;
  191. }
  192. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr2M, (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
  193. }
  194. else if(byRxRate==2){
  195. pStatistic->CustomStat.ullRsr1M++;
  196. if(byRSR & RSR_CRCOK) {
  197. pStatistic->CustomStat.ullRsr1MCRCOk++;
  198. }
  199. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr1M, (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
  200. }
  201. else if(byRxRate==12){
  202. pStatistic->CustomStat.ullRsr6M++;
  203. if(byRSR & RSR_CRCOK) {
  204. pStatistic->CustomStat.ullRsr6MCRCOk++;
  205. }
  206. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr6M, (int)pStatistic->CustomStat.ullRsr6MCRCOk);
  207. }
  208. else if(byRxRate==18){
  209. pStatistic->CustomStat.ullRsr9M++;
  210. if(byRSR & RSR_CRCOK) {
  211. pStatistic->CustomStat.ullRsr9MCRCOk++;
  212. }
  213. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr9M, (int)pStatistic->CustomStat.ullRsr9MCRCOk);
  214. }
  215. else if(byRxRate==24){
  216. pStatistic->CustomStat.ullRsr12M++;
  217. if(byRSR & RSR_CRCOK) {
  218. pStatistic->CustomStat.ullRsr12MCRCOk++;
  219. }
  220. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr12M, (int)pStatistic->CustomStat.ullRsr12MCRCOk);
  221. }
  222. else if(byRxRate==36){
  223. pStatistic->CustomStat.ullRsr18M++;
  224. if(byRSR & RSR_CRCOK) {
  225. pStatistic->CustomStat.ullRsr18MCRCOk++;
  226. }
  227. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr18M, (int)pStatistic->CustomStat.ullRsr18MCRCOk);
  228. }
  229. else if(byRxRate==48){
  230. pStatistic->CustomStat.ullRsr24M++;
  231. if(byRSR & RSR_CRCOK) {
  232. pStatistic->CustomStat.ullRsr24MCRCOk++;
  233. }
  234. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr24M, (int)pStatistic->CustomStat.ullRsr24MCRCOk);
  235. }
  236. else if(byRxRate==72){
  237. pStatistic->CustomStat.ullRsr36M++;
  238. if(byRSR & RSR_CRCOK) {
  239. pStatistic->CustomStat.ullRsr36MCRCOk++;
  240. }
  241. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr36M, (int)pStatistic->CustomStat.ullRsr36MCRCOk);
  242. }
  243. else if(byRxRate==96){
  244. pStatistic->CustomStat.ullRsr48M++;
  245. if(byRSR & RSR_CRCOK) {
  246. pStatistic->CustomStat.ullRsr48MCRCOk++;
  247. }
  248. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr48M, (int)pStatistic->CustomStat.ullRsr48MCRCOk);
  249. }
  250. else if(byRxRate==108){
  251. pStatistic->CustomStat.ullRsr54M++;
  252. if(byRSR & RSR_CRCOK) {
  253. pStatistic->CustomStat.ullRsr54MCRCOk++;
  254. }
  255. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr54M, (int)pStatistic->CustomStat.ullRsr54MCRCOk);
  256. }
  257. else {
  258. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (int)pStatistic->dwRsrRxPacket+1, (int)pStatistic->dwRsrCRCOk);
  259. }
  260. if (byRSR & RSR_BSSIDOK)
  261. pStatistic->dwRsrBSSIDOk++;
  262. if (byRSR & RSR_BCNSSIDOK)
  263. pStatistic->dwRsrBCNSSIDOk++;
  264. if (byRSR & RSR_IVLDLEN) //invalid len (> 2312 byte)
  265. pStatistic->dwRsrLENErr++;
  266. if (byRSR & RSR_IVLDTYP) //invalid packet type
  267. pStatistic->dwRsrTYPErr++;
  268. if (byRSR & (RSR_IVLDTYP | RSR_IVLDLEN))
  269. pStatistic->dwRsrErr++;
  270. if (byNewRSR & NEWRSR_DECRYPTOK)
  271. pStatistic->dwNewRsrDECRYPTOK++;
  272. if (byNewRSR & NEWRSR_CFPIND)
  273. pStatistic->dwNewRsrCFP++;
  274. if (byNewRSR & NEWRSR_HWUTSF)
  275. pStatistic->dwNewRsrUTSF++;
  276. if (byNewRSR & NEWRSR_BCNHITAID)
  277. pStatistic->dwNewRsrHITAID++;
  278. if (byNewRSR & NEWRSR_BCNHITAID0)
  279. pStatistic->dwNewRsrHITAID0++;
  280. // increase rx packet count
  281. pStatistic->dwRsrRxPacket++;
  282. pStatistic->dwRsrRxOctet += cbFrameLength;
  283. if (IS_TYPE_DATA(pbyBuffer)) {
  284. pStatistic->dwRsrRxData++;
  285. } else if (IS_TYPE_MGMT(pbyBuffer)){
  286. pStatistic->dwRsrRxManage++;
  287. } else if (IS_TYPE_CONTROL(pbyBuffer)){
  288. pStatistic->dwRsrRxControl++;
  289. }
  290. if (byRSR & RSR_ADDRBROAD)
  291. pStatistic->dwRsrBroadcast++;
  292. else if (byRSR & RSR_ADDRMULTI)
  293. pStatistic->dwRsrMulticast++;
  294. else
  295. pStatistic->dwRsrDirected++;
  296. if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
  297. pStatistic->dwRsrRxFragment++;
  298. if (cbFrameLength < ETH_ZLEN + 4) {
  299. pStatistic->dwRsrRunt++;
  300. }
  301. else if (cbFrameLength == ETH_ZLEN + 4) {
  302. pStatistic->dwRsrRxFrmLen64++;
  303. }
  304. else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
  305. pStatistic->dwRsrRxFrmLen65_127++;
  306. }
  307. else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
  308. pStatistic->dwRsrRxFrmLen128_255++;
  309. }
  310. else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
  311. pStatistic->dwRsrRxFrmLen256_511++;
  312. }
  313. else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
  314. pStatistic->dwRsrRxFrmLen512_1023++;
  315. }
  316. else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4)) {
  317. pStatistic->dwRsrRxFrmLen1024_1518++;
  318. } else if (cbFrameLength > ETH_FRAME_LEN + 4) {
  319. pStatistic->dwRsrLong++;
  320. }
  321. }
  322. /*
  323. * Description: Update Rx Statistic Counter and copy Rx buffer
  324. *
  325. * Parameters:
  326. * In:
  327. * pStatistic - Pointer to Statistic Counter Data Structure
  328. * byRSR - Rx Status
  329. * byNewRSR - Rx Status
  330. * pbyBuffer - Rx Buffer
  331. * cbFrameLength - Rx Length
  332. * Out:
  333. * none
  334. *
  335. * Return Value: none
  336. *
  337. */
  338. void
  339. STAvUpdateRDStatCounterEx (
  340. PSStatCounter pStatistic,
  341. unsigned char byRSR,
  342. unsigned char byNewRSR,
  343. unsigned char byRxRate,
  344. unsigned char *pbyBuffer,
  345. unsigned int cbFrameLength
  346. )
  347. {
  348. STAvUpdateRDStatCounter(
  349. pStatistic,
  350. byRSR,
  351. byNewRSR,
  352. byRxRate,
  353. pbyBuffer,
  354. cbFrameLength
  355. );
  356. // rx length
  357. pStatistic->dwCntRxFrmLength = cbFrameLength;
  358. // rx pattern, we just see 10 bytes for sample
  359. memcpy(pStatistic->abyCntRxPattern, (unsigned char *)pbyBuffer, 10);
  360. }
  361. /*
  362. * Description: Update Tx Statistic Counter
  363. *
  364. * Parameters:
  365. * In:
  366. * pStatistic - Pointer to Statistic Counter Data Structure
  367. * byTSR0 - Tx Status
  368. * byTSR1 - Tx Status
  369. * pbyBuffer - Tx Buffer
  370. * cbFrameLength - Tx Length
  371. * uIdx - Index of Tx DMA
  372. * Out:
  373. * none
  374. *
  375. * Return Value: none
  376. *
  377. */
  378. void
  379. STAvUpdateTDStatCounter (
  380. PSStatCounter pStatistic,
  381. unsigned char byTSR0,
  382. unsigned char byTSR1,
  383. unsigned char *pbyBuffer,
  384. unsigned int cbFrameLength,
  385. unsigned int uIdx
  386. )
  387. {
  388. PWLAN_80211HDR_A4 pHeader;
  389. unsigned char *pbyDestAddr;
  390. unsigned char byTSR0_NCR = byTSR0 & TSR0_NCR;
  391. pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
  392. if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) {
  393. pbyDestAddr = &(pHeader->abyAddr1[0]);
  394. }
  395. else {
  396. pbyDestAddr = &(pHeader->abyAddr3[0]);
  397. }
  398. // increase tx packet count
  399. pStatistic->dwTsrTxPacket[uIdx]++;
  400. pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
  401. if (byTSR0_NCR != 0) {
  402. pStatistic->dwTsrRetry[uIdx]++;
  403. pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
  404. if (byTSR0_NCR == 1)
  405. pStatistic->dwTsrOnceRetry[uIdx]++;
  406. else
  407. pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
  408. }
  409. if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
  410. pStatistic->ullTsrOK[uIdx]++;
  411. pStatistic->CustomStat.ullTsrAllOK =
  412. (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
  413. // update counters in case that successful transmit
  414. if (is_broadcast_ether_addr(pbyDestAddr)) {
  415. pStatistic->ullTxBroadcastFrames[uIdx]++;
  416. pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength;
  417. }
  418. else if (is_multicast_ether_addr(pbyDestAddr)) {
  419. pStatistic->ullTxMulticastFrames[uIdx]++;
  420. pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength;
  421. }
  422. else {
  423. pStatistic->ullTxDirectedFrames[uIdx]++;
  424. pStatistic->ullTxDirectedBytes[uIdx] += (unsigned long long) cbFrameLength;
  425. }
  426. }
  427. else {
  428. if (byTSR1 & TSR1_TERR)
  429. pStatistic->dwTsrErr[uIdx]++;
  430. if (byTSR1 & TSR1_RETRYTMO)
  431. pStatistic->dwTsrRetryTimeout[uIdx]++;
  432. if (byTSR1 & TSR1_TMO)
  433. pStatistic->dwTsrTransmitTimeout[uIdx]++;
  434. if (byTSR1 & ACK_DATA)
  435. pStatistic->dwTsrACKData[uIdx]++;
  436. }
  437. if (is_broadcast_ether_addr(pbyDestAddr))
  438. pStatistic->dwTsrBroadcast[uIdx]++;
  439. else if (is_multicast_ether_addr(pbyDestAddr))
  440. pStatistic->dwTsrMulticast[uIdx]++;
  441. else
  442. pStatistic->dwTsrDirected[uIdx]++;
  443. }
  444. /*
  445. * Description: Update Tx Statistic Counter and copy Tx buffer
  446. *
  447. * Parameters:
  448. * In:
  449. * pStatistic - Pointer to Statistic Counter Data Structure
  450. * pbyBuffer - Tx Buffer
  451. * cbFrameLength - Tx Length
  452. * Out:
  453. * none
  454. *
  455. * Return Value: none
  456. *
  457. */
  458. void
  459. STAvUpdateTDStatCounterEx (
  460. PSStatCounter pStatistic,
  461. unsigned char *pbyBuffer,
  462. unsigned long cbFrameLength
  463. )
  464. {
  465. unsigned int uPktLength;
  466. uPktLength = (unsigned int)cbFrameLength;
  467. // tx length
  468. pStatistic->dwCntTxBufLength = uPktLength;
  469. // tx pattern, we just see 16 bytes for sample
  470. memcpy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
  471. }
  472. /*
  473. * Description: Update 802.11 mib counter
  474. *
  475. * Parameters:
  476. * In:
  477. * p802_11Counter - Pointer to 802.11 mib counter
  478. * pStatistic - Pointer to Statistic Counter Data Structure
  479. * dwCounter - hardware counter for 802.11 mib
  480. * Out:
  481. * none
  482. *
  483. * Return Value: none
  484. *
  485. */
  486. void
  487. STAvUpdate802_11Counter(
  488. PSDot11Counters p802_11Counter,
  489. PSStatCounter pStatistic,
  490. unsigned long dwCounter
  491. )
  492. {
  493. //p802_11Counter->TransmittedFragmentCount
  494. p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
  495. pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
  496. pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
  497. pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
  498. p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
  499. p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
  500. p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
  501. pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
  502. //p802_11Counter->FrameDuplicateCount
  503. p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff);
  504. p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8);
  505. p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16);
  506. p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24);
  507. //p802_11Counter->ReceivedFragmentCount
  508. p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast +
  509. pStatistic->dwRsrMulticast);
  510. }
  511. /*
  512. * Description: Clear 802.11 mib counter
  513. *
  514. * Parameters:
  515. * In:
  516. * p802_11Counter - Pointer to 802.11 mib counter
  517. * Out:
  518. * none
  519. *
  520. * Return Value: none
  521. *
  522. */
  523. void
  524. STAvClear802_11Counter(PSDot11Counters p802_11Counter)
  525. {
  526. // set memory to zero
  527. memset(p802_11Counter, 0, sizeof(SDot11Counters));
  528. }