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
83 INTvWorkItem(PVOID Context
)
85 PSDevice pDevice
= (PSDevice
) Context
;
88 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->Interrupt Polling Thread\n");
90 spin_lock_irq(&pDevice
->lock
);
91 if (pDevice
->fKillEventPollingThread
!= TRUE
)
92 ntStatus
= PIPEnsInterruptRead(pDevice
);
93 spin_unlock_irq(&pDevice
->lock
);
97 INTnsProcessData(PSDevice pDevice
)
99 NTSTATUS status
= STATUS_SUCCESS
;
101 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
102 struct net_device_stats
*pStats
= &pDevice
->stats
;
104 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->s_nsInterruptProcessData\n");
106 pINTData
= (PSINTData
) pDevice
->intBuf
.pDataBuf
;
107 if (pINTData
->byTSR0
& TSR_VALID
) {
108 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
109 (BYTE
) (pINTData
->byPkt0
& 0x0F),
110 (BYTE
) (pINTData
->byPkt0
>>4),
112 BSSvUpdateNodeTxCounter(pDevice
,
113 &(pDevice
->scStatistic
),
116 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
118 if (pINTData
->byTSR1
& TSR_VALID
) {
119 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
120 (BYTE
) (pINTData
->byPkt1
& 0x0F),
121 (BYTE
) (pINTData
->byPkt1
>>4),
123 BSSvUpdateNodeTxCounter(pDevice
,
124 &(pDevice
->scStatistic
),
127 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
129 if (pINTData
->byTSR2
& TSR_VALID
) {
130 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
131 (BYTE
) (pINTData
->byPkt2
& 0x0F),
132 (BYTE
) (pINTData
->byPkt2
>>4),
134 BSSvUpdateNodeTxCounter(pDevice
,
135 &(pDevice
->scStatistic
),
138 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
140 if (pINTData
->byTSR3
& TSR_VALID
) {
141 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
142 (BYTE
) (pINTData
->byPkt3
& 0x0F),
143 (BYTE
) (pINTData
->byPkt3
>>4),
145 BSSvUpdateNodeTxCounter(pDevice
,
146 &(pDevice
->scStatistic
),
149 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
151 if (pINTData
->byISR0
!= 0) {
152 if (pINTData
->byISR0
& ISR_BNTX
) {
153 if (pDevice
->eOPMode
== OP_MODE_AP
) {
154 if (pMgmt
->byDTIMCount
> 0) {
155 pMgmt
->byDTIMCount
--;
156 pMgmt
->sNodeDBTable
[0].bRxPSPoll
=
158 } else if (pMgmt
->byDTIMCount
== 0) {
159 /* check if mutltcast tx bufferring */
161 pMgmt
->byDTIMPeriod
-1;
162 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= TRUE
;
163 if (pMgmt
->sNodeDBTable
[0].bPSEnable
)
164 bScheduleCommand((HANDLE
)pDevice
,
168 bScheduleCommand((HANDLE
)pDevice
,
171 } /* if (pDevice->eOPMode == OP_MODE_AP) */
172 pDevice
->bBeaconSent
= TRUE
;
174 pDevice
->bBeaconSent
= FALSE
;
176 if (pINTData
->byISR0
& ISR_TBTT
) {
177 if (pDevice
->bEnablePSMode
)
178 bScheduleCommand((HANDLE
) pDevice
,
179 WLAN_CMD_TBTT_WAKEUP
,
181 if (pDevice
->bChannelSwitch
) {
182 pDevice
->byChannelSwitchCount
--;
183 if (pDevice
->byChannelSwitchCount
== 0)
184 bScheduleCommand((HANDLE
) pDevice
,
189 LODWORD(pDevice
->qwCurrTSF
) = pINTData
->dwLoTSF
;
190 HIDWORD(pDevice
->qwCurrTSF
) = pINTData
->dwHiTSF
;
191 /*DBG_PRN_GRP01(("ISR0 = %02x ,
196 pINTData->dwHiTSF)); */
198 STAvUpdate802_11Counter(&pDevice
->s802_11Counter
,
199 &pDevice
->scStatistic
,
200 pINTData
->byRTSSuccess
,
204 STAvUpdateIsrStatCounter(&pDevice
->scStatistic
,
209 if (pINTData
->byISR1
!= 0)
210 if (pINTData
->byISR1
& ISR_GPIO3
)
211 bScheduleCommand((HANDLE
) pDevice
,
214 pDevice
->intBuf
.uDataLen
= 0;
215 pDevice
->intBuf
.bInUse
= FALSE
;
217 pStats
->tx_packets
= pDevice
->scStatistic
.ullTsrOK
;
218 pStats
->tx_bytes
= pDevice
->scStatistic
.ullTxDirectedBytes
+
219 pDevice
->scStatistic
.ullTxMulticastBytes
+
220 pDevice
->scStatistic
.ullTxBroadcastBytes
;
221 pStats
->tx_errors
= pDevice
->scStatistic
.dwTsrErr
;
222 pStats
->tx_dropped
= pDevice
->scStatistic
.dwTsrErr
;