Merge git://git.infradead.org/iommu-2.6
[linux-2.6] / drivers / staging / vt6655 / mib.c
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
40
41 #if !defined(__UPC_H__)
42 #include "upc.h"
43 #endif
44 #if !defined(__MAC_H__)
45 #include "mac.h"
46 #endif
47 #if !defined(__TBIT_H__)
48 #include "tbit.h"
49 #endif
50 #if !defined(__TETHER_H__)
51 #include "tether.h"
52 #endif
53 #if !defined(__MIB_H__)
54 #include "mib.h"
55 #endif
56 #if !defined(__WCTL_H__)
57 #include "wctl.h"
58 #endif
59 #if !defined(__UMEM_H__)
60 #include "umem.h"
61 #endif
62 #if !defined(__BASEBAND_H__)
63 #include "baseband.h"
64 #endif
65
66 /*---------------------  Static Definitions -------------------------*/
67 static int          msglevel                =MSG_LEVEL_INFO;
68 /*---------------------  Static Classes  ----------------------------*/
69
70 /*---------------------  Static Variables  --------------------------*/
71
72 /*---------------------  Static Functions  --------------------------*/
73
74 /*---------------------  Export Variables  --------------------------*/
75
76 /*---------------------  Export Functions  --------------------------*/
77
78
79
80 /*
81  * Description: Clear All Statistic Counter
82  *
83  * Parameters:
84  *  In:
85  *      pStatistic  - Pointer to Statistic Counter Data Structure
86  *  Out:
87  *      none
88  *
89  * Return Value: none
90  *
91  */
92 void STAvClearAllCounter (PSStatCounter pStatistic)
93 {
94     // set memory to zero
95     ZERO_MEMORY(pStatistic, sizeof(SStatCounter));
96 }
97
98
99 /*
100  * Description: Update Isr Statistic Counter
101  *
102  * Parameters:
103  *  In:
104  *      pStatistic  - Pointer to Statistic Counter Data Structure
105  *      wisr        - Interrupt status
106  *  Out:
107  *      none
108  *
109  * Return Value: none
110  *
111  */
112 void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, DWORD dwIsr)
113 {
114     /**********************/
115     /* ABNORMAL interrupt */
116     /**********************/
117     // not any IMR bit invoke irq
118
119     if (dwIsr == 0) {
120         pStatistic->ISRStat.dwIsrUnknown++;
121         return;
122     }
123
124 //Added by Kyle
125     if (BITbIsBitOn(dwIsr, ISR_TXDMA0))               // ISR, bit0
126         pStatistic->ISRStat.dwIsrTx0OK++;             // TXDMA0 successful
127
128     if (BITbIsBitOn(dwIsr, ISR_AC0DMA))               // ISR, bit1
129         pStatistic->ISRStat.dwIsrAC0TxOK++;           // AC0DMA successful
130
131     if (BITbIsBitOn(dwIsr, ISR_BNTX))                 // ISR, bit2
132         pStatistic->ISRStat.dwIsrBeaconTxOK++;        // BeaconTx successful
133
134     if (BITbIsBitOn(dwIsr, ISR_RXDMA0))               // ISR, bit3
135         pStatistic->ISRStat.dwIsrRx0OK++;             // Rx0 successful
136
137     if (BITbIsBitOn(dwIsr, ISR_TBTT))                 // ISR, bit4
138         pStatistic->ISRStat.dwIsrTBTTInt++;           // TBTT successful
139
140     if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER))            // ISR, bit6
141         pStatistic->ISRStat.dwIsrSTIMERInt++;
142
143     if (BITbIsBitOn(dwIsr, ISR_WATCHDOG))             // ISR, bit7
144         pStatistic->ISRStat.dwIsrWatchDog++;
145
146     if (BITbIsBitOn(dwIsr, ISR_FETALERR))             // ISR, bit8
147         pStatistic->ISRStat.dwIsrUnrecoverableError++;
148
149     if (BITbIsBitOn(dwIsr, ISR_SOFTINT))              // ISR, bit9
150         pStatistic->ISRStat.dwIsrSoftInterrupt++;     // software interrupt
151
152     if (BITbIsBitOn(dwIsr, ISR_MIBNEARFULL))          // ISR, bit10
153         pStatistic->ISRStat.dwIsrMIBNearfull++;
154
155     if (BITbIsBitOn(dwIsr, ISR_RXNOBUF))              // ISR, bit11
156         pStatistic->ISRStat.dwIsrRxNoBuf++;           // Rx No Buff
157
158     if (BITbIsBitOn(dwIsr, ISR_RXDMA1))               // ISR, bit12
159         pStatistic->ISRStat.dwIsrRx1OK++;             // Rx1 successful
160
161 //    if (BITbIsBitOn(dwIsr, ISR_ATIMTX))               // ISR, bit13
162 //        pStatistic->ISRStat.dwIsrATIMTxOK++;          // ATIMTX successful
163
164 //    if (BITbIsBitOn(dwIsr, ISR_SYNCTX))               // ISR, bit14
165 //        pStatistic->ISRStat.dwIsrSYNCTxOK++;          // SYNCTX successful
166
167 //    if (BITbIsBitOn(dwIsr, ISR_CFPEND))               // ISR, bit18
168 //        pStatistic->ISRStat.dwIsrCFPEnd++;
169
170 //    if (BITbIsBitOn(dwIsr, ISR_ATIMEND))              // ISR, bit19
171 //        pStatistic->ISRStat.dwIsrATIMEnd++;
172
173 //    if (BITbIsBitOn(dwIsr, ISR_SYNCFLUSHOK))          // ISR, bit20
174 //        pStatistic->ISRStat.dwIsrSYNCFlushOK++;
175
176     if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER1))           // ISR, bit21
177         pStatistic->ISRStat.dwIsrSTIMER1Int++;
178
179 }
180
181
182 /*
183  * Description: Update Rx Statistic Counter
184  *
185  * Parameters:
186  *  In:
187  *      pStatistic      - Pointer to Statistic Counter Data Structure
188  *      byRSR           - Rx Status
189  *      byNewRSR        - Rx Status
190  *      pbyBuffer       - Rx Buffer
191  *      cbFrameLength   - Rx Length
192  *  Out:
193  *      none
194  *
195  * Return Value: none
196  *
197  */
198 void STAvUpdateRDStatCounter (PSStatCounter pStatistic,
199                               BYTE byRSR, BYTE byNewRSR, BYTE byRxRate,
200                               PBYTE pbyBuffer, UINT cbFrameLength)
201 {
202     //need change
203     PS802_11Header pHeader = (PS802_11Header)pbyBuffer;
204
205     if (BITbIsBitOn(byRSR, RSR_ADDROK))
206         pStatistic->dwRsrADDROk++;
207     if (BITbIsBitOn(byRSR, RSR_CRCOK)) {
208         pStatistic->dwRsrCRCOk++;
209
210         pStatistic->ullRsrOK++;
211
212         if (cbFrameLength >= U_ETHER_ADDR_LEN) {
213             // update counters in case that successful transmit
214             if (BITbIsBitOn(byRSR, RSR_ADDRBROAD)) {
215                 pStatistic->ullRxBroadcastFrames++;
216                 pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength;
217             }
218             else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI)) {
219                 pStatistic->ullRxMulticastFrames++;
220                 pStatistic->ullRxMulticastBytes += (ULONGLONG)cbFrameLength;
221             }
222             else {
223                 pStatistic->ullRxDirectedFrames++;
224                 pStatistic->ullRxDirectedBytes += (ULONGLONG)cbFrameLength;
225             }
226         }
227     }
228
229     if(byRxRate==22) {
230         pStatistic->CustomStat.ullRsr11M++;
231         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
232             pStatistic->CustomStat.ullRsr11MCRCOk++;
233         }
234         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr11M, (INT)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
235     }
236     else if(byRxRate==11) {
237         pStatistic->CustomStat.ullRsr5M++;
238         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
239             pStatistic->CustomStat.ullRsr5MCRCOk++;
240         }
241         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr5M, (INT)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
242     }
243     else if(byRxRate==4) {
244         pStatistic->CustomStat.ullRsr2M++;
245         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
246             pStatistic->CustomStat.ullRsr2MCRCOk++;
247         }
248         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr2M, (INT)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
249     }
250     else if(byRxRate==2){
251         pStatistic->CustomStat.ullRsr1M++;
252         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
253             pStatistic->CustomStat.ullRsr1MCRCOk++;
254         }
255         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr1M, (INT)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
256     }
257     else if(byRxRate==12){
258         pStatistic->CustomStat.ullRsr6M++;
259         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
260             pStatistic->CustomStat.ullRsr6MCRCOk++;
261         }
262         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr6M, (INT)pStatistic->CustomStat.ullRsr6MCRCOk);
263     }
264     else if(byRxRate==18){
265         pStatistic->CustomStat.ullRsr9M++;
266         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
267             pStatistic->CustomStat.ullRsr9MCRCOk++;
268         }
269         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr9M, (INT)pStatistic->CustomStat.ullRsr9MCRCOk);
270     }
271     else if(byRxRate==24){
272         pStatistic->CustomStat.ullRsr12M++;
273         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
274             pStatistic->CustomStat.ullRsr12MCRCOk++;
275         }
276         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr12M, (INT)pStatistic->CustomStat.ullRsr12MCRCOk);
277     }
278     else if(byRxRate==36){
279         pStatistic->CustomStat.ullRsr18M++;
280         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
281             pStatistic->CustomStat.ullRsr18MCRCOk++;
282         }
283         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr18M, (INT)pStatistic->CustomStat.ullRsr18MCRCOk);
284     }
285     else if(byRxRate==48){
286         pStatistic->CustomStat.ullRsr24M++;
287         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
288             pStatistic->CustomStat.ullRsr24MCRCOk++;
289         }
290         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr24M, (INT)pStatistic->CustomStat.ullRsr24MCRCOk);
291     }
292     else if(byRxRate==72){
293         pStatistic->CustomStat.ullRsr36M++;
294         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
295             pStatistic->CustomStat.ullRsr36MCRCOk++;
296         }
297         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr36M, (INT)pStatistic->CustomStat.ullRsr36MCRCOk);
298     }
299     else if(byRxRate==96){
300         pStatistic->CustomStat.ullRsr48M++;
301         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
302             pStatistic->CustomStat.ullRsr48MCRCOk++;
303         }
304         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr48M, (INT)pStatistic->CustomStat.ullRsr48MCRCOk);
305     }
306     else if(byRxRate==108){
307         pStatistic->CustomStat.ullRsr54M++;
308         if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
309             pStatistic->CustomStat.ullRsr54MCRCOk++;
310         }
311         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk);
312     }
313     else {
314         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (INT)pStatistic->dwRsrRxPacket+1, (INT)pStatistic->dwRsrCRCOk);
315     }
316
317     if (BITbIsBitOn(byRSR, RSR_BSSIDOK))
318         pStatistic->dwRsrBSSIDOk++;
319
320     if (BITbIsBitOn(byRSR, RSR_BCNSSIDOK))
321         pStatistic->dwRsrBCNSSIDOk++;
322     if (BITbIsBitOn(byRSR, RSR_IVLDLEN))  //invalid len (> 2312 byte)
323         pStatistic->dwRsrLENErr++;
324     if (BITbIsBitOn(byRSR, RSR_IVLDTYP))  //invalid packet type
325         pStatistic->dwRsrTYPErr++;
326     if (BITbIsBitOn(byRSR, (RSR_IVLDTYP | RSR_IVLDLEN)))
327         pStatistic->dwRsrErr++;
328
329     if (BITbIsBitOn(byNewRSR, NEWRSR_DECRYPTOK))
330         pStatistic->dwNewRsrDECRYPTOK++;
331     if (BITbIsBitOn(byNewRSR, NEWRSR_CFPIND))
332         pStatistic->dwNewRsrCFP++;
333     if (BITbIsBitOn(byNewRSR, NEWRSR_HWUTSF))
334         pStatistic->dwNewRsrUTSF++;
335     if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID))
336         pStatistic->dwNewRsrHITAID++;
337     if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID0))
338         pStatistic->dwNewRsrHITAID0++;
339
340     // increase rx packet count
341     pStatistic->dwRsrRxPacket++;
342     pStatistic->dwRsrRxOctet += cbFrameLength;
343
344
345     if (IS_TYPE_DATA(pbyBuffer)) {
346         pStatistic->dwRsrRxData++;
347     } else if (IS_TYPE_MGMT(pbyBuffer)){
348         pStatistic->dwRsrRxManage++;
349     } else if (IS_TYPE_CONTROL(pbyBuffer)){
350         pStatistic->dwRsrRxControl++;
351     }
352
353     if (BITbIsBitOn(byRSR, RSR_ADDRBROAD))
354         pStatistic->dwRsrBroadcast++;
355     else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI))
356         pStatistic->dwRsrMulticast++;
357     else
358         pStatistic->dwRsrDirected++;
359
360     if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
361         pStatistic->dwRsrRxFragment++;
362
363     if (cbFrameLength < MIN_PACKET_LEN + 4) {
364         pStatistic->dwRsrRunt++;
365     }
366     else if (cbFrameLength == MIN_PACKET_LEN + 4) {
367         pStatistic->dwRsrRxFrmLen64++;
368     }
369     else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
370         pStatistic->dwRsrRxFrmLen65_127++;
371     }
372     else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
373         pStatistic->dwRsrRxFrmLen128_255++;
374     }
375     else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
376         pStatistic->dwRsrRxFrmLen256_511++;
377     }
378     else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
379         pStatistic->dwRsrRxFrmLen512_1023++;
380     }
381     else if ((1024 <= cbFrameLength) && (cbFrameLength <= MAX_PACKET_LEN + 4)) {
382         pStatistic->dwRsrRxFrmLen1024_1518++;
383     } else if (cbFrameLength > MAX_PACKET_LEN + 4) {
384         pStatistic->dwRsrLong++;
385     }
386
387 }
388
389
390
391 /*
392  * Description: Update Rx Statistic Counter and copy Rx buffer
393  *
394  * Parameters:
395  *  In:
396  *      pStatistic      - Pointer to Statistic Counter Data Structure
397  *      byRSR           - Rx Status
398  *      byNewRSR        - Rx Status
399  *      pbyBuffer       - Rx Buffer
400  *      cbFrameLength   - Rx Length
401  *  Out:
402  *      none
403  *
404  * Return Value: none
405  *
406  */
407
408 void
409 STAvUpdateRDStatCounterEx (
410     PSStatCounter   pStatistic,
411     BYTE            byRSR,
412     BYTE            byNewRSR,
413     BYTE            byRxRate,
414     PBYTE           pbyBuffer,
415     UINT            cbFrameLength
416     )
417 {
418     STAvUpdateRDStatCounter(
419                     pStatistic,
420                     byRSR,
421                     byNewRSR,
422                     byRxRate,
423                     pbyBuffer,
424                     cbFrameLength
425                     );
426
427     // rx length
428     pStatistic->dwCntRxFrmLength = cbFrameLength;
429     // rx pattern, we just see 10 bytes for sample
430     MEMvCopy(pStatistic->abyCntRxPattern, (PBYTE)pbyBuffer, 10);
431 }
432
433
434 /*
435  * Description: Update Tx Statistic Counter
436  *
437  * Parameters:
438  *  In:
439  *      pStatistic      - Pointer to Statistic Counter Data Structure
440  *      byTSR0          - Tx Status
441  *      byTSR1          - Tx Status
442  *      pbyBuffer       - Tx Buffer
443  *      cbFrameLength   - Tx Length
444  *      uIdx            - Index of Tx DMA
445  *  Out:
446  *      none
447  *
448  * Return Value: none
449  *
450  */
451 void
452 STAvUpdateTDStatCounter (
453     PSStatCounter   pStatistic,
454     BYTE            byTSR0,
455     BYTE            byTSR1,
456     PBYTE           pbyBuffer,
457     UINT            cbFrameLength,
458     UINT            uIdx
459     )
460 {
461     PWLAN_80211HDR_A4   pHeader;
462     PBYTE               pbyDestAddr;
463     BYTE                byTSR0_NCR = byTSR0 & TSR0_NCR;
464
465
466
467     pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
468     if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) {
469         pbyDestAddr = &(pHeader->abyAddr1[0]);
470     }
471     else {
472         pbyDestAddr = &(pHeader->abyAddr3[0]);
473     }
474     // increase tx packet count
475     pStatistic->dwTsrTxPacket[uIdx]++;
476     pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
477
478     if (byTSR0_NCR != 0) {
479         pStatistic->dwTsrRetry[uIdx]++;
480         pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
481
482         if (byTSR0_NCR == 1)
483             pStatistic->dwTsrOnceRetry[uIdx]++;
484         else
485             pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
486     }
487
488     if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
489         pStatistic->ullTsrOK[uIdx]++;
490         pStatistic->CustomStat.ullTsrAllOK =
491             (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
492         // update counters in case that successful transmit
493         if (IS_BROADCAST_ADDRESS(pbyDestAddr)) {
494             pStatistic->ullTxBroadcastFrames[uIdx]++;
495             pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength;
496         }
497         else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) {
498             pStatistic->ullTxMulticastFrames[uIdx]++;
499             pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength;
500         }
501         else {
502             pStatistic->ullTxDirectedFrames[uIdx]++;
503             pStatistic->ullTxDirectedBytes[uIdx] += (ULONGLONG)cbFrameLength;
504         }
505     }
506     else {
507         if (BITbIsBitOn(byTSR1, TSR1_TERR))
508             pStatistic->dwTsrErr[uIdx]++;
509         if (BITbIsBitOn(byTSR1, TSR1_RETRYTMO))
510             pStatistic->dwTsrRetryTimeout[uIdx]++;
511         if (BITbIsBitOn(byTSR1, TSR1_TMO))
512             pStatistic->dwTsrTransmitTimeout[uIdx]++;
513         if (BITbIsBitOn(byTSR1, ACK_DATA))
514             pStatistic->dwTsrACKData[uIdx]++;
515     }
516
517     if (IS_BROADCAST_ADDRESS(pbyDestAddr))
518         pStatistic->dwTsrBroadcast[uIdx]++;
519     else if (IS_MULTICAST_ADDRESS(pbyDestAddr))
520         pStatistic->dwTsrMulticast[uIdx]++;
521     else
522         pStatistic->dwTsrDirected[uIdx]++;
523
524 }
525
526
527 /*
528  * Description: Update Tx Statistic Counter and copy Tx buffer
529  *
530  * Parameters:
531  *  In:
532  *      pStatistic      - Pointer to Statistic Counter Data Structure
533  *      pbyBuffer       - Tx Buffer
534  *      cbFrameLength   - Tx Length
535  *  Out:
536  *      none
537  *
538  * Return Value: none
539  *
540  */
541 void
542 STAvUpdateTDStatCounterEx (
543     PSStatCounter   pStatistic,
544     PBYTE           pbyBuffer,
545     DWORD           cbFrameLength
546     )
547 {
548     UINT    uPktLength;
549
550     uPktLength = (UINT)cbFrameLength;
551
552     // tx length
553     pStatistic->dwCntTxBufLength = uPktLength;
554     // tx pattern, we just see 16 bytes for sample
555     MEMvCopy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
556 }
557
558
559 /*
560  * Description: Update 802.11 mib counter
561  *
562  * Parameters:
563  *  In:
564  *      p802_11Counter  - Pointer to 802.11 mib counter
565  *      pStatistic      - Pointer to Statistic Counter Data Structure
566  *      dwCounter       - hardware counter for 802.11 mib
567  *  Out:
568  *      none
569  *
570  * Return Value: none
571  *
572  */
573 void
574 STAvUpdate802_11Counter(
575     PSDot11Counters         p802_11Counter,
576     PSStatCounter           pStatistic,
577     DWORD                   dwCounter
578     )
579 {
580     //p802_11Counter->TransmittedFragmentCount
581     p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
582                                                                   pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
583                                                                   pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
584                                                                   pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
585     p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
586     p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
587     p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
588                                                           pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
589     //p802_11Counter->FrameDuplicateCount
590     p802_11Counter->RTSSuccessCount += (ULONGLONG)  (dwCounter & 0x000000ff);
591     p802_11Counter->RTSFailureCount += (ULONGLONG) ((dwCounter & 0x0000ff00) >> 8);
592     p802_11Counter->ACKFailureCount += (ULONGLONG) ((dwCounter & 0x00ff0000) >> 16);
593     p802_11Counter->FCSErrorCount +=   (ULONGLONG) ((dwCounter & 0xff000000) >> 24);
594     //p802_11Counter->ReceivedFragmentCount
595     p802_11Counter->MulticastReceivedFrameCount = (ULONGLONG) (pStatistic->dwRsrBroadcast +
596                                                                pStatistic->dwRsrMulticast);
597 }
598
599 /*
600  * Description: Clear 802.11 mib counter
601  *
602  * Parameters:
603  *  In:
604  *      p802_11Counter  - Pointer to 802.11 mib counter
605  *  Out:
606  *      none
607  *
608  * Return Value: none
609  *
610  */
611 void
612 STAvClear802_11Counter(PSDot11Counters p802_11Counter)
613 {
614     // set memory to zero
615     ZERO_MEMORY(p802_11Counter, sizeof(SDot11Counters));
616 }