]>
Commit | Line | Data |
---|---|---|
5449c685 FB |
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 | ||
5449c685 | 40 | #include "upc.h" |
5449c685 | 41 | #include "mac.h" |
5449c685 | 42 | #include "tether.h" |
5449c685 | 43 | #include "mib.h" |
5449c685 | 44 | #include "wctl.h" |
5449c685 | 45 | #include "baseband.h" |
5449c685 FB |
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 | |
51b6d9c2 | 76 | memset(pStatistic, 0, sizeof(SStatCounter)); |
5449c685 FB |
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, DWORD 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 | |
256a816b | 106 | if (dwIsr & ISR_TXDMA0) // ISR, bit0 |
5449c685 FB |
107 | pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful |
108 | ||
256a816b | 109 | if (dwIsr & ISR_AC0DMA) // ISR, bit1 |
5449c685 FB |
110 | pStatistic->ISRStat.dwIsrAC0TxOK++; // AC0DMA successful |
111 | ||
256a816b | 112 | if (dwIsr & ISR_BNTX) // ISR, bit2 |
5449c685 FB |
113 | pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful |
114 | ||
256a816b | 115 | if (dwIsr & ISR_RXDMA0) // ISR, bit3 |
5449c685 FB |
116 | pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful |
117 | ||
256a816b | 118 | if (dwIsr & ISR_TBTT) // ISR, bit4 |
5449c685 FB |
119 | pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful |
120 | ||
256a816b | 121 | if (dwIsr & ISR_SOFTTIMER) // ISR, bit6 |
5449c685 FB |
122 | pStatistic->ISRStat.dwIsrSTIMERInt++; |
123 | ||
256a816b | 124 | if (dwIsr & ISR_WATCHDOG) // ISR, bit7 |
5449c685 FB |
125 | pStatistic->ISRStat.dwIsrWatchDog++; |
126 | ||
256a816b | 127 | if (dwIsr & ISR_FETALERR) // ISR, bit8 |
5449c685 FB |
128 | pStatistic->ISRStat.dwIsrUnrecoverableError++; |
129 | ||
256a816b | 130 | if (dwIsr & ISR_SOFTINT) // ISR, bit9 |
5449c685 FB |
131 | pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt |
132 | ||
256a816b | 133 | if (dwIsr & ISR_MIBNEARFULL) // ISR, bit10 |
5449c685 FB |
134 | pStatistic->ISRStat.dwIsrMIBNearfull++; |
135 | ||
256a816b | 136 | if (dwIsr & ISR_RXNOBUF) // ISR, bit11 |
5449c685 FB |
137 | pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff |
138 | ||
256a816b | 139 | if (dwIsr & ISR_RXDMA1) // ISR, bit12 |
5449c685 FB |
140 | pStatistic->ISRStat.dwIsrRx1OK++; // Rx1 successful |
141 | ||
256a816b | 142 | // if (dwIsr & ISR_ATIMTX) // ISR, bit13 |
5449c685 FB |
143 | // pStatistic->ISRStat.dwIsrATIMTxOK++; // ATIMTX successful |
144 | ||
256a816b | 145 | // if (dwIsr & ISR_SYNCTX) // ISR, bit14 |
5449c685 FB |
146 | // pStatistic->ISRStat.dwIsrSYNCTxOK++; // SYNCTX successful |
147 | ||
256a816b | 148 | // if (dwIsr & ISR_CFPEND) // ISR, bit18 |
5449c685 FB |
149 | // pStatistic->ISRStat.dwIsrCFPEnd++; |
150 | ||
256a816b | 151 | // if (dwIsr & ISR_ATIMEND) // ISR, bit19 |
5449c685 FB |
152 | // pStatistic->ISRStat.dwIsrATIMEnd++; |
153 | ||
256a816b | 154 | // if (dwIsr & ISR_SYNCFLUSHOK) // ISR, bit20 |
5449c685 FB |
155 | // pStatistic->ISRStat.dwIsrSYNCFlushOK++; |
156 | ||
256a816b | 157 | if (dwIsr & ISR_SOFTTIMER1) // ISR, bit21 |
5449c685 FB |
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 | BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, | |
181 | PBYTE pbyBuffer, UINT cbFrameLength) | |
182 | { | |
183 | //need change | |
184 | PS802_11Header pHeader = (PS802_11Header)pbyBuffer; | |
185 | ||
256a816b | 186 | if (byRSR & RSR_ADDROK) |
5449c685 | 187 | pStatistic->dwRsrADDROk++; |
256a816b | 188 | if (byRSR & RSR_CRCOK) { |
5449c685 FB |
189 | pStatistic->dwRsrCRCOk++; |
190 | ||
191 | pStatistic->ullRsrOK++; | |
192 | ||
193 | if (cbFrameLength >= U_ETHER_ADDR_LEN) { | |
194 | // update counters in case that successful transmit | |
256a816b | 195 | if (byRSR & RSR_ADDRBROAD) { |
5449c685 FB |
196 | pStatistic->ullRxBroadcastFrames++; |
197 | pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength; | |
198 | } | |
256a816b | 199 | else if (byRSR & RSR_ADDRMULTI) { |
5449c685 FB |
200 | pStatistic->ullRxMulticastFrames++; |
201 | pStatistic->ullRxMulticastBytes += (ULONGLONG)cbFrameLength; | |
202 | } | |
203 | else { | |
204 | pStatistic->ullRxDirectedFrames++; | |
205 | pStatistic->ullRxDirectedBytes += (ULONGLONG)cbFrameLength; | |
206 | } | |
207 | } | |
208 | } | |
209 | ||
210 | if(byRxRate==22) { | |
211 | pStatistic->CustomStat.ullRsr11M++; | |
256a816b | 212 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
213 | pStatistic->CustomStat.ullRsr11MCRCOk++; |
214 | } | |
7e809a9b | 215 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr11M, (INT)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR); |
5449c685 FB |
216 | } |
217 | else if(byRxRate==11) { | |
218 | pStatistic->CustomStat.ullRsr5M++; | |
256a816b | 219 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
220 | pStatistic->CustomStat.ullRsr5MCRCOk++; |
221 | } | |
7e809a9b | 222 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr5M, (INT)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR); |
5449c685 FB |
223 | } |
224 | else if(byRxRate==4) { | |
225 | pStatistic->CustomStat.ullRsr2M++; | |
256a816b | 226 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
227 | pStatistic->CustomStat.ullRsr2MCRCOk++; |
228 | } | |
7e809a9b | 229 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr2M, (INT)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR); |
5449c685 FB |
230 | } |
231 | else if(byRxRate==2){ | |
232 | pStatistic->CustomStat.ullRsr1M++; | |
256a816b | 233 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
234 | pStatistic->CustomStat.ullRsr1MCRCOk++; |
235 | } | |
7e809a9b | 236 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr1M, (INT)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR); |
5449c685 FB |
237 | } |
238 | else if(byRxRate==12){ | |
239 | pStatistic->CustomStat.ullRsr6M++; | |
256a816b | 240 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
241 | pStatistic->CustomStat.ullRsr6MCRCOk++; |
242 | } | |
7e809a9b | 243 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr6M, (INT)pStatistic->CustomStat.ullRsr6MCRCOk); |
5449c685 FB |
244 | } |
245 | else if(byRxRate==18){ | |
246 | pStatistic->CustomStat.ullRsr9M++; | |
256a816b | 247 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
248 | pStatistic->CustomStat.ullRsr9MCRCOk++; |
249 | } | |
7e809a9b | 250 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr9M, (INT)pStatistic->CustomStat.ullRsr9MCRCOk); |
5449c685 FB |
251 | } |
252 | else if(byRxRate==24){ | |
253 | pStatistic->CustomStat.ullRsr12M++; | |
256a816b | 254 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
255 | pStatistic->CustomStat.ullRsr12MCRCOk++; |
256 | } | |
7e809a9b | 257 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr12M, (INT)pStatistic->CustomStat.ullRsr12MCRCOk); |
5449c685 FB |
258 | } |
259 | else if(byRxRate==36){ | |
260 | pStatistic->CustomStat.ullRsr18M++; | |
256a816b | 261 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
262 | pStatistic->CustomStat.ullRsr18MCRCOk++; |
263 | } | |
7e809a9b | 264 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr18M, (INT)pStatistic->CustomStat.ullRsr18MCRCOk); |
5449c685 FB |
265 | } |
266 | else if(byRxRate==48){ | |
267 | pStatistic->CustomStat.ullRsr24M++; | |
256a816b | 268 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
269 | pStatistic->CustomStat.ullRsr24MCRCOk++; |
270 | } | |
7e809a9b | 271 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr24M, (INT)pStatistic->CustomStat.ullRsr24MCRCOk); |
5449c685 FB |
272 | } |
273 | else if(byRxRate==72){ | |
274 | pStatistic->CustomStat.ullRsr36M++; | |
256a816b | 275 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
276 | pStatistic->CustomStat.ullRsr36MCRCOk++; |
277 | } | |
7e809a9b | 278 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr36M, (INT)pStatistic->CustomStat.ullRsr36MCRCOk); |
5449c685 FB |
279 | } |
280 | else if(byRxRate==96){ | |
281 | pStatistic->CustomStat.ullRsr48M++; | |
256a816b | 282 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
283 | pStatistic->CustomStat.ullRsr48MCRCOk++; |
284 | } | |
7e809a9b | 285 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr48M, (INT)pStatistic->CustomStat.ullRsr48MCRCOk); |
5449c685 FB |
286 | } |
287 | else if(byRxRate==108){ | |
288 | pStatistic->CustomStat.ullRsr54M++; | |
256a816b | 289 | if(byRSR & RSR_CRCOK) { |
5449c685 FB |
290 | pStatistic->CustomStat.ullRsr54MCRCOk++; |
291 | } | |
7e809a9b | 292 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk); |
5449c685 FB |
293 | } |
294 | else { | |
7e809a9b | 295 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (INT)pStatistic->dwRsrRxPacket+1, (INT)pStatistic->dwRsrCRCOk); |
5449c685 FB |
296 | } |
297 | ||
256a816b | 298 | if (byRSR & RSR_BSSIDOK) |
5449c685 FB |
299 | pStatistic->dwRsrBSSIDOk++; |
300 | ||
256a816b | 301 | if (byRSR & RSR_BCNSSIDOK) |
5449c685 | 302 | pStatistic->dwRsrBCNSSIDOk++; |
256a816b | 303 | if (byRSR & RSR_IVLDLEN) //invalid len (> 2312 byte) |
5449c685 | 304 | pStatistic->dwRsrLENErr++; |
256a816b | 305 | if (byRSR & RSR_IVLDTYP) //invalid packet type |
5449c685 | 306 | pStatistic->dwRsrTYPErr++; |
256a816b | 307 | if (byRSR & (RSR_IVLDTYP | RSR_IVLDLEN)) |
5449c685 FB |
308 | pStatistic->dwRsrErr++; |
309 | ||
256a816b | 310 | if (byNewRSR & NEWRSR_DECRYPTOK) |
5449c685 | 311 | pStatistic->dwNewRsrDECRYPTOK++; |
256a816b | 312 | if (byNewRSR & NEWRSR_CFPIND) |
5449c685 | 313 | pStatistic->dwNewRsrCFP++; |
256a816b | 314 | if (byNewRSR & NEWRSR_HWUTSF) |
5449c685 | 315 | pStatistic->dwNewRsrUTSF++; |
256a816b | 316 | if (byNewRSR & NEWRSR_BCNHITAID) |
5449c685 | 317 | pStatistic->dwNewRsrHITAID++; |
256a816b | 318 | if (byNewRSR & NEWRSR_BCNHITAID0) |
5449c685 FB |
319 | pStatistic->dwNewRsrHITAID0++; |
320 | ||
321 | // increase rx packet count | |
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 | ||
256a816b | 334 | if (byRSR & RSR_ADDRBROAD) |
5449c685 | 335 | pStatistic->dwRsrBroadcast++; |
256a816b | 336 | else if (byRSR & RSR_ADDRMULTI) |
5449c685 FB |
337 | pStatistic->dwRsrMulticast++; |
338 | else | |
339 | pStatistic->dwRsrDirected++; | |
340 | ||
341 | if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl)) | |
342 | pStatistic->dwRsrRxFragment++; | |
343 | ||
344 | if (cbFrameLength < MIN_PACKET_LEN + 4) { | |
345 | pStatistic->dwRsrRunt++; | |
346 | } | |
347 | else if (cbFrameLength == MIN_PACKET_LEN + 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 <= MAX_PACKET_LEN + 4)) { | |
363 | pStatistic->dwRsrRxFrmLen1024_1518++; | |
364 | } else if (cbFrameLength > MAX_PACKET_LEN + 4) { | |
365 | pStatistic->dwRsrLong++; | |
366 | } | |
367 | ||
368 | } | |
369 | ||
370 | ||
371 | ||
372 | /* | |
373 | * Description: Update Rx Statistic Counter and copy Rx buffer | |
374 | * | |
375 | * Parameters: | |
376 | * In: | |
377 | * pStatistic - Pointer to Statistic Counter Data Structure | |
378 | * byRSR - Rx Status | |
379 | * byNewRSR - Rx Status | |
380 | * pbyBuffer - Rx Buffer | |
381 | * cbFrameLength - Rx Length | |
382 | * Out: | |
383 | * none | |
384 | * | |
385 | * Return Value: none | |
386 | * | |
387 | */ | |
388 | ||
389 | void | |
390 | STAvUpdateRDStatCounterEx ( | |
391 | PSStatCounter pStatistic, | |
392 | BYTE byRSR, | |
393 | BYTE byNewRSR, | |
394 | BYTE byRxRate, | |
395 | PBYTE pbyBuffer, | |
396 | UINT cbFrameLength | |
397 | ) | |
398 | { | |
399 | STAvUpdateRDStatCounter( | |
400 | pStatistic, | |
401 | byRSR, | |
402 | byNewRSR, | |
403 | byRxRate, | |
404 | pbyBuffer, | |
405 | cbFrameLength | |
406 | ); | |
407 | ||
408 | // rx length | |
409 | pStatistic->dwCntRxFrmLength = cbFrameLength; | |
410 | // rx pattern, we just see 10 bytes for sample | |
51b6d9c2 | 411 | memcpy(pStatistic->abyCntRxPattern, (PBYTE)pbyBuffer, 10); |
5449c685 FB |
412 | } |
413 | ||
414 | ||
415 | /* | |
416 | * Description: Update Tx Statistic Counter | |
417 | * | |
418 | * Parameters: | |
419 | * In: | |
420 | * pStatistic - Pointer to Statistic Counter Data Structure | |
421 | * byTSR0 - Tx Status | |
422 | * byTSR1 - Tx Status | |
423 | * pbyBuffer - Tx Buffer | |
424 | * cbFrameLength - Tx Length | |
425 | * uIdx - Index of Tx DMA | |
426 | * Out: | |
427 | * none | |
428 | * | |
429 | * Return Value: none | |
430 | * | |
431 | */ | |
432 | void | |
433 | STAvUpdateTDStatCounter ( | |
434 | PSStatCounter pStatistic, | |
435 | BYTE byTSR0, | |
436 | BYTE byTSR1, | |
437 | PBYTE pbyBuffer, | |
438 | UINT cbFrameLength, | |
439 | UINT uIdx | |
440 | ) | |
441 | { | |
442 | PWLAN_80211HDR_A4 pHeader; | |
443 | PBYTE pbyDestAddr; | |
444 | BYTE 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 | // increase tx packet count | |
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 | // update counters in case that successful transmit | |
474 | if (IS_BROADCAST_ADDRESS(pbyDestAddr)) { | |
475 | pStatistic->ullTxBroadcastFrames[uIdx]++; | |
476 | pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength; | |
477 | } | |
478 | else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) { | |
479 | pStatistic->ullTxMulticastFrames[uIdx]++; | |
480 | pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength; | |
481 | } | |
482 | else { | |
483 | pStatistic->ullTxDirectedFrames[uIdx]++; | |
484 | pStatistic->ullTxDirectedBytes[uIdx] += (ULONGLONG)cbFrameLength; | |
485 | } | |
486 | } | |
487 | else { | |
256a816b | 488 | if (byTSR1 & TSR1_TERR) |
5449c685 | 489 | pStatistic->dwTsrErr[uIdx]++; |
256a816b | 490 | if (byTSR1 & TSR1_RETRYTMO) |
5449c685 | 491 | pStatistic->dwTsrRetryTimeout[uIdx]++; |
256a816b | 492 | if (byTSR1 & TSR1_TMO) |
5449c685 | 493 | pStatistic->dwTsrTransmitTimeout[uIdx]++; |
256a816b | 494 | if (byTSR1 & ACK_DATA) |
5449c685 FB |
495 | pStatistic->dwTsrACKData[uIdx]++; |
496 | } | |
497 | ||
498 | if (IS_BROADCAST_ADDRESS(pbyDestAddr)) | |
499 | pStatistic->dwTsrBroadcast[uIdx]++; | |
500 | else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) | |
501 | pStatistic->dwTsrMulticast[uIdx]++; | |
502 | else | |
503 | pStatistic->dwTsrDirected[uIdx]++; | |
504 | ||
505 | } | |
506 | ||
507 | ||
508 | /* | |
509 | * Description: Update Tx Statistic Counter and copy Tx buffer | |
510 | * | |
511 | * Parameters: | |
512 | * In: | |
513 | * pStatistic - Pointer to Statistic Counter Data Structure | |
514 | * pbyBuffer - Tx Buffer | |
515 | * cbFrameLength - Tx Length | |
516 | * Out: | |
517 | * none | |
518 | * | |
519 | * Return Value: none | |
520 | * | |
521 | */ | |
522 | void | |
523 | STAvUpdateTDStatCounterEx ( | |
524 | PSStatCounter pStatistic, | |
525 | PBYTE pbyBuffer, | |
526 | DWORD cbFrameLength | |
527 | ) | |
528 | { | |
529 | UINT uPktLength; | |
530 | ||
531 | uPktLength = (UINT)cbFrameLength; | |
532 | ||
533 | // tx length | |
534 | pStatistic->dwCntTxBufLength = uPktLength; | |
535 | // tx pattern, we just see 16 bytes for sample | |
51b6d9c2 | 536 | memcpy(pStatistic->abyCntTxPattern, pbyBuffer, 16); |
5449c685 FB |
537 | } |
538 | ||
539 | ||
540 | /* | |
541 | * Description: Update 802.11 mib counter | |
542 | * | |
543 | * Parameters: | |
544 | * In: | |
545 | * p802_11Counter - Pointer to 802.11 mib counter | |
546 | * pStatistic - Pointer to Statistic Counter Data Structure | |
547 | * dwCounter - hardware counter for 802.11 mib | |
548 | * Out: | |
549 | * none | |
550 | * | |
551 | * Return Value: none | |
552 | * | |
553 | */ | |
554 | void | |
555 | STAvUpdate802_11Counter( | |
556 | PSDot11Counters p802_11Counter, | |
557 | PSStatCounter pStatistic, | |
558 | DWORD dwCounter | |
559 | ) | |
560 | { | |
561 | //p802_11Counter->TransmittedFragmentCount | |
562 | p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] + | |
563 | pStatistic->dwTsrBroadcast[TYPE_TXDMA0] + | |
564 | pStatistic->dwTsrMulticast[TYPE_AC0DMA] + | |
565 | pStatistic->dwTsrMulticast[TYPE_TXDMA0]); | |
566 | p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]); | |
567 | p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]); | |
568 | p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] + | |
569 | pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]); | |
570 | //p802_11Counter->FrameDuplicateCount | |
571 | p802_11Counter->RTSSuccessCount += (ULONGLONG) (dwCounter & 0x000000ff); | |
572 | p802_11Counter->RTSFailureCount += (ULONGLONG) ((dwCounter & 0x0000ff00) >> 8); | |
573 | p802_11Counter->ACKFailureCount += (ULONGLONG) ((dwCounter & 0x00ff0000) >> 16); | |
574 | p802_11Counter->FCSErrorCount += (ULONGLONG) ((dwCounter & 0xff000000) >> 24); | |
575 | //p802_11Counter->ReceivedFragmentCount | |
576 | p802_11Counter->MulticastReceivedFrameCount = (ULONGLONG) (pStatistic->dwRsrBroadcast + | |
577 | pStatistic->dwRsrMulticast); | |
578 | } | |
579 | ||
580 | /* | |
581 | * Description: Clear 802.11 mib counter | |
582 | * | |
583 | * Parameters: | |
584 | * In: | |
585 | * p802_11Counter - Pointer to 802.11 mib counter | |
586 | * Out: | |
587 | * none | |
588 | * | |
589 | * Return Value: none | |
590 | * | |
591 | */ | |
592 | void | |
593 | STAvClear802_11Counter(PSDot11Counters p802_11Counter) | |
594 | { | |
595 | // set memory to zero | |
51b6d9c2 | 596 | memset(p802_11Counter, 0, sizeof(SDot11Counters)); |
5449c685 | 597 | } |