⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wt_dev_mem.c

📁 linux2.6.11内核无线网卡驱动程序。支持802.11 abg
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** *This file realize all network device related functions  *Version:  *Copyright(c) 2004-2005 Beijing LHET Microelectronics Inc,All Right Reserved. *****************************************************************************/ #include "wtprecomp.h" /////////////////////////////////////////////////////////////////////////////////////////WT_ADAPTER *WtWlanAdpterWt4 = NULL;//void Wt4_HandleInterrupt_tasklet(unsigned long);//DECLARE_TASKLET(WtHandleInterrupt, Wt4_HandleInterrupt_tasklet, 0);/////////////////////////////////////////////////////////////////////////////////////////static int WtAllocMemory(WT_ADAPTER *Adapter);int WtHandleSendInterrupt(IN  PWT_ADAPTER  Adapter);void WtHandleInterrupt(WT_ADAPTER *Adapter); //const unsigned char	dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 }; /******************************************************************************    Device Interrupt Handler******************************************************************************/irqreturn_t WtInterrupt(int irq, void *config, struct pt_regs *regs){               //printk("<0> Now we entered  function %s  !!!\r\n", __FUNCTION__);       	WT_ADAPTER *Adapter=config;	FN_ENTER;	WT_SPIN_LOCK_IRQ(&Adapter->slock);//mxx already locked by wt_etc.c 433 line error	        //printk("%s   intmaskctrl = %04x intstatus = %04x : %08x %08x\r\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, &Adapter->MainMemAddress->HwCSMem.CSRAddress, Adapter->MainMemAddress->HwCSMem.SysCfg.ChipFreq);	        	//printk("<0>%s  step3 intmaskctrl = %04x intstatus = %04x  \r\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus);		if((!NIC_INTERRUPT_DISABLED(Adapter))&&NIC_INTERRUPT_ACTIVE(Adapter))	{ 		//printk("<0>%s  step4 intmaskctrl = %04x intstatus = %04x  txstatus = %04x RxStatus = %04x \r\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, Adapter->CSRAddress->TxStatus,Adapter->CSRAddress->RxStatus);		  //mdelay(80);	  //Adapter->debugvar1++;          //printk(" %s we got our interrupt (: !!!\n", __FUNCTION__);   	  WtDisableInterrupts(Adapter);	  //printk(" %s WtDisableInterrupts complete !!!\n", __FUNCTION__);	   //mdelay(80);	  WtClearInterrupts(Adapter);	  //printk(" %s WtClearInterrupts complete !!!\n", __FUNCTION__);	  	  //tasklet_schedule(&WtHandleInterrupt);	  //printk(" %s tasklet_schedule complete !!!\n", __FUNCTION__);	  	  WtHandleInterrupt(Adapter);	 // printk(" %s WtHandleInterrupt complete !!!\n", __FUNCTION__);	   	  	//WtEnableInterrupts( Adapter );	  //printk(" %s WtEnableInterrupts complete !!!\n", __FUNCTION__);	}	else	{	  //printk(" %s we got wrong interrupt ): prepare to exit !!!\n", __FUNCTION__);	  WT_SPIN_UNLOCK_IRQ(&Adapter->slock);	  //printk(" %s WT_SPIN_UNLOCK completed, bye ,wrong interrupt!!!\n", __FUNCTION__);        FN_EXIT(0,0);	  return IRQ_NONE;	  	}	//printk(" step 7 complete !!!\n");           WT_SPIN_UNLOCK_IRQ(&Adapter->slock);        FN_EXIT(0,0);	//printk(" step8 complete !!!\n");	return IRQ_HANDLED;}/////////////////////////////////////////////////////////////////////////////////////////void Wt4_HandleInterrupt_tasklet(unsigned long  pWtAdapter)void WtHandleInterrupt(WT_ADAPTER *Adapter){	//WT_ADAPTER *Adapter = (WT_ADAPTER *)WtWlanAdpterWt4;		//printk(" %s In function Wt4_HandleInterrupt_tasklet step 2 step !!! intmaskctrl = %04x intstatus = %04x : %08x %08x\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, &Adapter->MainMemAddress->HwCSMem.CSRAddress, Adapter->MainMemAddress->HwCSMem.SysCfg.ChipFreq);	//	Adapter->IntStatus |= Adapter->CSRAddress->IntStatus;//not =, because it is set at WtClearInterrupts first//	*((volatile USHORT *)(&Adapter->CSRAddress->IntStatus) )= Adapter->IntStatus;	//printk("Adapter->IntStatus 1 : %d \n", Adapter->IntStatus);	//printk("%s intmaskctrl = %04x intstatus = %04x  adapter->IntStatus = %04x\r\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, Adapter->IntStatus);	//printk("WtHandleInterrupt \n");		if( Adapter != NULL )        {		  				if(Adapter->IntStatus & MASK_STATUS_INT_TXEND)		{				tasklet_schedule(&Adapter->TxTasklet);		//printk("<0> %s WtHandleSendInterrupt is executed !!!\n", __FUNCTION__);	 				}		//added by hk 2006.4.11		//Adapter->IntStatus |= Adapter->CSRAddress->IntStatus;	//	*((volatile USHORT *)(&Adapter->CSRAddress->IntStatus) )= 		//Adapter->IntStatus & MASK_STATUS_INT_RXEND;					//printk("Adapter->IntStatus 2 : %d \n", Adapter->IntStatus);				if(Adapter->IntStatus & MASK_STATUS_INT_RXEND)//whether receive end interrupt		{ 			tasklet_schedule(&Adapter->RxTasklet);  //			printk("<0> %s WtHandleRecvInterrupt is executed !!!\n", __FUNCTION__);		}		else			//StaMacSend( Adapter );			WtEnableInterrupts(Adapter);			 			}		FN_EXIT( 0, 0 );			}VOID WtHandleRecvInterrupt(IN  PWT_ADAPTER  Adapter){                //printk(" Now we entered  function %s and the value of RecvNum is %d !!!\n", __FUNCTION__,Adapter->debugvar3++);        //printk("<0>)0x110 = %d 0x120 = %d 0x124 = %d 0x128 = %d 0x164 = %08x\r\n", Adapter->MainMemAddress->HwCSMem.HwStatistic.XmtMsduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvMpduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvSuccessMpduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvMissedCounter, Adapter->CSRAddress->RxStatus.RegRxStatus);	UINT            LoopIndex = 0;	UINT            LoopCount = 1;	BOOL            bContinue = TRUE;	BOOL            bAllocNewRfd = FALSE;	//USHORT          PacketStatus;	UCHAR           RxBank;	p80211_hdr_t	*pHdr;	UINT16          ftype;	UINT            fstype;	RXSTATUS        RxStatus;	UCHAR           Index;	PWTWLAN_RXBUF   pWtRxBuf;	PWTWLAN_MAINMEM	MainHwMem;//	WtDisableInterrupts(Adapter);	ASSERT(Adapter->nReadyRecv >= NIC_MIN_RFDS);	MainHwMem = Adapter->MainMemAddress;		// change to allow rcv multi package 	        //printk("<0>we are now in function %s at the %d line :-)\r\n",__FUNCTION__,__LINE__);	while(LoopIndex++ < LoopCount && bContinue)	{	        RxStatus = Adapter->CSRAddress->RxStatus;	       		//printk(" RxStatus = %08x\r\n",RxStatus.RegRxStatus);	        if(RxStatus.RegRxStatus == 0)	               break;	        for( Index = 0; Index < 4; Index++ )	        {	                if(RxStatus.RegRxStatus & (MASK_RX_BANK_DONE<<(2*Index)))	                {	                       RxBank = Index;					                       // log rx frame type and timestamp here	                       // move here for convenient to debug out	 	       	                       pHdr = (p80211_hdr_t*)&Adapter->MainMemAddress->RxBufMap[RxBank].HwRxBuf.dot11Head;	                       ftype =  WLAN_GET_FC_FTYPE(ieee2host16(pHdr->a3.fc));	                       fstype = WLAN_GET_FC_FSTYPE(ieee2host16(pHdr->a3.fc));	                       if( FALSE == MPPreRecv( Adapter, RxBank))	                       {			                //printk("<0>We lost a package :-(\n\r");		                        Adapter->CSRAddress->RxStatus.RegRxStatus = MASK_RX_BANK<<(2*Index);		                        continue;	                       }			       								if( ftype == WLAN_FTYPE_DATA )					{		                        AllocRxBuff(Adapter,  &pWtRxBuf);					}					else					{	                                AllocRxMgmtBuff(Adapter,  &pWtRxBuf);					}			       					                       if( NULL != pWtRxBuf )	                       {		                        pWtRxBuf->ftype = ftype;		                        pWtRxBuf->fstype = fstype;		                        pWtRxBuf->FrmCtl = ieee2host16(pHdr->a3.fc);		                        if( NICRecv( Adapter, Index, pWtRxBuf)  )		                        { 		                               if(Adapter->IsListenMode)		                               {       //defined in mime.c add it later!		                                       //InsertPacket(Adapter->pReceivedPackets, pWtRxBuf);									                                       if( ftype == WLAN_FTYPE_DATA )			                                       NICReturnRxBuf( Adapter,  pWtRxBuf );		                                       else			                                       NICReturnRxMgmtBuf( Adapter,  pWtRxBuf );		                                }		                                else		                                {						                                        Adapter->Ndis80211Parameter.RSSI = pWtRxBuf->RXHwBuf.pHwRxBuf->RxStatus.RecvPower;		                                        WtWlanRxInQueue(  Adapter, pWtRxBuf );		                                }		    		                        }		                        else		                        {    		                                if( ftype == WLAN_FTYPE_DATA )//edited by hk 2004.11.23		                                         NICReturnRxBuf( Adapter,  pWtRxBuf );		                                else		                                         NICReturnRxMgmtBuf( Adapter,  pWtRxBuf );		                                		                        }					                                        // printk(" %s start dump now !!!\n", __FUNCTION__);		 		                        //Dump( (unsigned char *)(&Adapter->MainMemAddress->RxBufMap[RxBank].HwRxBuf), 300, TRUE, 1 );		                        //printk(" %s dump  complete now !!!\n", __FUNCTION__);		  				Adapter->CSRAddress->RxStatus.RegRxStatus = MASK_RX_BANK<<(2*Index);		                }		                else		                {		                		printk("~~~~~~~in WtHandleRecvInterrupt don't allocate pWtRxBuf\n");		                        // check if rx buf too small alloc to add, or drop it 		                        bContinue = FALSE;  		                        bAllocNewRfd = TRUE;		                        break;		                }	                }		}        } 	if (Adapter->IsListenMode)	        IndicateReceivedPackets(Adapter);			else	{		//printk(" %s receive frame@ LINE = %d \n", __FUNCTION__, __LINE__);//del temp	// 	        WtWlanCFPRSPDPC( Adapter );	        MPRecv( Adapter );		WtEnableInterrupts( Adapter );	}}//#if 0/*++Routine Description:Interrupt handler for sending processing Re-claim the send resources,                     complete sends and get more to send from the send wait queueAssumption: Send spinlock has been acquired Arguments:    Adapter  Pointer to our adapterReturn Value: NDIS_STATUS_SUCCESS              NDIS_STATUS_HARD_ERRORS	      NDIS_STATUS_PENDING--*/int WtHandleSendInterrupt(IN  PWT_ADAPTER  Adapter){	//NDIS_STATUS     Status = NDIS_STATUS_SUCCESS;	NDIS_STATUS      Status = 1;	TXSTATUS	 TxStatus;	int              TxIndex;	UCHAR            TxBankStatus;         FN_ENTER;//	WtDisableInterrupts(Adapter);			TxStatus = Adapter->CSRAddress->TxStatus;	  			//printk("<0>)0x110 = %d 0x120 = %d 0x124 = %d 0x128 = %d 0x164 = %08x\r\n", Adapter->MainMemAddress->HwCSMem.HwStatistic.XmtMsduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvMpduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvSuccessMpduCounter, Adapter->MainMemAddress->HwCSMem.HwStatistic.RcvMissedCounter, Adapter->CSRAddress->RxStatus.RegRxStatus);	//printk("<0>%s   intmaskctrl = %04x intstatus = %04x : %08x %08x\r\n", __FUNCTION__,  Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, &Adapter->MainMemAddress->HwCSMem.CSRAddress, Adapter->MainMemAddress->HwCSMem.SysCfg.ChipFreq);	///////////////////////////////////////////////////////////////////////////////////////////////	if(Adapter->bSend_Test)	{	        //Dump( (char *)(&(Adapter->MainMemAddress->TxBufMap[1].HwTxBuf)),(1600+sizeof(WTWLAN_TAUXB)+80), TRUE, 1 );			        //printk(" return buffer\r\n");		 		kfree( Adapter->WtTDB.pTxbuf[1] );		 		Adapter->WtTDB.pTxbuf[1]  = NULL;				WtClearInterrupts(Adapter);		Adapter->MainMemAddress->HwCSMem.CSRAddress.IntMaskCtrl &= (MASK_INT_TXEND);	}//if(Adapter->bSend_Test)	///////////////////////////////////////////////////////////////////////////////////////////////	else//standed process	{  	        //printk("<0>we are now in function %s at the %d line :-)\r\n",__FUNCTION__,__LINE__);	        //printk("<0> TxStatus = %08x\r\n",TxStatus);		if( WT_TXHW_DONE(TxStatus.RegTxStatus) )		{			for( TxIndex = 0; TxIndex < TX_BUF_NUM; TxIndex++)			{				if( Adapter->WtTDB.pTxbuf[TxIndex] )				{					if( ( TxBankStatus = ( (TxStatus.RegTxStatus >> (3*TxIndex) ) & MASK_TX_BANK) ) > 4 )					{						if( TxBankStatus & MASK_TX_STATUS_ERROR )						{					       	 //printk("<0>we are now in function %s at the %d line :-(\r\n",__FUNCTION__,__LINE__);							//printk(" intmaskctrl = %04x intstatus = %04x \n\r",Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus);							Adapter->WtTDB.pTxbuf[TxIndex]->SendStatus =NDIS_STATUS_FAILURE;							TxDoneHandle( Adapter, Adapter->WtTDB.pTxbuf[TxIndex] );						}						else						{       					        	 //printk("<0>we are now in function %s at the %d line :-)\r\n",__FUNCTION__,__LINE__);							 //printk(" intmaskctrl = %04x intstatus = %04x \n\r",Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus);							Adapter->WtTDB.pTxbuf[TxIndex]->SendStatus =NDIS_STATUS_SUCCESS;							TxDoneHandle( Adapter, Adapter->WtTDB.pTxbuf[TxIndex] );						}					}				}			}		} //if( WT_TXHW_DONE(TxStatus.RegTxStatus)		else		{//		      printk("error when reading TxStatus in function WtHandleSendInterrupt\n");		}        }//standed process	StaMacSend( Adapter );	FN_EXIT(0,0);	return Status;}//#endif////////////////////////////////////////////////////////////////////////////////////////******************************************************************************    Network Interface Control & Statistical functions******************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -