Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 "tmacro.h"
37#include "mac.h"
38#include "power.h"
39#include "bssdb.h"
40#include "usbpipe.h"
41
42static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
43
44/*+
45 *
46 * Function: InterruptPollingThread
47 *
48 * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
49 *
50 * Arguments: Device Extension
51 *
52 * Returns:
53 *
54 * Algorithm: Call USBD for input data;
55 *
56 * History: dd-mm-yyyy Author Comment
57 *
58 *
59 * Notes:
60 *
61 * USB reads are by nature 'Blocking', and when in a read, the device looks
62 * like it's in a 'stall' condition, so we deliberately time out every second
63 * if we've gotten no data
64 *
65-*/
66void INTvWorkItem(struct vnt_private *pDevice)
67{
68 int ntStatus;
69
70 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
71
72 spin_lock_irq(&pDevice->lock);
73 if (pDevice->fKillEventPollingThread != true)
74 ntStatus = PIPEnsInterruptRead(pDevice);
75 spin_unlock_irq(&pDevice->lock);
76}
77
78void INTnsProcessData(struct vnt_private *pDevice)
79{
80 PSINTData pINTData;
81 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
82 struct net_device_stats *pStats = &pDevice->stats;
83
84 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
85
86 pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
87 if (pINTData->byTSR0 & TSR_VALID) {
88 if (pINTData->byTSR0 & (TSR_TMO | TSR_RETRYTMO))
89 pDevice->wstats.discard.retries++;
90 else
91 pStats->tx_packets++;
92
93 BSSvUpdateNodeTxCounter(pDevice,
94 pINTData->byTSR0,
95 pINTData->byPkt0);
96 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
97 }
98 if (pINTData->byTSR1 & TSR_VALID) {
99 if (pINTData->byTSR1 & (TSR_TMO | TSR_RETRYTMO))
100 pDevice->wstats.discard.retries++;
101 else
102 pStats->tx_packets++;
103
104
105 BSSvUpdateNodeTxCounter(pDevice,
106 pINTData->byTSR1,
107 pINTData->byPkt1);
108 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
109 }
110 if (pINTData->byTSR2 & TSR_VALID) {
111 if (pINTData->byTSR2 & (TSR_TMO | TSR_RETRYTMO))
112 pDevice->wstats.discard.retries++;
113 else
114 pStats->tx_packets++;
115
116 BSSvUpdateNodeTxCounter(pDevice,
117 pINTData->byTSR2,
118 pINTData->byPkt2);
119 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
120 }
121 if (pINTData->byTSR3 & TSR_VALID) {
122 if (pINTData->byTSR3 & (TSR_TMO | TSR_RETRYTMO))
123 pDevice->wstats.discard.retries++;
124 else
125 pStats->tx_packets++;
126
127 BSSvUpdateNodeTxCounter(pDevice,
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 =
138 false;
139 } else if (pMgmt->byDTIMCount == 0) {
140 /* check if multicast tx buffering */
141 pMgmt->byDTIMCount =
142 pMgmt->byDTIMPeriod-1;
143 pMgmt->sNodeDBTable[0].bRxPSPoll = true;
144 if (pMgmt->sNodeDBTable[0].bPSEnable)
145 bScheduleCommand((void *) pDevice,
146 WLAN_CMD_RX_PSPOLL,
147 NULL);
148 }
149 bScheduleCommand((void *) pDevice,
150 WLAN_CMD_BECON_SEND,
151 NULL);
152 } /* if (pDevice->eOPMode == OP_MODE_AP) */
153 pDevice->bBeaconSent = true;
154 } else {
155 pDevice->bBeaconSent = false;
156 }
157 if (pINTData->byISR0 & ISR_TBTT) {
158 if (pDevice->bEnablePSMode)
159 bScheduleCommand((void *) pDevice,
160 WLAN_CMD_TBTT_WAKEUP,
161 NULL);
162 if (pDevice->bChannelSwitch) {
163 pDevice->byChannelSwitchCount--;
164 if (pDevice->byChannelSwitchCount == 0)
165 bScheduleCommand((void *) pDevice,
166 WLAN_CMD_11H_CHSW,
167 NULL);
168 }
169 }
170 pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF);
171 /*DBG_PRN_GRP01(("ISR0 = %02x ,
172 LoTsf = %08x,
173 HiTsf = %08x\n",
174 pINTData->byISR0,
175 pINTData->dwLoTSF,
176 pINTData->dwHiTSF)); */
177 }
178 if (pINTData->byISR1 != 0)
179 if (pINTData->byISR1 & ISR_GPIO3)
180 bScheduleCommand((void *) pDevice,
181 WLAN_CMD_RADIO,
182 NULL);
183 pDevice->intBuf.uDataLen = 0;
184 pDevice->intBuf.bInUse = false;
185
186 pStats->tx_errors = pDevice->wstats.discard.retries;
187 pStats->tx_dropped = pDevice->wstats.discard.retries;
188}