[ARM] pxa: Gumstix Verdex PCMCIA support
[linux-2.6/verdex.git] / drivers / staging / vt6656 / int.c
blob35053be6900d23bbf3c3f2f197ed9418f0ec2d06
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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.
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.
20 * File: int.c
22 * Purpose: Handle USB interrupt endpoint
24 * Author: Jerry Chen
26 * Date: Apr. 2, 2004
28 * Functions:
30 * Revision History:
31 * 04-02-2004 Jerry Chen: Initial release
35 #include "int.h"
36 #include "mib.h"
37 #include "tmacro.h"
38 #include "mac.h"
39 #include "power.h"
40 #include "bssdb.h"
41 #include "usbpipe.h"
43 /*--------------------- Static Definitions -------------------------*/
44 //static int msglevel =MSG_LEVEL_DEBUG;
45 static int msglevel =MSG_LEVEL_INFO;
48 /*--------------------- Static Classes ----------------------------*/
50 /*--------------------- Static Variables --------------------------*/
52 /*--------------------- Static Functions --------------------------*/
54 /*--------------------- Export Variables --------------------------*/
57 /*--------------------- Export Functions --------------------------*/
60 /*+
62 * Function: InterruptPollingThread
64 * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
66 * Arguments: Device Extension
68 * Returns:
70 * Algorithm: Call USBD for input data;
72 * History: dd-mm-yyyy Author Comment
75 * Notes:
77 * USB reads are by nature 'Blocking', and when in a read, the device looks like it's
78 * in a 'stall' condition, so we deliberately time out every second if we've gotten no data
80 -*/
81 VOID
82 INTvWorkItem(
83 PVOID Context
86 PSDevice pDevice = (PSDevice) Context;
87 NTSTATUS ntStatus;
89 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
91 spin_lock_irq(&pDevice->lock);
92 if (pDevice->fKillEventPollingThread != TRUE) {
93 ntStatus = PIPEnsInterruptRead(pDevice);
95 spin_unlock_irq(&pDevice->lock);
100 NTSTATUS
101 INTnsProcessData(
102 IN PSDevice pDevice
105 NTSTATUS status = STATUS_SUCCESS;
106 PSINTData pINTData;
107 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
108 struct net_device_stats* pStats = &pDevice->stats;
111 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
113 pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
114 if (pINTData->byTSR0 & TSR_VALID) {
115 STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt0 & 0x0F), (BYTE) (pINTData->byPkt0>>4), pINTData->byTSR0);
116 BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR0, pINTData->byPkt0);
117 //DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));
119 if (pINTData->byTSR1 & TSR_VALID) {
120 STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt1 & 0x0F), (BYTE) (pINTData->byPkt1>>4), pINTData->byTSR1);
121 BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR1, pINTData->byPkt1);
122 //DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));
124 if (pINTData->byTSR2 & TSR_VALID) {
125 STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt2 & 0x0F), (BYTE) (pINTData->byPkt2>>4), pINTData->byTSR2);
126 BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR2, pINTData->byPkt2);
127 //DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));
129 if (pINTData->byTSR3 & TSR_VALID) {
130 STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt3 & 0x0F), (BYTE) (pINTData->byPkt3>>4), pINTData->byTSR3);
131 BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR3, pINTData->byPkt3);
132 //DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));
134 if ( pINTData->byISR0 != 0 ) {
135 if (pINTData->byISR0 & ISR_BNTX) {
137 if (pDevice->eOPMode == OP_MODE_AP) {
138 if(pMgmt->byDTIMCount > 0) {
139 pMgmt->byDTIMCount --;
140 pMgmt->sNodeDBTable[0].bRxPSPoll = FALSE;
141 } else if(pMgmt->byDTIMCount == 0) {
142 // check if mutltcast tx bufferring
143 pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
144 pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE;
145 if (pMgmt->sNodeDBTable[0].bPSEnable) {
146 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
149 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BECON_SEND, NULL);
150 } // if (pDevice->eOPMode == OP_MODE_AP)
152 pDevice->bBeaconSent = TRUE;
153 } else {
154 pDevice->bBeaconSent = FALSE;
156 if (pINTData->byISR0 & ISR_TBTT) {
157 if ( pDevice->bEnablePSMode ) {
158 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_TBTT_WAKEUP, NULL);
160 if ( pDevice->bChannelSwitch ) {
161 pDevice->byChannelSwitchCount--;
162 if ( pDevice->byChannelSwitchCount == 0 ) {
163 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_11H_CHSW, NULL);
167 LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF;
168 HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF;
169 //DBG_PRN_GRP01(("ISR0 = %02x ,LoTsf = %08x,HiTsf = %08x\n", pINTData->byISR0, pINTData->dwLoTSF,pINTData->dwHiTSF));
171 STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, pINTData->byRTSSuccess,
172 pINTData->byRTSFail, pINTData->byACKFail, pINTData->byFCSErr );
173 STAvUpdateIsrStatCounter(&pDevice->scStatistic, pINTData->byISR0, pINTData->byISR1);
177 if ( pINTData->byISR1 != 0 ) {
178 if (pINTData->byISR1 & ISR_GPIO3) {
179 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_RADIO, NULL);
182 pDevice->intBuf.uDataLen = 0;
183 pDevice->intBuf.bInUse = FALSE;
185 pStats->tx_packets = pDevice->scStatistic.ullTsrOK;
186 pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes +
187 pDevice->scStatistic.ullTxMulticastBytes +
188 pDevice->scStatistic.ullTxBroadcastBytes;
189 pStats->tx_errors = pDevice->scStatistic.dwTsrErr;
190 pStats->tx_dropped = pDevice->scStatistic.dwTsrErr;
192 return status;