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#include "mac.h"
39#include "tether.h"
40#include "mib.h"
41#include "wctl.h"
42#include "baseband.h"
43
44static int msglevel =MSG_LEVEL_INFO;
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, u8 byIsr0, u8 byIsr1)
60{
61
62
63
64
65 if (byIsr0 == 0) {
66 pStatistic->ISRStat.dwIsrUnknown++;
67 return;
68 }
69
70 if (byIsr0 & ISR_ACTX)
71 pStatistic->ISRStat.dwIsrTx0OK++;
72
73 if (byIsr0 & ISR_BNTX)
74 pStatistic->ISRStat.dwIsrBeaconTxOK++;
75
76 if (byIsr0 & ISR_RXDMA0)
77 pStatistic->ISRStat.dwIsrRx0OK++;
78
79 if (byIsr0 & ISR_TBTT)
80 pStatistic->ISRStat.dwIsrTBTTInt++;
81
82 if (byIsr0 & ISR_SOFTTIMER)
83 pStatistic->ISRStat.dwIsrSTIMERInt++;
84
85 if (byIsr0 & ISR_WATCHDOG)
86 pStatistic->ISRStat.dwIsrWatchDog++;
87
88 if (byIsr1 & ISR_FETALERR)
89 pStatistic->ISRStat.dwIsrUnrecoverableError++;
90
91 if (byIsr1 & ISR_SOFTINT)
92 pStatistic->ISRStat.dwIsrSoftInterrupt++;
93
94 if (byIsr1 & ISR_MIBNEARFULL)
95 pStatistic->ISRStat.dwIsrMIBNearfull++;
96
97 if (byIsr1 & ISR_RXNOBUF)
98 pStatistic->ISRStat.dwIsrRxNoBuf++;
99
100}
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
119 u8 byRSR, u8 byNewRSR,
120 u8 byRxSts, u8 byRxRate,
121 u8 * pbyBuffer, unsigned int cbFrameLength)
122{
123
124 struct ieee80211_hdr *pHeader = (struct ieee80211_hdr *)pbyBuffer;
125
126 if (byRSR & RSR_ADDROK)
127 pStatistic->dwRsrADDROk++;
128 if (byRSR & RSR_CRCOK) {
129 pStatistic->dwRsrCRCOk++;
130 pStatistic->ullRsrOK++;
131
132 if (cbFrameLength >= ETH_ALEN) {
133
134 if (byRSR & RSR_ADDRBROAD) {
135 pStatistic->ullRxBroadcastFrames++;
136 pStatistic->ullRxBroadcastBytes +=
137 (unsigned long long) cbFrameLength;
138 }
139 else if (byRSR & RSR_ADDRMULTI) {
140 pStatistic->ullRxMulticastFrames++;
141 pStatistic->ullRxMulticastBytes +=
142 (unsigned long long) cbFrameLength;
143 }
144 else {
145 pStatistic->ullRxDirectedFrames++;
146 pStatistic->ullRxDirectedBytes +=
147 (unsigned long long) cbFrameLength;
148 }
149 }
150 }
151
152 if(byRxRate==22) {
153 pStatistic->CustomStat.ullRsr11M++;
154 if(byRSR & RSR_CRCOK) {
155 pStatistic->CustomStat.ullRsr11MCRCOk++;
156 }
157 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "11M: ALL[%d], OK[%d]:[%02x]\n",
158 (signed int) pStatistic->CustomStat.ullRsr11M,
159 (signed int) pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
160 }
161 else if(byRxRate==11) {
162 pStatistic->CustomStat.ullRsr5M++;
163 if(byRSR & RSR_CRCOK) {
164 pStatistic->CustomStat.ullRsr5MCRCOk++;
165 }
166 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 5M: ALL[%d], OK[%d]:[%02x]\n",
167 (signed int) pStatistic->CustomStat.ullRsr5M,
168 (signed int) pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
169 }
170 else if(byRxRate==4) {
171 pStatistic->CustomStat.ullRsr2M++;
172 if(byRSR & RSR_CRCOK) {
173 pStatistic->CustomStat.ullRsr2MCRCOk++;
174 }
175 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 2M: ALL[%d], OK[%d]:[%02x]\n",
176 (signed int) pStatistic->CustomStat.ullRsr2M,
177 (signed int) pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
178 }
179 else if(byRxRate==2){
180 pStatistic->CustomStat.ullRsr1M++;
181 if(byRSR & RSR_CRCOK) {
182 pStatistic->CustomStat.ullRsr1MCRCOk++;
183 }
184 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 1M: ALL[%d], OK[%d]:[%02x]\n",
185 (signed int) pStatistic->CustomStat.ullRsr1M,
186 (signed int) pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
187 }
188 else if(byRxRate==12){
189 pStatistic->CustomStat.ullRsr6M++;
190 if(byRSR & RSR_CRCOK) {
191 pStatistic->CustomStat.ullRsr6MCRCOk++;
192 }
193 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 6M: ALL[%d], OK[%d]\n",
194 (signed int) pStatistic->CustomStat.ullRsr6M,
195 (signed int) pStatistic->CustomStat.ullRsr6MCRCOk);
196 }
197 else if(byRxRate==18){
198 pStatistic->CustomStat.ullRsr9M++;
199 if(byRSR & RSR_CRCOK) {
200 pStatistic->CustomStat.ullRsr9MCRCOk++;
201 }
202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 9M: ALL[%d], OK[%d]\n",
203 (signed int) pStatistic->CustomStat.ullRsr9M,
204 (signed int) pStatistic->CustomStat.ullRsr9MCRCOk);
205 }
206 else if(byRxRate==24){
207 pStatistic->CustomStat.ullRsr12M++;
208 if(byRSR & RSR_CRCOK) {
209 pStatistic->CustomStat.ullRsr12MCRCOk++;
210 }
211 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "12M: ALL[%d], OK[%d]\n",
212 (signed int) pStatistic->CustomStat.ullRsr12M,
213 (signed int) pStatistic->CustomStat.ullRsr12MCRCOk);
214 }
215 else if(byRxRate==36){
216 pStatistic->CustomStat.ullRsr18M++;
217 if(byRSR & RSR_CRCOK) {
218 pStatistic->CustomStat.ullRsr18MCRCOk++;
219 }
220 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "18M: ALL[%d], OK[%d]\n",
221 (signed int) pStatistic->CustomStat.ullRsr18M,
222 (signed int) pStatistic->CustomStat.ullRsr18MCRCOk);
223 }
224 else if(byRxRate==48){
225 pStatistic->CustomStat.ullRsr24M++;
226 if(byRSR & RSR_CRCOK) {
227 pStatistic->CustomStat.ullRsr24MCRCOk++;
228 }
229 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "24M: ALL[%d], OK[%d]\n",
230 (signed int) pStatistic->CustomStat.ullRsr24M,
231 (signed int) pStatistic->CustomStat.ullRsr24MCRCOk);
232 }
233 else if(byRxRate==72){
234 pStatistic->CustomStat.ullRsr36M++;
235 if(byRSR & RSR_CRCOK) {
236 pStatistic->CustomStat.ullRsr36MCRCOk++;
237 }
238 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "36M: ALL[%d], OK[%d]\n",
239 (signed int) pStatistic->CustomStat.ullRsr36M,
240 (signed int) pStatistic->CustomStat.ullRsr36MCRCOk);
241 }
242 else if(byRxRate==96){
243 pStatistic->CustomStat.ullRsr48M++;
244 if(byRSR & RSR_CRCOK) {
245 pStatistic->CustomStat.ullRsr48MCRCOk++;
246 }
247 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "48M: ALL[%d], OK[%d]\n",
248 (signed int) pStatistic->CustomStat.ullRsr48M,
249 (signed int) pStatistic->CustomStat.ullRsr48MCRCOk);
250 }
251 else if(byRxRate==108){
252 pStatistic->CustomStat.ullRsr54M++;
253 if(byRSR & RSR_CRCOK) {
254 pStatistic->CustomStat.ullRsr54MCRCOk++;
255 }
256 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "54M: ALL[%d], OK[%d]\n",
257 (signed int) pStatistic->CustomStat.ullRsr54M,
258 (signed int) pStatistic->CustomStat.ullRsr54MCRCOk);
259 }
260 else {
261 DBG_PRT(MSG_LEVEL_DEBUG,
262 KERN_INFO "Unknown: Total[%d], CRCOK[%d]\n",
263 (signed int) pStatistic->dwRsrRxPacket+1,
264 (signed int)pStatistic->dwRsrCRCOk);
265 }
266
267 if (byRSR & RSR_BSSIDOK)
268 pStatistic->dwRsrBSSIDOk++;
269
270 if (byRSR & RSR_BCNSSIDOK)
271 pStatistic->dwRsrBCNSSIDOk++;
272 if (byRSR & RSR_IVLDLEN)
273 pStatistic->dwRsrLENErr++;
274 if (byRSR & RSR_IVLDTYP)
275 pStatistic->dwRsrTYPErr++;
276 if ((byRSR & (RSR_IVLDTYP | RSR_IVLDLEN)) || !(byRSR & RSR_CRCOK))
277 pStatistic->dwRsrErr++;
278
279 if (byNewRSR & NEWRSR_DECRYPTOK)
280 pStatistic->dwNewRsrDECRYPTOK++;
281 if (byNewRSR & NEWRSR_CFPIND)
282 pStatistic->dwNewRsrCFP++;
283 if (byNewRSR & NEWRSR_HWUTSF)
284 pStatistic->dwNewRsrUTSF++;
285 if (byNewRSR & NEWRSR_BCNHITAID)
286 pStatistic->dwNewRsrHITAID++;
287 if (byNewRSR & NEWRSR_BCNHITAID0)
288 pStatistic->dwNewRsrHITAID0++;
289
290
291 pStatistic->dwRsrRxPacket++;
292 pStatistic->dwRsrRxOctet += cbFrameLength;
293
294 if (IS_TYPE_DATA(pbyBuffer)) {
295 pStatistic->dwRsrRxData++;
296 } else if (IS_TYPE_MGMT(pbyBuffer)){
297 pStatistic->dwRsrRxManage++;
298 } else if (IS_TYPE_CONTROL(pbyBuffer)){
299 pStatistic->dwRsrRxControl++;
300 }
301
302 if (byRSR & RSR_ADDRBROAD)
303 pStatistic->dwRsrBroadcast++;
304 else if (byRSR & RSR_ADDRMULTI)
305 pStatistic->dwRsrMulticast++;
306 else
307 pStatistic->dwRsrDirected++;
308
309 if (WLAN_GET_FC_MOREFRAG(pHeader->frame_control))
310 pStatistic->dwRsrRxFragment++;
311
312 if (cbFrameLength < ETH_ZLEN + 4) {
313 pStatistic->dwRsrRunt++;
314 } else if (cbFrameLength == ETH_ZLEN + 4) {
315 pStatistic->dwRsrRxFrmLen64++;
316 }
317 else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
318 pStatistic->dwRsrRxFrmLen65_127++;
319 }
320 else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
321 pStatistic->dwRsrRxFrmLen128_255++;
322 }
323 else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
324 pStatistic->dwRsrRxFrmLen256_511++;
325 }
326 else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
327 pStatistic->dwRsrRxFrmLen512_1023++;
328 } else if ((1024 <= cbFrameLength) &&
329 (cbFrameLength <= ETH_FRAME_LEN + 4)) {
330 pStatistic->dwRsrRxFrmLen1024_1518++;
331 } else if (cbFrameLength > ETH_FRAME_LEN + 4) {
332 pStatistic->dwRsrLong++;
333 }
334}
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353void
354STAvUpdateTDStatCounter (
355 PSStatCounter pStatistic,
356 u8 byPktNum,
357 u8 byRate,
358 u8 byTSR
359 )
360{
361 u8 byRetyCnt;
362
363 pStatistic->dwTsrTxPacket++;
364
365 byRetyCnt = (byTSR & 0xF0) >> 4;
366 if (byRetyCnt != 0) {
367 pStatistic->dwTsrRetry++;
368 pStatistic->dwTsrTotalRetry += byRetyCnt;
369 pStatistic->dwTxFail[byRate]+= byRetyCnt;
370 pStatistic->dwTxFail[MAX_RATE] += byRetyCnt;
371
372 if ( byRetyCnt == 0x1)
373 pStatistic->dwTsrOnceRetry++;
374 else
375 pStatistic->dwTsrMoreThanOnceRetry++;
376
377 if (byRetyCnt <= 8)
378 pStatistic->dwTxRetryCount[byRetyCnt-1]++;
379
380 }
381 if ( !(byTSR & (TSR_TMO | TSR_RETRYTMO))) {
382
383 if (byRetyCnt < 2)
384 pStatistic->TxNoRetryOkCount ++;
385 else
386 pStatistic->TxRetryOkCount ++;
387
388 pStatistic->ullTsrOK++;
389 pStatistic->CustomStat.ullTsrAllOK++;
390
391 pStatistic->dwTxOk[byRate]++;
392 pStatistic->dwTxOk[MAX_RATE]++;
393
394 if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_BROAD ) {
395 pStatistic->ullTxBroadcastFrames++;
396 pStatistic->ullTxBroadcastBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
397 } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_MULTI ) {
398 pStatistic->ullTxMulticastFrames++;
399 pStatistic->ullTxMulticastBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
400 } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_UNI ) {
401 pStatistic->ullTxDirectedFrames++;
402 pStatistic->ullTxDirectedBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
403 }
404 }
405 else {
406
407 pStatistic->TxFailCount ++;
408
409 pStatistic->dwTsrErr++;
410 if (byTSR & TSR_RETRYTMO)
411 pStatistic->dwTsrRetryTimeout++;
412 if (byTSR & TSR_TMO)
413 pStatistic->dwTsrTransmitTimeout++;
414 }
415
416 if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_BROAD ) {
417 pStatistic->dwTsrBroadcast++;
418 } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_MULTI ) {
419 pStatistic->dwTsrMulticast++;
420 } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_UNI ) {
421 pStatistic->dwTsrDirected++;
422 }
423}
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439void
440STAvUpdate802_11Counter(
441 PSDot11Counters p802_11Counter,
442 PSStatCounter pStatistic,
443 u8 byRTSSuccess,
444 u8 byRTSFail,
445 u8 byACKFail,
446 u8 byFCSErr
447 )
448{
449
450 p802_11Counter->MulticastTransmittedFrameCount =
451 (unsigned long long) (pStatistic->dwTsrBroadcast +
452 pStatistic->dwTsrMulticast);
453 p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr);
454 p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry);
455 p802_11Counter->MultipleRetryCount =
456 (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry);
457
458 p802_11Counter->RTSSuccessCount += (unsigned long long) byRTSSuccess;
459 p802_11Counter->RTSFailureCount += (unsigned long long) byRTSFail;
460 p802_11Counter->ACKFailureCount += (unsigned long long) byACKFail;
461 p802_11Counter->FCSErrorCount += (unsigned long long) byFCSErr;
462
463 p802_11Counter->MulticastReceivedFrameCount =
464 (unsigned long long) (pStatistic->dwRsrBroadcast +
465 pStatistic->dwRsrMulticast);
466}
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482void STAvUpdateUSBCounter(PSUSBCounter pUsbCounter, int ntStatus)
483{
484
485
486 pUsbCounter->dwCrc++;
487
488
489}
490