blob: 512bb5d8d3e410bc3f31b322f71724599a63b2cb [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
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
Forest Bond92b96792009-06-13 07:38:31 -040035#include "int.h"
Forest Bond92b96792009-06-13 07:38:31 -040036#include "mib.h"
Forest Bond92b96792009-06-13 07:38:31 -040037#include "tmacro.h"
Forest Bond92b96792009-06-13 07:38:31 -040038#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040039#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040040#include "bssdb.h"
Forest Bond92b96792009-06-13 07:38:31 -040041#include "usbpipe.h"
Forest Bond92b96792009-06-13 07:38:31 -040042
Jesper Juhlea15b7b2012-06-27 22:01:18 +020043static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
Forest Bond92b96792009-06-13 07:38:31 -040044
Forest Bond92b96792009-06-13 07:38:31 -040045/*+
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 *
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110062 * 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
Forest Bond92b96792009-06-13 07:38:31 -040065 *
66-*/
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000067void INTvWorkItem(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -040068{
Andres More6487c492010-08-02 20:51:57 -030069 int ntStatus;
Forest Bond92b96792009-06-13 07:38:31 -040070
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110071 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
Forest Bond92b96792009-06-13 07:38:31 -040072
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110073 spin_lock_irq(&pDevice->lock);
Andres More4e9b5e22013-02-12 20:36:30 -050074 if (pDevice->fKillEventPollingThread != true)
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110075 ntStatus = PIPEnsInterruptRead(pDevice);
76 spin_unlock_irq(&pDevice->lock);
77}
Forest Bond92b96792009-06-13 07:38:31 -040078
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000079void INTnsProcessData(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -040080{
Jesper Juhl0d126982012-06-27 22:02:19 +020081 PSINTData pINTData;
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000082 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110083 struct net_device_stats *pStats = &pDevice->stats;
Forest Bond92b96792009-06-13 07:38:31 -040084
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110085 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
Forest Bond92b96792009-06-13 07:38:31 -040086
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110087 pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
88 if (pINTData->byTSR0 & TSR_VALID) {
Malcolm Priestleyae27b142013-12-09 22:23:19 +000089 if (pINTData->byTSR0 & (TSR_TMO | TSR_RETRYTMO))
90 pDevice->wstats.discard.retries++;
91 else
92 pStats->tx_packets++;
93
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110094 BSSvUpdateNodeTxCounter(pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110095 pINTData->byTSR0,
96 pINTData->byPkt0);
97 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
98 }
99 if (pINTData->byTSR1 & TSR_VALID) {
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000100 if (pINTData->byTSR1 & (TSR_TMO | TSR_RETRYTMO))
101 pDevice->wstats.discard.retries++;
102 else
103 pStats->tx_packets++;
104
105
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100106 BSSvUpdateNodeTxCounter(pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100107 pINTData->byTSR1,
108 pINTData->byPkt1);
109 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
110 }
111 if (pINTData->byTSR2 & TSR_VALID) {
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000112 if (pINTData->byTSR2 & (TSR_TMO | TSR_RETRYTMO))
113 pDevice->wstats.discard.retries++;
114 else
115 pStats->tx_packets++;
116
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100117 BSSvUpdateNodeTxCounter(pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100118 pINTData->byTSR2,
119 pINTData->byPkt2);
120 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
121 }
122 if (pINTData->byTSR3 & TSR_VALID) {
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000123 if (pINTData->byTSR3 & (TSR_TMO | TSR_RETRYTMO))
124 pDevice->wstats.discard.retries++;
125 else
126 pStats->tx_packets++;
127
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100128 BSSvUpdateNodeTxCounter(pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100129 pINTData->byTSR3,
130 pINTData->byPkt3);
131 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
132 }
133 if (pINTData->byISR0 != 0) {
134 if (pINTData->byISR0 & ISR_BNTX) {
135 if (pDevice->eOPMode == OP_MODE_AP) {
136 if (pMgmt->byDTIMCount > 0) {
137 pMgmt->byDTIMCount--;
138 pMgmt->sNodeDBTable[0].bRxPSPoll =
Andres Moree269fc22013-02-12 20:36:29 -0500139 false;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100140 } else if (pMgmt->byDTIMCount == 0) {
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700141 /* check if multicast tx buffering */
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100142 pMgmt->byDTIMCount =
143 pMgmt->byDTIMPeriod-1;
Andres More4e9b5e22013-02-12 20:36:30 -0500144 pMgmt->sNodeDBTable[0].bRxPSPoll = true;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100145 if (pMgmt->sNodeDBTable[0].bPSEnable)
Andres More0cbd8d92010-05-06 20:34:29 -0300146 bScheduleCommand((void *) pDevice,
147 WLAN_CMD_RX_PSPOLL,
148 NULL);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100149 }
Andres More0cbd8d92010-05-06 20:34:29 -0300150 bScheduleCommand((void *) pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100151 WLAN_CMD_BECON_SEND,
152 NULL);
153 } /* if (pDevice->eOPMode == OP_MODE_AP) */
Andres More4e9b5e22013-02-12 20:36:30 -0500154 pDevice->bBeaconSent = true;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100155 } else {
Andres Moree269fc22013-02-12 20:36:29 -0500156 pDevice->bBeaconSent = false;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100157 }
158 if (pINTData->byISR0 & ISR_TBTT) {
159 if (pDevice->bEnablePSMode)
Andres More0cbd8d92010-05-06 20:34:29 -0300160 bScheduleCommand((void *) pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100161 WLAN_CMD_TBTT_WAKEUP,
162 NULL);
163 if (pDevice->bChannelSwitch) {
164 pDevice->byChannelSwitchCount--;
165 if (pDevice->byChannelSwitchCount == 0)
Andres More0cbd8d92010-05-06 20:34:29 -0300166 bScheduleCommand((void *) pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100167 WLAN_CMD_11H_CHSW,
168 NULL);
169 }
170 }
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000171 pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100172 /*DBG_PRN_GRP01(("ISR0 = %02x ,
Jesper Juhlce3eaed2012-06-27 22:03:30 +0200173 LoTsf = %08x,
174 HiTsf = %08x\n",
175 pINTData->byISR0,
176 pINTData->dwLoTSF,
177 pINTData->dwHiTSF)); */
Forest Bond92b96792009-06-13 07:38:31 -0400178
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100179 STAvUpdate802_11Counter(&pDevice->s802_11Counter,
180 &pDevice->scStatistic,
181 pINTData->byRTSSuccess,
182 pINTData->byRTSFail,
183 pINTData->byACKFail,
184 pINTData->byFCSErr);
185 STAvUpdateIsrStatCounter(&pDevice->scStatistic,
186 pINTData->byISR0,
187 pINTData->byISR1);
188 }
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100189 if (pINTData->byISR1 != 0)
190 if (pINTData->byISR1 & ISR_GPIO3)
Andres More0cbd8d92010-05-06 20:34:29 -0300191 bScheduleCommand((void *) pDevice,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100192 WLAN_CMD_RADIO,
193 NULL);
194 pDevice->intBuf.uDataLen = 0;
Andres Moree269fc22013-02-12 20:36:29 -0500195 pDevice->intBuf.bInUse = false;
Forest Bond92b96792009-06-13 07:38:31 -0400196
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000197 pStats->tx_errors = pDevice->wstats.discard.retries;
198 pStats->tx_dropped = pDevice->wstats.discard.retries;
Forest Bond92b96792009-06-13 07:38:31 -0400199}