1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
48static int msglevel =MSG_LEVEL_INFO;
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73void STAvClearAllCounter (PSStatCounter pStatistic)
74{
75
76 memset(pStatistic, 0, sizeof(SStatCounter));
77}
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, unsigned long dwIsr)
94{
95
96
97
98
99
100 if (dwIsr == 0) {
101 pStatistic->ISRStat.dwIsrUnknown++;
102 return;
103 }
104
105
106 if (dwIsr & ISR_TXDMA0)
107 pStatistic->ISRStat.dwIsrTx0OK++;
108
109 if (dwIsr & ISR_AC0DMA)
110 pStatistic->ISRStat.dwIsrAC0TxOK++;
111
112 if (dwIsr & ISR_BNTX)
113 pStatistic->ISRStat.dwIsrBeaconTxOK++;
114
115 if (dwIsr & ISR_RXDMA0)
116 pStatistic->ISRStat.dwIsrRx0OK++;
117
118 if (dwIsr & ISR_TBTT)
119 pStatistic->ISRStat.dwIsrTBTTInt++;
120
121 if (dwIsr & ISR_SOFTTIMER)
122 pStatistic->ISRStat.dwIsrSTIMERInt++;
123
124 if (dwIsr & ISR_WATCHDOG)
125 pStatistic->ISRStat.dwIsrWatchDog++;
126
127 if (dwIsr & ISR_FETALERR)
128 pStatistic->ISRStat.dwIsrUnrecoverableError++;
129
130 if (dwIsr & ISR_SOFTINT)
131 pStatistic->ISRStat.dwIsrSoftInterrupt++;
132
133 if (dwIsr & ISR_MIBNEARFULL)
134 pStatistic->ISRStat.dwIsrMIBNearfull++;
135
136 if (dwIsr & ISR_RXNOBUF)
137 pStatistic->ISRStat.dwIsrRxNoBuf++;
138
139 if (dwIsr & ISR_RXDMA1)
140 pStatistic->ISRStat.dwIsrRx1OK++;
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 if (dwIsr & ISR_SOFTTIMER1)
158 pStatistic->ISRStat.dwIsrSTIMER1Int++;
159
160}
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179void STAvUpdateRDStatCounter (PSStatCounter pStatistic,
180 unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate,
181 unsigned char *pbyBuffer, unsigned int cbFrameLength)
182{
183
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
195 if (byRSR & RSR_ADDRBROAD) {
196 pStatistic->ullRxBroadcastFrames++;
197 pStatistic->ullRxBroadcastBytes += (unsigned long long) cbFrameLength;
198 }
199 else if (byRSR & RSR_ADDRMULTI) {
200 pStatistic->ullRxMulticastFrames++;
201 pStatistic->ullRxMulticastBytes += (unsigned long long) cbFrameLength;
202 }
203 else {
204 pStatistic->ullRxDirectedFrames++;
205 pStatistic->ullRxDirectedBytes += (unsigned long long) cbFrameLength;
206 }
207 }
208 }
209
210 if(byRxRate==22) {
211 pStatistic->CustomStat.ullRsr11M++;
212 if(byRSR & RSR_CRCOK) {
213 pStatistic->CustomStat.ullRsr11MCRCOk++;
214 }
215 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr11M, (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
216 }
217 else if(byRxRate==11) {
218 pStatistic->CustomStat.ullRsr5M++;
219 if(byRSR & RSR_CRCOK) {
220 pStatistic->CustomStat.ullRsr5MCRCOk++;
221 }
222 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr5M, (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
223 }
224 else if(byRxRate==4) {
225 pStatistic->CustomStat.ullRsr2M++;
226 if(byRSR & RSR_CRCOK) {
227 pStatistic->CustomStat.ullRsr2MCRCOk++;
228 }
229 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr2M, (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
230 }
231 else if(byRxRate==2){
232 pStatistic->CustomStat.ullRsr1M++;
233 if(byRSR & RSR_CRCOK) {
234 pStatistic->CustomStat.ullRsr1MCRCOk++;
235 }
236 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr1M, (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
237 }
238 else if(byRxRate==12){
239 pStatistic->CustomStat.ullRsr6M++;
240 if(byRSR & RSR_CRCOK) {
241 pStatistic->CustomStat.ullRsr6MCRCOk++;
242 }
243 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr6M, (int)pStatistic->CustomStat.ullRsr6MCRCOk);
244 }
245 else if(byRxRate==18){
246 pStatistic->CustomStat.ullRsr9M++;
247 if(byRSR & RSR_CRCOK) {
248 pStatistic->CustomStat.ullRsr9MCRCOk++;
249 }
250 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr9M, (int)pStatistic->CustomStat.ullRsr9MCRCOk);
251 }
252 else if(byRxRate==24){
253 pStatistic->CustomStat.ullRsr12M++;
254 if(byRSR & RSR_CRCOK) {
255 pStatistic->CustomStat.ullRsr12MCRCOk++;
256 }
257 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr12M, (int)pStatistic->CustomStat.ullRsr12MCRCOk);
258 }
259 else if(byRxRate==36){
260 pStatistic->CustomStat.ullRsr18M++;
261 if(byRSR & RSR_CRCOK) {
262 pStatistic->CustomStat.ullRsr18MCRCOk++;
263 }
264 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr18M, (int)pStatistic->CustomStat.ullRsr18MCRCOk);
265 }
266 else if(byRxRate==48){
267 pStatistic->CustomStat.ullRsr24M++;
268 if(byRSR & RSR_CRCOK) {
269 pStatistic->CustomStat.ullRsr24MCRCOk++;
270 }
271 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr24M, (int)pStatistic->CustomStat.ullRsr24MCRCOk);
272 }
273 else if(byRxRate==72){
274 pStatistic->CustomStat.ullRsr36M++;
275 if(byRSR & RSR_CRCOK) {
276 pStatistic->CustomStat.ullRsr36MCRCOk++;
277 }
278 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr36M, (int)pStatistic->CustomStat.ullRsr36MCRCOk);
279 }
280 else if(byRxRate==96){
281 pStatistic->CustomStat.ullRsr48M++;
282 if(byRSR & RSR_CRCOK) {
283 pStatistic->CustomStat.ullRsr48MCRCOk++;
284 }
285 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr48M, (int)pStatistic->CustomStat.ullRsr48MCRCOk);
286 }
287 else if(byRxRate==108){
288 pStatistic->CustomStat.ullRsr54M++;
289 if(byRSR & RSR_CRCOK) {
290 pStatistic->CustomStat.ullRsr54MCRCOk++;
291 }
292 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr54M, (int)pStatistic->CustomStat.ullRsr54MCRCOk);
293 }
294 else {
295 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (int)pStatistic->dwRsrRxPacket+1, (int)pStatistic->dwRsrCRCOk);
296 }
297
298 if (byRSR & RSR_BSSIDOK)
299 pStatistic->dwRsrBSSIDOk++;
300
301 if (byRSR & RSR_BCNSSIDOK)
302 pStatistic->dwRsrBCNSSIDOk++;
303 if (byRSR & RSR_IVLDLEN)
304 pStatistic->dwRsrLENErr++;
305 if (byRSR & RSR_IVLDTYP)
306 pStatistic->dwRsrTYPErr++;
307 if (byRSR & (RSR_IVLDTYP | RSR_IVLDLEN))
308 pStatistic->dwRsrErr++;
309
310 if (byNewRSR & NEWRSR_DECRYPTOK)
311 pStatistic->dwNewRsrDECRYPTOK++;
312 if (byNewRSR & NEWRSR_CFPIND)
313 pStatistic->dwNewRsrCFP++;
314 if (byNewRSR & NEWRSR_HWUTSF)
315 pStatistic->dwNewRsrUTSF++;
316 if (byNewRSR & NEWRSR_BCNHITAID)
317 pStatistic->dwNewRsrHITAID++;
318 if (byNewRSR & NEWRSR_BCNHITAID0)
319 pStatistic->dwNewRsrHITAID0++;
320
321
322 pStatistic->dwRsrRxPacket++;
323 pStatistic->dwRsrRxOctet += cbFrameLength;
324
325
326 if (IS_TYPE_DATA(pbyBuffer)) {
327 pStatistic->dwRsrRxData++;
328 } else if (IS_TYPE_MGMT(pbyBuffer)){
329 pStatistic->dwRsrRxManage++;
330 } else if (IS_TYPE_CONTROL(pbyBuffer)){
331 pStatistic->dwRsrRxControl++;
332 }
333
334 if (byRSR & RSR_ADDRBROAD)
335 pStatistic->dwRsrBroadcast++;
336 else if (byRSR & RSR_ADDRMULTI)
337 pStatistic->dwRsrMulticast++;
338 else
339 pStatistic->dwRsrDirected++;
340
341 if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
342 pStatistic->dwRsrRxFragment++;
343
344 if (cbFrameLength < ETH_ZLEN + 4) {
345 pStatistic->dwRsrRunt++;
346 }
347 else if (cbFrameLength == ETH_ZLEN + 4) {
348 pStatistic->dwRsrRxFrmLen64++;
349 }
350 else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
351 pStatistic->dwRsrRxFrmLen65_127++;
352 }
353 else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
354 pStatistic->dwRsrRxFrmLen128_255++;
355 }
356 else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
357 pStatistic->dwRsrRxFrmLen256_511++;
358 }
359 else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
360 pStatistic->dwRsrRxFrmLen512_1023++;
361 }
362 else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4)) {
363 pStatistic->dwRsrRxFrmLen1024_1518++;
364 } else if (cbFrameLength > ETH_FRAME_LEN + 4) {
365 pStatistic->dwRsrLong++;
366 }
367
368}
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389void
390STAvUpdateRDStatCounterEx (
391 PSStatCounter pStatistic,
392 unsigned char byRSR,
393 unsigned char byNewRSR,
394 unsigned char byRxRate,
395 unsigned char *pbyBuffer,
396 unsigned int cbFrameLength
397 )
398{
399 STAvUpdateRDStatCounter(
400 pStatistic,
401 byRSR,
402 byNewRSR,
403 byRxRate,
404 pbyBuffer,
405 cbFrameLength
406 );
407
408
409 pStatistic->dwCntRxFrmLength = cbFrameLength;
410
411 memcpy(pStatistic->abyCntRxPattern, (unsigned char *)pbyBuffer, 10);
412}
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432void
433STAvUpdateTDStatCounter (
434 PSStatCounter pStatistic,
435 unsigned char byTSR0,
436 unsigned char byTSR1,
437 unsigned char *pbyBuffer,
438 unsigned int cbFrameLength,
439 unsigned int uIdx
440 )
441{
442 PWLAN_80211HDR_A4 pHeader;
443 unsigned char *pbyDestAddr;
444 unsigned char byTSR0_NCR = byTSR0 & TSR0_NCR;
445
446
447
448 pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
449 if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) {
450 pbyDestAddr = &(pHeader->abyAddr1[0]);
451 }
452 else {
453 pbyDestAddr = &(pHeader->abyAddr3[0]);
454 }
455
456 pStatistic->dwTsrTxPacket[uIdx]++;
457 pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
458
459 if (byTSR0_NCR != 0) {
460 pStatistic->dwTsrRetry[uIdx]++;
461 pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
462
463 if (byTSR0_NCR == 1)
464 pStatistic->dwTsrOnceRetry[uIdx]++;
465 else
466 pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
467 }
468
469 if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
470 pStatistic->ullTsrOK[uIdx]++;
471 pStatistic->CustomStat.ullTsrAllOK =
472 (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
473
474 if (is_broadcast_ether_addr(pbyDestAddr)) {
475 pStatistic->ullTxBroadcastFrames[uIdx]++;
476 pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength;
477 }
478 else if (is_multicast_ether_addr(pbyDestAddr)) {
479 pStatistic->ullTxMulticastFrames[uIdx]++;
480 pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength;
481 }
482 else {
483 pStatistic->ullTxDirectedFrames[uIdx]++;
484 pStatistic->ullTxDirectedBytes[uIdx] += (unsigned long long) cbFrameLength;
485 }
486 }
487 else {
488 if (byTSR1 & TSR1_TERR)
489 pStatistic->dwTsrErr[uIdx]++;
490 if (byTSR1 & TSR1_RETRYTMO)
491 pStatistic->dwTsrRetryTimeout[uIdx]++;
492 if (byTSR1 & TSR1_TMO)
493 pStatistic->dwTsrTransmitTimeout[uIdx]++;
494 if (byTSR1 & ACK_DATA)
495 pStatistic->dwTsrACKData[uIdx]++;
496 }
497
498 if (is_broadcast_ether_addr(pbyDestAddr))
499 pStatistic->dwTsrBroadcast[uIdx]++;
500 else if (is_multicast_ether_addr(pbyDestAddr))
501 pStatistic->dwTsrMulticast[uIdx]++;
502 else
503 pStatistic->dwTsrDirected[uIdx]++;
504
505}
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522void
523STAvUpdateTDStatCounterEx (
524 PSStatCounter pStatistic,
525 unsigned char *pbyBuffer,
526 unsigned long cbFrameLength
527 )
528{
529 unsigned int uPktLength;
530
531 uPktLength = (unsigned int)cbFrameLength;
532
533
534 pStatistic->dwCntTxBufLength = uPktLength;
535
536 memcpy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
537}
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554void
555STAvUpdate802_11Counter(
556 PSDot11Counters p802_11Counter,
557 PSStatCounter pStatistic,
558 unsigned long dwCounter
559 )
560{
561
562 p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
563 pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
564 pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
565 pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
566 p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
567 p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
568 p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
569 pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
570
571 p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff);
572 p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8);
573 p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16);
574 p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24);
575
576 p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast +
577 pStatistic->dwRsrMulticast);
578}
579
580
581
582
583
584
585
586
587
588
589
590
591
592void
593STAvClear802_11Counter(PSDot11Counters p802_11Counter)
594{
595
596 memset(p802_11Counter, 0, sizeof(SDot11Counters));
597}
598