Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 35 | #include "int.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 36 | #include "mib.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 37 | #include "tmacro.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 38 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 39 | #include "power.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 40 | #include "bssdb.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 41 | #include "usbpipe.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 42 | |
Jesper Juhl | ea15b7b | 2012-06-27 22:01:18 +0200 | [diff] [blame] | 43 | static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | * |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 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 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 65 | * |
| 66 | -*/ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 67 | void INTvWorkItem(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 69 | int ntStatus; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 70 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 71 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 72 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 73 | spin_lock_irq(&pDevice->lock); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 74 | if (pDevice->fKillEventPollingThread != true) |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 75 | ntStatus = PIPEnsInterruptRead(pDevice); |
| 76 | spin_unlock_irq(&pDevice->lock); |
| 77 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 78 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 79 | void INTnsProcessData(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 80 | { |
Jesper Juhl | 0d12698 | 2012-06-27 22:02:19 +0200 | [diff] [blame] | 81 | PSINTData pINTData; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 82 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 83 | struct net_device_stats *pStats = &pDevice->stats; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 84 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 85 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 86 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 87 | pINTData = (PSINTData) pDevice->intBuf.pDataBuf; |
| 88 | if (pINTData->byTSR0 & TSR_VALID) { |
Malcolm Priestley | ae27b14 | 2013-12-09 22:23:19 +0000 | [diff] [blame] | 89 | if (pINTData->byTSR0 & (TSR_TMO | TSR_RETRYTMO)) |
| 90 | pDevice->wstats.discard.retries++; |
| 91 | else |
| 92 | pStats->tx_packets++; |
| 93 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 94 | BSSvUpdateNodeTxCounter(pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 95 | pINTData->byTSR0, |
| 96 | pINTData->byPkt0); |
| 97 | /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/ |
| 98 | } |
| 99 | if (pINTData->byTSR1 & TSR_VALID) { |
Malcolm Priestley | ae27b14 | 2013-12-09 22:23:19 +0000 | [diff] [blame] | 100 | if (pINTData->byTSR1 & (TSR_TMO | TSR_RETRYTMO)) |
| 101 | pDevice->wstats.discard.retries++; |
| 102 | else |
| 103 | pStats->tx_packets++; |
| 104 | |
| 105 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 106 | BSSvUpdateNodeTxCounter(pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 107 | pINTData->byTSR1, |
| 108 | pINTData->byPkt1); |
| 109 | /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/ |
| 110 | } |
| 111 | if (pINTData->byTSR2 & TSR_VALID) { |
Malcolm Priestley | ae27b14 | 2013-12-09 22:23:19 +0000 | [diff] [blame] | 112 | if (pINTData->byTSR2 & (TSR_TMO | TSR_RETRYTMO)) |
| 113 | pDevice->wstats.discard.retries++; |
| 114 | else |
| 115 | pStats->tx_packets++; |
| 116 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 117 | BSSvUpdateNodeTxCounter(pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 118 | pINTData->byTSR2, |
| 119 | pINTData->byPkt2); |
| 120 | /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/ |
| 121 | } |
| 122 | if (pINTData->byTSR3 & TSR_VALID) { |
Malcolm Priestley | ae27b14 | 2013-12-09 22:23:19 +0000 | [diff] [blame] | 123 | if (pINTData->byTSR3 & (TSR_TMO | TSR_RETRYTMO)) |
| 124 | pDevice->wstats.discard.retries++; |
| 125 | else |
| 126 | pStats->tx_packets++; |
| 127 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 128 | BSSvUpdateNodeTxCounter(pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 129 | 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 More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 139 | false; |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 140 | } else if (pMgmt->byDTIMCount == 0) { |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 141 | /* check if multicast tx buffering */ |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 142 | pMgmt->byDTIMCount = |
| 143 | pMgmt->byDTIMPeriod-1; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 144 | pMgmt->sNodeDBTable[0].bRxPSPoll = true; |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 145 | if (pMgmt->sNodeDBTable[0].bPSEnable) |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 146 | bScheduleCommand((void *) pDevice, |
| 147 | WLAN_CMD_RX_PSPOLL, |
| 148 | NULL); |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 149 | } |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 150 | bScheduleCommand((void *) pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 151 | WLAN_CMD_BECON_SEND, |
| 152 | NULL); |
| 153 | } /* if (pDevice->eOPMode == OP_MODE_AP) */ |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 154 | pDevice->bBeaconSent = true; |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 155 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 156 | pDevice->bBeaconSent = false; |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 157 | } |
| 158 | if (pINTData->byISR0 & ISR_TBTT) { |
| 159 | if (pDevice->bEnablePSMode) |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 160 | bScheduleCommand((void *) pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 161 | WLAN_CMD_TBTT_WAKEUP, |
| 162 | NULL); |
| 163 | if (pDevice->bChannelSwitch) { |
| 164 | pDevice->byChannelSwitchCount--; |
| 165 | if (pDevice->byChannelSwitchCount == 0) |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 166 | bScheduleCommand((void *) pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 167 | WLAN_CMD_11H_CHSW, |
| 168 | NULL); |
| 169 | } |
| 170 | } |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 171 | pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF); |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 172 | /*DBG_PRN_GRP01(("ISR0 = %02x , |
Jesper Juhl | ce3eaed | 2012-06-27 22:03:30 +0200 | [diff] [blame] | 173 | LoTsf = %08x, |
| 174 | HiTsf = %08x\n", |
| 175 | pINTData->byISR0, |
| 176 | pINTData->dwLoTSF, |
| 177 | pINTData->dwHiTSF)); */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 178 | |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 179 | 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 Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 189 | if (pINTData->byISR1 != 0) |
| 190 | if (pINTData->byISR1 & ISR_GPIO3) |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 191 | bScheduleCommand((void *) pDevice, |
Daniel Kenji Toyama | ff8041b | 2010-03-30 00:28:19 +1100 | [diff] [blame] | 192 | WLAN_CMD_RADIO, |
| 193 | NULL); |
| 194 | pDevice->intBuf.uDataLen = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 195 | pDevice->intBuf.bInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 196 | |
Malcolm Priestley | ae27b14 | 2013-12-09 22:23:19 +0000 | [diff] [blame] | 197 | pStats->tx_errors = pDevice->wstats.discard.retries; |
| 198 | pStats->tx_dropped = pDevice->wstats.discard.retries; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 199 | } |