staging: delete non-required instances of include <linux/init.h>
[deliverable/linux.git] / drivers / staging / vt6656 / 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 * STAvUpdateIstStatCounter - Update ISR statistic counter
29 * STAvUpdateRDStatCounter - Update Rx statistic counter
30 * STAvUpdateTDStatCounter - Update Tx statistic counter
31 * STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data
32 * STAvUpdate802_11Counter - Update 802.11 mib counter
33 *
34 * Revision History:
35 *
36 */
37
38 #include "mac.h"
39 #include "tether.h"
40 #include "mib.h"
41 #include "wctl.h"
42 #include "baseband.h"
43
44 static int msglevel =MSG_LEVEL_INFO;
45
46 /*
47 * Description: Update Isr Statistic Counter
48 *
49 * Parameters:
50 * In:
51 * pStatistic - Pointer to Statistic Counter Data Structure
52 * wisr - Interrupt status
53 * Out:
54 * none
55 *
56 * Return Value: none
57 *
58 */
59 void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, u8 byIsr0, u8 byIsr1)
60 {
61 /**********************/
62 /* ABNORMAL interrupt */
63 /**********************/
64 // not any IMR bit invoke irq
65 if (byIsr0 == 0) {
66 pStatistic->ISRStat.dwIsrUnknown++;
67 return;
68 }
69
70 if (byIsr0 & ISR_ACTX) // ISR, bit0
71 pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful
72
73 if (byIsr0 & ISR_BNTX) // ISR, bit2
74 pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful
75
76 if (byIsr0 & ISR_RXDMA0) // ISR, bit3
77 pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful
78
79 if (byIsr0 & ISR_TBTT) // ISR, bit4
80 pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful
81
82 if (byIsr0 & ISR_SOFTTIMER) // ISR, bit6
83 pStatistic->ISRStat.dwIsrSTIMERInt++;
84
85 if (byIsr0 & ISR_WATCHDOG) // ISR, bit7
86 pStatistic->ISRStat.dwIsrWatchDog++;
87
88 if (byIsr1 & ISR_FETALERR) // ISR, bit8
89 pStatistic->ISRStat.dwIsrUnrecoverableError++;
90
91 if (byIsr1 & ISR_SOFTINT) // ISR, bit9
92 pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt
93
94 if (byIsr1 & ISR_MIBNEARFULL) // ISR, bit10
95 pStatistic->ISRStat.dwIsrMIBNearfull++;
96
97 if (byIsr1 & ISR_RXNOBUF) // ISR, bit11
98 pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff
99
100 }
101
102 /*
103 * Description: Update Rx Statistic Counter
104 *
105 * Parameters:
106 * In:
107 * pStatistic - Pointer to Statistic Counter Data Structure
108 * byRSR - Rx Status
109 * byNewRSR - Rx Status
110 * pbyBuffer - Rx Buffer
111 * cbFrameLength - Rx Length
112 * Out:
113 * none
114 *
115 * Return Value: none
116 *
117 */
118 void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
119 u8 byRSR, u8 byNewRSR,
120 u8 byRxSts, u8 byRxRate,
121 u8 * pbyBuffer, unsigned int cbFrameLength)
122 {
123 /* need change */
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 /* update counters in case of successful transmission */
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) //invalid len (> 2312 byte)
273 pStatistic->dwRsrLENErr++;
274 if (byRSR & RSR_IVLDTYP) //invalid packet type
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 // increase rx packet count
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 * Description: Update 802.11 mib counter
338 *
339 * Parameters:
340 * In:
341 * p802_11Counter - Pointer to 802.11 mib counter
342 * pStatistic - Pointer to Statistic Counter Data Structure
343 * dwCounter - hardware counter for 802.11 mib
344 * Out:
345 * none
346 *
347 * Return Value: none
348 *
349 */
350 void
351 STAvUpdate802_11Counter(
352 PSDot11Counters p802_11Counter,
353 PSStatCounter pStatistic,
354 u8 byRTSSuccess,
355 u8 byRTSFail,
356 u8 byACKFail,
357 u8 byFCSErr
358 )
359 {
360 //p802_11Counter->TransmittedFragmentCount
361 p802_11Counter->MulticastTransmittedFrameCount =
362 (unsigned long long) (pStatistic->dwTsrBroadcast +
363 pStatistic->dwTsrMulticast);
364 p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr);
365 p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry);
366 p802_11Counter->MultipleRetryCount =
367 (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry);
368 //p802_11Counter->FrameDuplicateCount
369 p802_11Counter->RTSSuccessCount += (unsigned long long) byRTSSuccess;
370 p802_11Counter->RTSFailureCount += (unsigned long long) byRTSFail;
371 p802_11Counter->ACKFailureCount += (unsigned long long) byACKFail;
372 p802_11Counter->FCSErrorCount += (unsigned long long) byFCSErr;
373 //p802_11Counter->ReceivedFragmentCount
374 p802_11Counter->MulticastReceivedFrameCount =
375 (unsigned long long) (pStatistic->dwRsrBroadcast +
376 pStatistic->dwRsrMulticast);
377 }
378
379 /*
380 * Description: Clear 802.11 mib counter
381 *
382 * Parameters:
383 * In:
384 * pUsbCounter - Pointer to USB mib counter
385 * ntStatus - URB status
386 * Out:
387 * none
388 *
389 * Return Value: none
390 *
391 */
392
393 void STAvUpdateUSBCounter(PSUSBCounter pUsbCounter, int ntStatus)
394 {
395
396 // if ( ntStatus == USBD_STATUS_CRC ) {
397 pUsbCounter->dwCrc++;
398 // }
399
400 }
This page took 0.050901 seconds and 5 git commands to generate.