]> Pileus Git - ~andy/linux/blob - drivers/staging/vt6656/int.c
staging: vt6656: Remove STAvUpdateTDStatCounter and apply directly to stats
[~andy/linux] / drivers / staging / vt6656 / int.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  *
20  * File: int.c
21  *
22  * Purpose: Handle USB interrupt endpoint
23  *
24  * Author: Jerry Chen
25  *
26  * Date: Apr. 2, 2004
27  *
28  * Functions:
29  *
30  * Revision History:
31  *      04-02-2004 Jerry Chen:  Initial release
32  *
33  */
34
35 #include "int.h"
36 #include "mib.h"
37 #include "tmacro.h"
38 #include "mac.h"
39 #include "power.h"
40 #include "bssdb.h"
41 #include "usbpipe.h"
42
43 static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
44
45 /*+
46  *
47  *  Function:   InterruptPollingThread
48  *
49  *  Synopsis:   Thread running at IRQL PASSIVE_LEVEL.
50  *
51  *  Arguments: Device Extension
52  *
53  *  Returns:
54  *
55  *  Algorithm:  Call USBD for input data;
56  *
57  *  History:    dd-mm-yyyy   Author    Comment
58  *
59  *
60  *  Notes:
61  *
62  *  USB reads are by nature 'Blocking', and when in a read, the device looks
63  *  like it's in a 'stall' condition, so we deliberately time out every second
64  *  if we've gotten no data
65  *
66 -*/
67 void INTvWorkItem(struct vnt_private *pDevice)
68 {
69         int ntStatus;
70
71         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
72
73         spin_lock_irq(&pDevice->lock);
74         if (pDevice->fKillEventPollingThread != true)
75                 ntStatus = PIPEnsInterruptRead(pDevice);
76         spin_unlock_irq(&pDevice->lock);
77 }
78
79 void INTnsProcessData(struct vnt_private *pDevice)
80 {
81         PSINTData pINTData;
82         struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
83         struct net_device_stats *pStats = &pDevice->stats;
84
85         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
86
87         pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
88         if (pINTData->byTSR0 & TSR_VALID) {
89                 if (pINTData->byTSR0 & (TSR_TMO | TSR_RETRYTMO))
90                         pDevice->wstats.discard.retries++;
91                 else
92                         pStats->tx_packets++;
93
94                 BSSvUpdateNodeTxCounter(pDevice,
95                                         &(pDevice->scStatistic),
96                                         pINTData->byTSR0,
97                                         pINTData->byPkt0);
98                 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
99         }
100         if (pINTData->byTSR1 & TSR_VALID) {
101                 if (pINTData->byTSR1 & (TSR_TMO | TSR_RETRYTMO))
102                         pDevice->wstats.discard.retries++;
103                 else
104                         pStats->tx_packets++;
105
106
107                 BSSvUpdateNodeTxCounter(pDevice,
108                                         &(pDevice->scStatistic),
109                                         pINTData->byTSR1,
110                                         pINTData->byPkt1);
111                 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
112         }
113         if (pINTData->byTSR2 & TSR_VALID) {
114                 if (pINTData->byTSR2 & (TSR_TMO | TSR_RETRYTMO))
115                         pDevice->wstats.discard.retries++;
116                 else
117                         pStats->tx_packets++;
118
119                 BSSvUpdateNodeTxCounter(pDevice,
120                                         &(pDevice->scStatistic),
121                                         pINTData->byTSR2,
122                                         pINTData->byPkt2);
123                 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
124         }
125         if (pINTData->byTSR3 & TSR_VALID) {
126                 if (pINTData->byTSR3 & (TSR_TMO | TSR_RETRYTMO))
127                         pDevice->wstats.discard.retries++;
128                 else
129                         pStats->tx_packets++;
130
131                 BSSvUpdateNodeTxCounter(pDevice,
132                                         &(pDevice->scStatistic),
133                                         pINTData->byTSR3,
134                                         pINTData->byPkt3);
135                 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
136         }
137         if (pINTData->byISR0 != 0) {
138                 if (pINTData->byISR0 & ISR_BNTX) {
139                         if (pDevice->eOPMode == OP_MODE_AP) {
140                                 if (pMgmt->byDTIMCount > 0) {
141                                         pMgmt->byDTIMCount--;
142                                         pMgmt->sNodeDBTable[0].bRxPSPoll =
143                                                 false;
144                                 } else if (pMgmt->byDTIMCount == 0) {
145                                         /* check if multicast tx buffering */
146                                         pMgmt->byDTIMCount =
147                                                 pMgmt->byDTIMPeriod-1;
148                                         pMgmt->sNodeDBTable[0].bRxPSPoll = true;
149                                         if (pMgmt->sNodeDBTable[0].bPSEnable)
150                                                 bScheduleCommand((void *) pDevice,
151                                                                  WLAN_CMD_RX_PSPOLL,
152                                                                  NULL);
153                                 }
154                                 bScheduleCommand((void *) pDevice,
155                                                 WLAN_CMD_BECON_SEND,
156                                                 NULL);
157                         } /* if (pDevice->eOPMode == OP_MODE_AP) */
158                 pDevice->bBeaconSent = true;
159                 } else {
160                         pDevice->bBeaconSent = false;
161                 }
162                 if (pINTData->byISR0 & ISR_TBTT) {
163                         if (pDevice->bEnablePSMode)
164                                 bScheduleCommand((void *) pDevice,
165                                                 WLAN_CMD_TBTT_WAKEUP,
166                                                 NULL);
167                         if (pDevice->bChannelSwitch) {
168                                 pDevice->byChannelSwitchCount--;
169                                 if (pDevice->byChannelSwitchCount == 0)
170                                         bScheduleCommand((void *) pDevice,
171                                                         WLAN_CMD_11H_CHSW,
172                                                         NULL);
173                         }
174                 }
175                 pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF);
176                 /*DBG_PRN_GRP01(("ISR0 = %02x ,
177                   LoTsf =  %08x,
178                   HiTsf =  %08x\n",
179                   pINTData->byISR0,
180                   pINTData->dwLoTSF,
181                   pINTData->dwHiTSF)); */
182
183                 STAvUpdate802_11Counter(&pDevice->s802_11Counter,
184                                         &pDevice->scStatistic,
185                                         pINTData->byRTSSuccess,
186                                         pINTData->byRTSFail,
187                                         pINTData->byACKFail,
188                                         pINTData->byFCSErr);
189                 STAvUpdateIsrStatCounter(&pDevice->scStatistic,
190                                         pINTData->byISR0,
191                                         pINTData->byISR1);
192         }
193         if (pINTData->byISR1 != 0)
194                 if (pINTData->byISR1 & ISR_GPIO3)
195                         bScheduleCommand((void *) pDevice,
196                                         WLAN_CMD_RADIO,
197                                         NULL);
198         pDevice->intBuf.uDataLen = 0;
199         pDevice->intBuf.bInUse = false;
200
201         pStats->tx_errors = pDevice->wstats.discard.retries;
202         pStats->tx_dropped = pDevice->wstats.discard.retries;
203 }