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 int msglevel
= MSG_LEVEL_INFO
; /* MSG_LEVEL_DEBUG */
47 * Function: InterruptPollingThread
49 * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
51 * Arguments: Device Extension
55 * Algorithm: Call USBD for input data;
57 * History: dd-mm-yyyy Author Comment
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
67 void INTvWorkItem(struct vnt_private
*pDevice
)
71 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->Interrupt Polling Thread\n");
73 spin_lock_irq(&pDevice
->lock
);
74 if (pDevice
->fKillEventPollingThread
!= true)
75 ntStatus
= PIPEnsInterruptRead(pDevice
);
76 spin_unlock_irq(&pDevice
->lock
);
79 void INTnsProcessData(struct vnt_private
*pDevice
)
82 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
83 struct net_device_stats
*pStats
= &pDevice
->stats
;
85 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"---->s_nsInterruptProcessData\n");
87 pINTData
= (PSINTData
) pDevice
->intBuf
.pDataBuf
;
88 if (pINTData
->byTSR0
& TSR_VALID
) {
89 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
90 (u8
)(pINTData
->byPkt0
& 0x0F),
91 (u8
)(pINTData
->byPkt0
>>4),
93 BSSvUpdateNodeTxCounter(pDevice
,
94 &(pDevice
->scStatistic
),
97 /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/
99 if (pINTData
->byTSR1
& TSR_VALID
) {
100 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
101 (u8
)(pINTData
->byPkt1
& 0x0F),
102 (u8
)(pINTData
->byPkt1
>>4),
104 BSSvUpdateNodeTxCounter(pDevice
,
105 &(pDevice
->scStatistic
),
108 /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/
110 if (pINTData
->byTSR2
& TSR_VALID
) {
111 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
112 (u8
)(pINTData
->byPkt2
& 0x0F),
113 (u8
)(pINTData
->byPkt2
>>4),
115 BSSvUpdateNodeTxCounter(pDevice
,
116 &(pDevice
->scStatistic
),
119 /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
121 if (pINTData
->byTSR3
& TSR_VALID
) {
122 STAvUpdateTDStatCounter(&(pDevice
->scStatistic
),
123 (u8
)(pINTData
->byPkt3
& 0x0F),
124 (u8
)(pINTData
->byPkt3
>>4),
126 BSSvUpdateNodeTxCounter(pDevice
,
127 &(pDevice
->scStatistic
),
130 /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
132 if (pINTData
->byISR0
!= 0) {
133 if (pINTData
->byISR0
& ISR_BNTX
) {
134 if (pDevice
->eOPMode
== OP_MODE_AP
) {
135 if (pMgmt
->byDTIMCount
> 0) {
136 pMgmt
->byDTIMCount
--;
137 pMgmt
->sNodeDBTable
[0].bRxPSPoll
=
139 } else if (pMgmt
->byDTIMCount
== 0) {
140 /* check if multicast tx buffering */
142 pMgmt
->byDTIMPeriod
-1;
143 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= true;
144 if (pMgmt
->sNodeDBTable
[0].bPSEnable
)
145 bScheduleCommand((void *) pDevice
,
149 bScheduleCommand((void *) pDevice
,
152 } /* if (pDevice->eOPMode == OP_MODE_AP) */
153 pDevice
->bBeaconSent
= true;
155 pDevice
->bBeaconSent
= false;
157 if (pINTData
->byISR0
& ISR_TBTT
) {
158 if (pDevice
->bEnablePSMode
)
159 bScheduleCommand((void *) pDevice
,
160 WLAN_CMD_TBTT_WAKEUP
,
162 if (pDevice
->bChannelSwitch
) {
163 pDevice
->byChannelSwitchCount
--;
164 if (pDevice
->byChannelSwitchCount
== 0)
165 bScheduleCommand((void *) pDevice
,
170 pDevice
->qwCurrTSF
= cpu_to_le64(pINTData
->qwTSF
);
171 /*DBG_PRN_GRP01(("ISR0 = %02x ,
176 pINTData->dwHiTSF)); */
178 STAvUpdate802_11Counter(&pDevice
->s802_11Counter
,
179 &pDevice
->scStatistic
,
180 pINTData
->byRTSSuccess
,
184 STAvUpdateIsrStatCounter(&pDevice
->scStatistic
,
188 if (pINTData
->byISR1
!= 0)
189 if (pINTData
->byISR1
& ISR_GPIO3
)
190 bScheduleCommand((void *) pDevice
,
193 pDevice
->intBuf
.uDataLen
= 0;
194 pDevice
->intBuf
.bInUse
= false;
196 pStats
->tx_packets
= pDevice
->scStatistic
.ullTsrOK
;
197 pStats
->tx_bytes
= pDevice
->scStatistic
.ullTxDirectedBytes
+
198 pDevice
->scStatistic
.ullTxMulticastBytes
+
199 pDevice
->scStatistic
.ullTxBroadcastBytes
;
200 pStats
->tx_errors
= pDevice
->scStatistic
.dwTsrErr
;
201 pStats
->tx_dropped
= pDevice
->scStatistic
.dwTsrErr
;