2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
22 * Purpose: Handle USB interrupt endpoint
31 * 04-02-2004 Jerry Chen: Initial release
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 --------------------------*/
62 * Function: InterruptPollingThread
64 * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
66 * Arguments: Device Extension
70 * Algorithm: Call USBD for input data;
72 * History: dd-mm-yyyy Author Comment
77 * USB reads are by nature 'Blocking', and when in a read, the device looks
78 * like it's in a 'stall' condition, so we deliberately time out every second
79 * if we've gotten no data
82 void INTvWorkItem(void *Context
)
84 PSDevice pDevice
= (PSDevice
) Context
;
87 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->Interrupt Polling Thread\n");
89 spin_lock_irq(&pDevice
->lock
);
90 if (pDevice
->fKillEventPollingThread
!= TRUE
)
91 ntStatus
= PIPEnsInterruptRead(pDevice
);
92 spin_unlock_irq(&pDevice
->lock
);
95 int INTnsProcessData(PSDevice pDevice
)
97 int status
= STATUS_SUCCESS
;
99 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
100 struct net_device_stats
*pStats
= &pDevice
->stats
;
102 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->s_nsInterruptProcessData\n");
104 pINTData
= (PSINTData
) pDevice
->intBuf
.pDataBuf
;
105 if (pINTData
->byTSR0
& TSR_VALID
) {
106 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
107 (BYTE
) (pINTData
->byPkt0
& 0x0F),
108 (BYTE
) (pINTData
->byPkt0
>>4),
110 BSSvUpdateNodeTxCounter(pDevice
,
111 &(pDevice
->scStatistic
),
114 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
116 if (pINTData
->byTSR1
& TSR_VALID
) {
117 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
118 (BYTE
) (pINTData
->byPkt1
& 0x0F),
119 (BYTE
) (pINTData
->byPkt1
>>4),
121 BSSvUpdateNodeTxCounter(pDevice
,
122 &(pDevice
->scStatistic
),
125 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
127 if (pINTData
->byTSR2
& TSR_VALID
) {
128 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
129 (BYTE
) (pINTData
->byPkt2
& 0x0F),
130 (BYTE
) (pINTData
->byPkt2
>>4),
132 BSSvUpdateNodeTxCounter(pDevice
,
133 &(pDevice
->scStatistic
),
136 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
138 if (pINTData
->byTSR3
& TSR_VALID
) {
139 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
140 (BYTE
) (pINTData
->byPkt3
& 0x0F),
141 (BYTE
) (pINTData
->byPkt3
>>4),
143 BSSvUpdateNodeTxCounter(pDevice
,
144 &(pDevice
->scStatistic
),
147 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
149 if (pINTData
->byISR0
!= 0) {
150 if (pINTData
->byISR0
& ISR_BNTX
) {
151 if (pDevice
->eOPMode
== OP_MODE_AP
) {
152 if (pMgmt
->byDTIMCount
> 0) {
153 pMgmt
->byDTIMCount
--;
154 pMgmt
->sNodeDBTable
[0].bRxPSPoll
=
156 } else if (pMgmt
->byDTIMCount
== 0) {
157 /* check if mutltcast tx bufferring */
159 pMgmt
->byDTIMPeriod
-1;
160 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= TRUE
;
161 if (pMgmt
->sNodeDBTable
[0].bPSEnable
)
162 bScheduleCommand((void *) pDevice
,
166 bScheduleCommand((void *) pDevice
,
169 } /* if (pDevice->eOPMode == OP_MODE_AP) */
170 pDevice
->bBeaconSent
= TRUE
;
172 pDevice
->bBeaconSent
= FALSE
;
174 if (pINTData
->byISR0
& ISR_TBTT
) {
175 if (pDevice
->bEnablePSMode
)
176 bScheduleCommand((void *) pDevice
,
177 WLAN_CMD_TBTT_WAKEUP
,
179 if (pDevice
->bChannelSwitch
) {
180 pDevice
->byChannelSwitchCount
--;
181 if (pDevice
->byChannelSwitchCount
== 0)
182 bScheduleCommand((void *) pDevice
,
187 LODWORD(pDevice
->qwCurrTSF
) = pINTData
->dwLoTSF
;
188 HIDWORD(pDevice
->qwCurrTSF
) = pINTData
->dwHiTSF
;
189 /*DBG_PRN_GRP01(("ISR0 = %02x ,
194 pINTData->dwHiTSF)); */
196 STAvUpdate802_11Counter(&pDevice
->s802_11Counter
,
197 &pDevice
->scStatistic
,
198 pINTData
->byRTSSuccess
,
202 STAvUpdateIsrStatCounter(&pDevice
->scStatistic
,
207 if (pINTData
->byISR1
!= 0)
208 if (pINTData
->byISR1
& ISR_GPIO3
)
209 bScheduleCommand((void *) pDevice
,
212 pDevice
->intBuf
.uDataLen
= 0;
213 pDevice
->intBuf
.bInUse
= FALSE
;
215 pStats
->tx_packets
= pDevice
->scStatistic
.ullTsrOK
;
216 pStats
->tx_bytes
= pDevice
->scStatistic
.ullTxDirectedBytes
+
217 pDevice
->scStatistic
.ullTxMulticastBytes
+
218 pDevice
->scStatistic
.ullTxBroadcastBytes
;
219 pStats
->tx_errors
= pDevice
->scStatistic
.dwTsrErr
;
220 pStats
->tx_dropped
= pDevice
->scStatistic
.dwTsrErr
;