Merge 3.9-rc5 into staging-next
[deliverable/linux.git] / drivers / staging / vt6656 / int.c
CommitLineData
92b96797
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 *
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
92b96797 35#include "int.h"
92b96797 36#include "mib.h"
92b96797 37#include "tmacro.h"
92b96797 38#include "mac.h"
92b96797 39#include "power.h"
92b96797 40#include "bssdb.h"
92b96797 41#include "usbpipe.h"
92b96797 42
ea15b7b2 43static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
92b96797 44
92b96797
FB
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 *
ff8041bb
DKT
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
92b96797
FB
65 *
66-*/
fe5d00eb 67void INTvWorkItem(struct vnt_private *pDevice)
92b96797 68{
6487c49e 69 int ntStatus;
92b96797 70
ff8041bb 71 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
92b96797 72
ff8041bb 73 spin_lock_irq(&pDevice->lock);
4e9b5e2b 74 if (pDevice->fKillEventPollingThread != true)
ff8041bb
DKT
75 ntStatus = PIPEnsInterruptRead(pDevice);
76 spin_unlock_irq(&pDevice->lock);
77}
92b96797 78
fe5d00eb 79void INTnsProcessData(struct vnt_private *pDevice)
92b96797 80{
0d126986 81 PSINTData pINTData;
fe5d00eb 82 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
ff8041bb
DKT
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 STAvUpdateTDStatCounter(&(pDevice->scStatistic),
b902fbfe
AM
90 (u8)(pINTData->byPkt0 & 0x0F),
91 (u8)(pINTData->byPkt0>>4),
ff8041bb
DKT
92 pINTData->byTSR0);
93 BSSvUpdateNodeTxCounter(pDevice,
94 &(pDevice->scStatistic),
95 pINTData->byTSR0,
96 pINTData->byPkt0);
97 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
98 }
99 if (pINTData->byTSR1 & TSR_VALID) {
100 STAvUpdateTDStatCounter(&(pDevice->scStatistic),
b902fbfe
AM
101 (u8)(pINTData->byPkt1 & 0x0F),
102 (u8)(pINTData->byPkt1>>4),
ff8041bb
DKT
103 pINTData->byTSR1);
104 BSSvUpdateNodeTxCounter(pDevice,
105 &(pDevice->scStatistic),
106 pINTData->byTSR1,
107 pINTData->byPkt1);
108 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
109 }
110 if (pINTData->byTSR2 & TSR_VALID) {
111 STAvUpdateTDStatCounter(&(pDevice->scStatistic),
b902fbfe
AM
112 (u8)(pINTData->byPkt2 & 0x0F),
113 (u8)(pINTData->byPkt2>>4),
ff8041bb
DKT
114 pINTData->byTSR2);
115 BSSvUpdateNodeTxCounter(pDevice,
116 &(pDevice->scStatistic),
117 pINTData->byTSR2,
118 pINTData->byPkt2);
119 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
120 }
121 if (pINTData->byTSR3 & TSR_VALID) {
122 STAvUpdateTDStatCounter(&(pDevice->scStatistic),
b902fbfe
AM
123 (u8)(pINTData->byPkt3 & 0x0F),
124 (u8)(pINTData->byPkt3>>4),
ff8041bb
DKT
125 pINTData->byTSR3);
126 BSSvUpdateNodeTxCounter(pDevice,
127 &(pDevice->scStatistic),
128 pINTData->byTSR3,
129 pINTData->byPkt3);
130 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
131 }
132 if (pINTData->byISR0 != 0) {
133 if (pINTData->byISR0 & ISR_BNTX) {
134 if (pDevice->eOPMode == OP_MODE_AP) {
135 if (pMgmt->byDTIMCount > 0) {
136 pMgmt->byDTIMCount--;
137 pMgmt->sNodeDBTable[0].bRxPSPoll =
e269fc2d 138 false;
ff8041bb 139 } else if (pMgmt->byDTIMCount == 0) {
a0a1f61a 140 /* check if multicast tx buffering */
ff8041bb
DKT
141 pMgmt->byDTIMCount =
142 pMgmt->byDTIMPeriod-1;
4e9b5e2b 143 pMgmt->sNodeDBTable[0].bRxPSPoll = true;
ff8041bb 144 if (pMgmt->sNodeDBTable[0].bPSEnable)
0cbd8d98
AM
145 bScheduleCommand((void *) pDevice,
146 WLAN_CMD_RX_PSPOLL,
147 NULL);
ff8041bb 148 }
0cbd8d98 149 bScheduleCommand((void *) pDevice,
ff8041bb
DKT
150 WLAN_CMD_BECON_SEND,
151 NULL);
152 } /* if (pDevice->eOPMode == OP_MODE_AP) */
4e9b5e2b 153 pDevice->bBeaconSent = true;
ff8041bb 154 } else {
e269fc2d 155 pDevice->bBeaconSent = false;
ff8041bb
DKT
156 }
157 if (pINTData->byISR0 & ISR_TBTT) {
158 if (pDevice->bEnablePSMode)
0cbd8d98 159 bScheduleCommand((void *) pDevice,
ff8041bb
DKT
160 WLAN_CMD_TBTT_WAKEUP,
161 NULL);
162 if (pDevice->bChannelSwitch) {
163 pDevice->byChannelSwitchCount--;
164 if (pDevice->byChannelSwitchCount == 0)
0cbd8d98 165 bScheduleCommand((void *) pDevice,
ff8041bb
DKT
166 WLAN_CMD_11H_CHSW,
167 NULL);
168 }
169 }
7c65fa2a 170 pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF);
ff8041bb 171 /*DBG_PRN_GRP01(("ISR0 = %02x ,
ce3eaedf
JJ
172 LoTsf = %08x,
173 HiTsf = %08x\n",
174 pINTData->byISR0,
175 pINTData->dwLoTSF,
176 pINTData->dwHiTSF)); */
ff8041bb
DKT
177
178 STAvUpdate802_11Counter(&pDevice->s802_11Counter,
179 &pDevice->scStatistic,
180 pINTData->byRTSSuccess,
181 pINTData->byRTSFail,
182 pINTData->byACKFail,
183 pINTData->byFCSErr);
184 STAvUpdateIsrStatCounter(&pDevice->scStatistic,
185 pINTData->byISR0,
186 pINTData->byISR1);
187 }
ff8041bb
DKT
188 if (pINTData->byISR1 != 0)
189 if (pINTData->byISR1 & ISR_GPIO3)
0cbd8d98 190 bScheduleCommand((void *) pDevice,
ff8041bb
DKT
191 WLAN_CMD_RADIO,
192 NULL);
193 pDevice->intBuf.uDataLen = 0;
e269fc2d 194 pDevice->intBuf.bInUse = false;
ff8041bb
DKT
195
196 pStats->tx_packets = pDevice->scStatistic.ullTsrOK;
197 pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes +
ce3eaedf
JJ
198 pDevice->scStatistic.ullTxMulticastBytes +
199 pDevice->scStatistic.ullTxBroadcastBytes;
ff8041bb
DKT
200 pStats->tx_errors = pDevice->scStatistic.dwTsrErr;
201 pStats->tx_dropped = pDevice->scStatistic.dwTsrErr;
92b96797 202}
This page took 0.355624 seconds and 5 git commands to generate.