📄 wt_dev_pci.c
字号:
/* Copyright (C) 2005 LHWT Inc. */ #include "wtprecomp.h" /////////////////////////////////////////////////////////////////////////////////////////WT_ADAPTER *WtWlanAdpterWt4 = NULL;//void Wt4_HandleInterrupt_tasklet(unsigned long);//DECLARE_TASKLET(WtHandleInterrupt, Wt4_HandleInterrupt_tasklet, 0);///////////////////////////////////////////////////////////////////////////////////////// const unsigned char dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 };static int wt4_bring_down(WT_ADAPTER *);static int WtAllocMemory(WT_ADAPTER *);void WtHandleInterrupt(WT_ADAPTER *Adapter);void WtHandleSendInterrupt(IN PWT_ADAPTER Adapter); /****************************************************************************** Device Interrupt Handler******************************************************************************/irqreturn_t WtInterrupt(int irq, void *config, struct pt_regs *regs){ WT_ADAPTER *Adapter=config; FN_ENTER; WT_SPIN_LOCK_IRQ(&Adapter->slock);//mxx already locked by wt_etc.c 433 line error //printk("%s LEVEL 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("%s LEVEL step3 intmaskctrl = %04x intstatus = %04x \r\n", __FUNCTION__, Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus); if((!NIC_INTERRUPT_DISABLED(Adapter))&&NIC_INTERRUPT_ACTIVE(Adapter)) { //printk("%s LEVEL step4 intmaskctrl = %04x intstatus = %04x \r\n", __FUNCTION__, Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus); //mdelay(80); //Adapter->debugvar1++; // printk(LEVEL" %s we got our interrupt (: !!!\n", __FUNCTION__); WtDisableInterrupts(Adapter); //printk(LEVEL" %s WtDisableInterrupts complete !!!\n", __FUNCTION__); //mdelay(80); WtClearInterrupts(Adapter); // printk(LEVEL" %s WtClearInterrupts complete !!!\n", __FUNCTION__); //tasklet_schedule(&WtHandleInterrupt); //printk(LEVEL" %s tasklet_schedule complete !!!\n", __FUNCTION__); WtHandleInterrupt(Adapter); //printk(LEVEL" %s WtHandleInterrupt complete !!!\n", __FUNCTION__); //WtEnableInterrupts( Adapter ); //printk(LEVEL" %s WtEnableInterrupts complete !!!\n", __FUNCTION__); } else { //printk(LEVEL" %s we got wrong interrupt ): prepare to exit !!!\n", __FUNCTION__); WT_SPIN_UNLOCK_IRQ(&Adapter->slock); //printk(LEVEL" %s WT_SPIN_UNLOCK completed, bye ,wrong interrupt!!!\n", __FUNCTION__); FN_EXIT(0,0); return IRQ_NONE; } WT_SPIN_UNLOCK_IRQ(&Adapter->slock); FN_EXIT(0,0); return IRQ_HANDLED;}///////////////////////////////////////////////////////////////////////////////////////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) { //StaMacSend( Adapter ); tasklet_schedule(&Adapter->TxTasklet); //WtHandleSendInterrupt(Adapter); //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 { //WtHandleRecvInterrupt(Adapter); 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){ UINT LoopIndex = 0; UINT LoopCount = 2; BOOL bContinue = TRUE; BOOL bAllocNewRfd = FALSE; //USHORT PacketStatus; UCHAR RxBank; p80211_hdr_t *pHdr; UINT16 ftype;//frame type UINT fstype; RXSTATUS RxStatus; UCHAR Index; PWTWLAN_RXBUF pWtRxBuf; PWTWLAN_MAINMEM MainHwMem; ASSERT(Adapter->nReadyRecv >= NIC_MIN_RFDS); FN_ENTER; Index = Adapter->NextRecvBank; // change to allow rcv multi package while(LoopIndex++ < LoopCount && bContinue) { RxStatus.RegRxStatus = ieee2host32( Adapter->CSRAddress->RxStatus.RegRxStatus ); //printk("<0> RxStatus = %08x\r\n",RxStatus.RegRxStatus); while(Index < 4) { RxStatus.RegRxStatus = ieee2host32( Adapter->CSRAddress->RxStatus.RegRxStatus ); if( RxStatus.RegRxStatus & (MASK_RX_BANK_DONE<<(2*Index))) { Adapter->NextRecvBank = Index + 1; RxBank = Index;//choose bank // 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))//backhere1 { Adapter->CSRAddress->RxStatus.RegRxStatus = host2ieee32( MASK_RX_BANK<<(2*Index) ); Index++;//added by hk 2006.6.22 continue; } //printk("ftype = %04x WLAN_FTYPE_DATA = %08x\n", ftype, WLAN_FTYPE_DATA); if( ftype == WLAN_FTYPE_DATA ) { //printk("receive data packet here\n"); 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) )//mxx see here backhere2 { if(Adapter->IsListenMode) { //defined in mime.c add it later! // add packet to monitor //InsertPacket(Adapter->pReceivedPackets, pWtRxBuf); if( ftype == WLAN_FTYPE_DATA ) NICReturnRxBuf( Adapter, pWtRxBuf ); else NICReturnRxMgmtBuf( Adapter, pWtRxBuf ); } else { // call WtWlanUpdateRssi instead // Adapter->Ndis80211Parameter.RSSI = pWtRxBuf->RXHwBuf.pHwRxBuf->RxStatus.RecvPower ; WtWlanUpdateRxPowerState( Adapter, pWtRxBuf->RXHwBuf.pHwRxBuf); WtWlanRxInQueue( Adapter, pWtRxBuf ); } } else { if( ftype == WLAN_FTYPE_DATA )//edited by hk 2004.11.23 { //edited by hk 2006.10.19 //added by hk 2006.4.11 //dev_kfree_skb(pWtRxBuf->skb); dev_kfree_skb_any(pWtRxBuf->skb); pWtRxBuf->skb = NULL; NICReturnRxBuf( Adapter, pWtRxBuf ); } else NICReturnRxMgmtBuf( Adapter, pWtRxBuf ); } //printk(LEVEL" %s start dump now !!!\n", __FUNCTION__); //Dump( (unsigned char *)(&Adapter->MainMemAddress->RxBufMap[RxBank].HwRxBuf), 300, TRUE, 1 ); //printk(LEVEL" %s dump complete now !!!\n", __FUNCTION__); Adapter->CSRAddress->RxStatus.RegRxStatus = host2ieee32( MASK_RX_BANK<<(2*Index) ); } else { // check if rx buf too small alloc to add, or drop it bContinue = FALSE; bAllocNewRfd = TRUE; break; } } //added by hk 2006.10.20 else break; Index++;//added by hk 2006.6.22 } Index = 0;//added by hk 2006.6.22 } if (Adapter->IsListenMode) IndicateReceivedPackets(Adapter); else { //printk(LEVEL" %s receive frame@ LINE = %d \n", __FUNCTION__, __LINE__); // WtWlanCFPRSPDPC( Adapter ); MPRecv( Adapter ); WtEnableInterrupts( Adapter ); } FN_EXIT(0,0);}//#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--*/void WtHandleSendInterrupt(IN PWT_ADAPTER Adapter){ //NDIS_STATUS Status = NDIS_STATUS_SUCCESS; NDIS_STATUS Status = 1; TXSTATUS TxStatus; int TxIndex; UCHAR TxBankStatus; FN_ENTER; TxStatus.RegTxStatus = ieee2host16( Adapter->CSRAddress->TxStatus.RegTxStatus ); //printk("%s LEVEL 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 ); kfree( Adapter->WtTDB.pTxbuf[1] ); Adapter->WtTDB.pTxbuf[1] = NULL; WtClearInterrupts(Adapter); Adapter->MainMemAddress->HwCSMem.CSRAddress.IntMaskCtrl &= (MASK_INT_TXEND); } else{ //standed process //if(Adapter->bSend_Test) //printk("<0>we are now in function %s at the %d line :-)\r\n",__FUNCTION__,__LINE__); //printk("<0> TxStatus = %08x\r\n",TxStatus); //TxStatus.RegTxStatus = 4924 is correct 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__); 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__); 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");//mxx error } }//standed process //printk("File %s Function %s Line %d \n", __FILE__, __FUNCTION__,__LINE__); StaMacSend( Adapter ); FN_EXIT(0,0); return Status;}//#endif////////////////////////////////////////////////////////////////////////////////////////****************************************************************************** Network Interface Control & Statistical functions******************************************************************************/static intWtOpen(struct net_device *ndev)//while"ifconfig eth1 up",executing { WT_ADAPTER *Adapter = netdev_priv(ndev); FN_ENTER; printk(LEVEL" Now we entered function %s !!!\n", __FUNCTION__); //WT_SPIN_LOCK_IRQSAVE(&Adapter->slock, flags); udelay( NIC_DELAY_POST_RESET ); WtWlanSoftReset( Adapter ); udelay( NIC_DELAY_POST_RESET ); /*Adapter->RegMacParameter.ABGMode = IEEE80211B_ONLY;*/ WtWlanInitWt4Hw(Adapter, Adapter->RegMacParameter.ABGMode); WtWlanHwIntInit(Adapter); WtEnableInterrupts( Adapter ); printk(LEVEL" Adapter->CSRAddress->IntMaskCtrl = %08x\r\n",Adapter->CSRAddress->IntMaskCtrl); printk(LEVEL" %s intmaskctrl = %04x intstatus = %04x : %08x %08x\n", __FUNCTION__, Adapter->CSRAddress->IntMaskCtrl, Adapter->CSRAddress->IntStatus, &Adapter->MainMemAddress->HwCSMem.CSRAddress, Adapter->MainMemAddress->HwCSMem.SysCfg.ChipFreq); //WT_SPIN_UNLOCK_IRQRESTORE(&Adapter->slock, flags); netif_start_queue(ndev);//start interface transmit queue,ndev->state = 0 FN_EXIT(0,0); return 0; }static int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -