summaryrefslogblamecommitdiffstats
path: root/drivers/staging/vt6656/int.c
blob: 0094887d4d529c86cda955f51bc4912c4a9e51c8 (plain) (tree)

































                                                                          
                
                   
                
                  
                  
                    
 
                                                           
 
















                                                     


                                                                              

   
                                              
 
                     
 
                                                                             
 
                                      
                                                     


                                                        
 
                                                  
 
                                            
                                                       



                                                                             


                                                                         



                                                          
                                                

                                                        
         

                                                              




                                                          
                                                

                                                        
         

                                                              



                                                          
                                                

                                                        

                                                                     

                                                              



                                                          
                                                

                                                        

                                                                     

                                                
                                                                    


                                                                          
                                                      
                                                                     
                                                                             

                                                                      
                                                                                
                                                                             


                                                                                    
                                 
                                                                  

                                                                    
                         
                                            
                        
                                                     
                 
                                                
                                                   
                                                                  




                                                                       
                                                                          



                                                                          
                                                                
                                               




                                         
         

                                               
                                                          


                                                       
                                       
 

                                                             
 
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *
 * File: int.c
 *
 * Purpose: Handle USB interrupt endpoint
 *
 * Author: Jerry Chen
 *
 * Date: Apr. 2, 2004
 *
 * Functions:
 *
 * Revision History:
 *      04-02-2004 Jerry Chen:  Initial release
 *
 */

#include "int.h"
#include "tmacro.h"
#include "mac.h"
#include "power.h"
#include "bssdb.h"
#include "usbpipe.h"

static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */

/*+
 *
 *  Function:   InterruptPollingThread
 *
 *  Synopsis:   Thread running at IRQL PASSIVE_LEVEL.
 *
 *  Arguments: Device Extension
 *
 *  Returns:
 *
 *  Algorithm:  Call USBD for input data;
 *
 *  History:    dd-mm-yyyy   Author    Comment
 *
 *
 *  Notes:
 *
 *  USB reads are by nature 'Blocking', and when in a read, the device looks
 *  like it's in a 'stall' condition, so we deliberately time out every second
 *  if we've gotten no data
 *
-*/
void INTvWorkItem(struct vnt_private *pDevice)
{
	int ntStatus;

	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");

	spin_lock_irq(&pDevice->lock);
	if (pDevice->fKillEventPollingThread != true)
		ntStatus = PIPEnsInterruptRead(pDevice);
	spin_unlock_irq(&pDevice->lock);
}

void INTnsProcessData(struct vnt_private *pDevice)
{
	struct vnt_interrupt_data *pINTData;
	struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
	struct net_device_stats *pStats = &pDevice->stats;

	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");

	pINTData = (struct vnt_interrupt_data *)pDevice->intBuf.pDataBuf;
	if (pINTData->tsr0 & TSR_VALID) {
		if (pINTData->tsr0 & (TSR_TMO | TSR_RETRYTMO))
			pDevice->wstats.discard.retries++;
		else
			pStats->tx_packets++;

		BSSvUpdateNodeTxCounter(pDevice,
					pINTData->tsr0,
					pINTData->pkt0);
	}
	if (pINTData->tsr1 & TSR_VALID) {
		if (pINTData->tsr1 & (TSR_TMO | TSR_RETRYTMO))
			pDevice->wstats.discard.retries++;
		else
			pStats->tx_packets++;


		BSSvUpdateNodeTxCounter(pDevice,
					pINTData->tsr1,
					pINTData->pkt1);
	}
	if (pINTData->tsr2 & TSR_VALID) {
		if (pINTData->tsr2 & (TSR_TMO | TSR_RETRYTMO))
			pDevice->wstats.discard.retries++;
		else
			pStats->tx_packets++;

		BSSvUpdateNodeTxCounter(pDevice,
					pINTData->tsr2,
					pINTData->pkt2);
		/*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/
	}
	if (pINTData->tsr3 & TSR_VALID) {
		if (pINTData->tsr3 & (TSR_TMO | TSR_RETRYTMO))
			pDevice->wstats.discard.retries++;
		else
			pStats->tx_packets++;

		BSSvUpdateNodeTxCounter(pDevice,
					pINTData->tsr3,
					pINTData->pkt3);
		/*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/
	}
	if (pINTData->isr0 != 0) {
		if (pINTData->isr0 & ISR_BNTX) {
			if (pDevice->op_mode == NL80211_IFTYPE_AP) {
				if (pMgmt->byDTIMCount > 0) {
					pMgmt->byDTIMCount--;
					pMgmt->sNodeDBTable[0].bRxPSPoll =
						false;
				} else if (pMgmt->byDTIMCount == 0) {
					/* check if multicast tx buffering */
					pMgmt->byDTIMCount =
						pMgmt->byDTIMPeriod-1;
					pMgmt->sNodeDBTable[0].bRxPSPoll = true;
					if (pMgmt->sNodeDBTable[0].bPSEnable)
						bScheduleCommand((void *) pDevice,
								 WLAN_CMD_RX_PSPOLL,
								 NULL);
				}
				bScheduleCommand((void *) pDevice,
						WLAN_CMD_BECON_SEND,
						NULL);
			}
		pDevice->bBeaconSent = true;
		} else {
			pDevice->bBeaconSent = false;
		}
		if (pINTData->isr0 & ISR_TBTT) {
			if (pDevice->bEnablePSMode)
				bScheduleCommand((void *) pDevice,
						WLAN_CMD_TBTT_WAKEUP,
						NULL);
			if (pDevice->bChannelSwitch) {
				pDevice->byChannelSwitchCount--;
				if (pDevice->byChannelSwitchCount == 0)
					bScheduleCommand((void *) pDevice,
							WLAN_CMD_11H_CHSW,
							NULL);
			}
		}
		pDevice->qwCurrTSF = le64_to_cpu(pINTData->tsf);
		/*DBG_PRN_GRP01(("ISR0 = %02x ,
		  LoTsf =  %08x,
		  HiTsf =  %08x\n",
		  pINTData->byISR0,
		  pINTData->dwLoTSF,
		  pINTData->dwHiTSF)); */
	}
	if (pINTData->isr1 != 0)
		if (pINTData->isr1 & ISR_GPIO3)
			bScheduleCommand((void *) pDevice,
					WLAN_CMD_RADIO,
					NULL);
	pDevice->intBuf.uDataLen = 0;
	pDevice->intBuf.bInUse = false;

	pStats->tx_errors = pDevice->wstats.discard.retries;
	pStats->tx_dropped = pDevice->wstats.discard.retries;
}