blob: cca56b2f243dd83c0bc78dd2b82d8a7f19537119 [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 "tmacro.h"
Forest Bond92b96792009-06-13 07:38:31 -040037#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040038#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040039#include "bssdb.h"
Forest Bond92b96792009-06-13 07:38:31 -040040#include "usbpipe.h"
Forest Bond92b96792009-06-13 07:38:31 -040041
Jesper Juhlea15b7b2012-06-27 22:01:18 +020042static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
Forest Bond92b96792009-06-13 07:38:31 -040043
Forest Bond92b96792009-06-13 07:38:31 -040044/*+
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 *
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110061 * 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
Forest Bond92b96792009-06-13 07:38:31 -040064 *
65-*/
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000066void INTvWorkItem(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -040067{
Andres More6487c492010-08-02 20:51:57 -030068 int ntStatus;
Forest Bond92b96792009-06-13 07:38:31 -040069
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110070 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
Forest Bond92b96792009-06-13 07:38:31 -040071
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110072 spin_lock_irq(&pDevice->lock);
Malcolm Priestley749627f2014-02-17 21:24:33 +000073
74 ntStatus = PIPEnsInterruptRead(pDevice);
75
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110076 spin_unlock_irq(&pDevice->lock);
77}
Forest Bond92b96792009-06-13 07:38:31 -040078
Malcolm Priestley210098a2014-02-16 19:10:18 +000079void INTnsProcessData(struct vnt_private *priv)
Forest Bond92b96792009-06-13 07:38:31 -040080{
Malcolm Priestley210098a2014-02-16 19:10:18 +000081 struct vnt_interrupt_data *int_data;
82 struct vnt_manager *mgmt = &priv->vnt_mgmt;
83 struct net_device_stats *stats = &priv->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
Malcolm Priestleyf764e002014-02-19 18:39:09 +000087 int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf;
Malcolm Priestley210098a2014-02-16 19:10:18 +000088
89 if (int_data->tsr0 & TSR_VALID) {
90 if (int_data->tsr0 & (TSR_TMO | TSR_RETRYTMO))
91 priv->wstats.discard.retries++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +000092 else
Malcolm Priestley210098a2014-02-16 19:10:18 +000093 stats->tx_packets++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +000094
Malcolm Priestley210098a2014-02-16 19:10:18 +000095 BSSvUpdateNodeTxCounter(priv,
96 int_data->tsr0,
97 int_data->pkt0);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +110098 }
Malcolm Priestley210098a2014-02-16 19:10:18 +000099
100 if (int_data->tsr1 & TSR_VALID) {
101 if (int_data->tsr1 & (TSR_TMO | TSR_RETRYTMO))
102 priv->wstats.discard.retries++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000103 else
Malcolm Priestley210098a2014-02-16 19:10:18 +0000104 stats->tx_packets++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000105
106
Malcolm Priestley210098a2014-02-16 19:10:18 +0000107 BSSvUpdateNodeTxCounter(priv,
108 int_data->tsr1,
109 int_data->pkt1);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100110 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000111
112 if (int_data->tsr2 & TSR_VALID) {
113 if (int_data->tsr2 & (TSR_TMO | TSR_RETRYTMO))
114 priv->wstats.discard.retries++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000115 else
Malcolm Priestley210098a2014-02-16 19:10:18 +0000116 stats->tx_packets++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000117
Malcolm Priestley210098a2014-02-16 19:10:18 +0000118 BSSvUpdateNodeTxCounter(priv,
119 int_data->tsr2,
120 int_data->pkt2);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100121 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000122
123 if (int_data->tsr3 & TSR_VALID) {
124 if (int_data->tsr3 & (TSR_TMO | TSR_RETRYTMO))
125 priv->wstats.discard.retries++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000126 else
Malcolm Priestley210098a2014-02-16 19:10:18 +0000127 stats->tx_packets++;
Malcolm Priestleyae27b142013-12-09 22:23:19 +0000128
Malcolm Priestley210098a2014-02-16 19:10:18 +0000129 BSSvUpdateNodeTxCounter(priv,
130 int_data->tsr3,
131 int_data->pkt3);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100132 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000133
134 if (int_data->isr0 != 0) {
135 if (int_data->isr0 & ISR_BNTX) {
136 if (priv->op_mode == NL80211_IFTYPE_AP) {
137 if (mgmt->byDTIMCount > 0) {
138 mgmt->byDTIMCount--;
139 mgmt->sNodeDBTable[0].bRxPSPoll =
Andres Moree269fc22013-02-12 20:36:29 -0500140 false;
Malcolm Priestley210098a2014-02-16 19:10:18 +0000141 } else if (mgmt->byDTIMCount == 0) {
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700142 /* check if multicast tx buffering */
Malcolm Priestley210098a2014-02-16 19:10:18 +0000143 mgmt->byDTIMCount =
144 mgmt->byDTIMPeriod-1;
145 mgmt->sNodeDBTable[0].bRxPSPoll = true;
146 if (mgmt->sNodeDBTable[0].bPSEnable)
147 bScheduleCommand((void *) priv,
Andres More0cbd8d92010-05-06 20:34:29 -0300148 WLAN_CMD_RX_PSPOLL,
149 NULL);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100150 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000151 bScheduleCommand((void *) priv,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100152 WLAN_CMD_BECON_SEND,
153 NULL);
Malcolm Priestleya0ad2772014-02-15 21:56:20 +0000154 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000155 priv->bBeaconSent = true;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100156 } else {
Malcolm Priestley210098a2014-02-16 19:10:18 +0000157 priv->bBeaconSent = false;
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100158 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000159
160 if (int_data->isr0 & ISR_TBTT) {
161 if (priv->bEnablePSMode)
162 bScheduleCommand((void *) priv,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100163 WLAN_CMD_TBTT_WAKEUP,
164 NULL);
Malcolm Priestley210098a2014-02-16 19:10:18 +0000165 if (priv->bChannelSwitch) {
166 priv->byChannelSwitchCount--;
167 if (priv->byChannelSwitchCount == 0)
168 bScheduleCommand((void *) priv,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100169 WLAN_CMD_11H_CHSW,
170 NULL);
171 }
172 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000173 priv->qwCurrTSF = le64_to_cpu(int_data->tsf);
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100174 }
Malcolm Priestley210098a2014-02-16 19:10:18 +0000175
176 if (int_data->isr1 != 0)
177 if (int_data->isr1 & ISR_GPIO3)
178 bScheduleCommand((void *) priv,
Daniel Kenji Toyamaff8041b2010-03-30 00:28:19 +1100179 WLAN_CMD_RADIO,
180 NULL);
Malcolm Priestleyf764e002014-02-19 18:39:09 +0000181
182 priv->int_buf.in_use = false;
Forest Bond92b96792009-06-13 07:38:31 -0400183
Malcolm Priestley210098a2014-02-16 19:10:18 +0000184 stats->tx_errors = priv->wstats.discard.retries;
185 stats->tx_dropped = priv->wstats.discard.retries;
Forest Bond92b96792009-06-13 07:38:31 -0400186}