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