diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
commit | fb20871a54961b82d35303b43452928186c1361d (patch) | |
tree | 1beeb39e45eda1c8b5893090904b583fceeb07ef /drivers/staging/rt2870/common/rtusb_bulk.c | |
parent | bee89ab228e6f51c4ddd3481b9bd491859a8ee7b (diff) | |
parent | c7a5d70796379e3d51d0c652fbe1634b81d3bbd5 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (342 commits)
Staging: comedi: fix build errors
Staging: udlfb: update to version 0.2.3
Staging: udlfb: fix some sparse warnings.
Staging: udlfb: clean up checkpatch warnings in udlfb.c
Staging: udlfb: clean up checkpatch warnings in udlfb.h
Staging: udlfb: add udlfb driver to build
Staging: add udlfb driver
Staging: pata_rdc: remove pointless comments
Staging: pata_rdc: remove DRIVER macros
Staging: pata_rdc: remove dbgprintf macro
Staging: pata_rdc: remove broken flag
Staging: pata_rdc: fix build warnings
Staging: pata_rdc: use PCI_DEVICE
Staging: pata_rdc: remove function prototypes
Staging: pata_rdc: coding style fixes
Staging: pata_rdc: convert code to work in 2.6.29
Staging: pata_rdc: add driver to the build system
Staging: add pata_rdc driver
Staging: remove obsolete serqt_usb driver
Staging: serqt_usb2 add the driver to the build
...
Diffstat (limited to 'drivers/staging/rt2870/common/rtusb_bulk.c')
-rw-r--r-- | drivers/staging/rt2870/common/rtusb_bulk.c | 775 |
1 files changed, 14 insertions, 761 deletions
diff --git a/drivers/staging/rt2870/common/rtusb_bulk.c b/drivers/staging/rt2870/common/rtusb_bulk.c index c46d9166ccf..7ae3e959613 100644 --- a/drivers/staging/rt2870/common/rtusb_bulk.c +++ b/drivers/staging/rt2870/common/rtusb_bulk.c @@ -52,11 +52,7 @@ void RTUSB_FILL_BULK_URB (struct urb *pUrb, void *pContext) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) usb_fill_bulk_urb(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, (usb_complete_t)Complete, pContext); -#else - FILL_BULK_URB(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, Complete, pContext); -#endif } @@ -95,14 +91,12 @@ VOID RTUSBInitTxDesc( Func, pTxContext); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) if (pTxContext->bAggregatible) pUrb->transfer_dma = (pTxContext->data_dma + TX_BUFFER_NORMSIZE + 2); else pUrb->transfer_dma = pTxContext->data_dma; pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -#endif } @@ -135,10 +129,8 @@ VOID RTUSBInitHTTxDesc( Func, pTxContext); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) pUrb->transfer_dma = (pTxContext->data_dma + pTxContext->NextBulkOutPosition); pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -#endif } @@ -168,10 +160,8 @@ VOID RTUSBInitRxDesc( (usb_complete_t)RTUSBBulkRxComplete, (void *)pRxContext); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) pUrb->transfer_dma = pRxContext->data_dma + pAd->NextRxBulkInPosition; pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -#endif } @@ -327,6 +317,7 @@ VOID RTUSBBulkOutDataPacket( break; } + //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA) if (pTxInfo->QSEL != FIFO_EDCA) { printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL); @@ -359,7 +350,7 @@ VOID RTUSBBulkOutDataPacket( pLastTxInfo = pTxInfo; // Make sure we use EDCA QUEUE. - pTxInfo->QSEL = FIFO_EDCA; + pTxInfo->QSEL = FIFO_EDCA; //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA) ThisBulkSize += (pTxInfo->USBDMATxPktLen+4); TmpBulkEndPos += (pTxInfo->USBDMATxPktLen+4); @@ -375,31 +366,14 @@ VOID RTUSBBulkOutDataPacket( bTxQLastRound = TRUE; pHTTXContext->ENextBulkOutPosition = 8; - #ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO); - RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI); - #endif // RT_BIG_ENDIAN // - break; } - -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO); - RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI); -#endif // RT_BIG_ENDIAN // - }while (TRUE); // adjust the pTxInfo->USBDMANextVLD value of last pTxInfo. if (pLastTxInfo) { -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // pLastTxInfo->USBDMANextVLD = 0; -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // } /* @@ -475,115 +449,6 @@ VOID RTUSBBulkOutDataPacket( VOID RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs) { -#if 0 // sample, IRQ LOCK - PRTMP_ADAPTER pAd; - POS_COOKIE pObj; - PHT_TX_CONTEXT pHTTXContext; - UCHAR BulkOutPipeId; - NTSTATUS Status; - unsigned long IrqFlags; - - DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutDataPacketComplete\n")); - - pHTTXContext = (PHT_TX_CONTEXT)pUrb->context; - pAd = pHTTXContext->pAd; - pObj = (POS_COOKIE) pAd->OS_Cookie; - Status = pUrb->status; - - // Store BulkOut PipeId - BulkOutPipeId = pHTTXContext->BulkOutPipeId; - pAd->BulkOutDataOneSecCount++; - - //DBGPRINT(RT_DEBUG_LOUD, ("Done-B(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", BulkOutPipeId, in_interrupt(), pHTTXContext->CurWritePosition, - // pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); - pAd->BulkOutPending[BulkOutPipeId] = FALSE; - pHTTXContext->IRPPending = FALSE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); - - if (Status == USB_ST_NOERROR) - { - pAd->BulkOutComplete++; - - pAd->Counters8023.GoodTransmits++; - //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext); - //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - - - } - else // STATUS_OTHER - { - PUCHAR pBuf; - - pAd->BulkOutCompleteOther++; - - pBuf = &pHTTXContext->TransferBuffer->WirelessPacket[pHTTXContext->NextBulkOutPosition]; - - DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkOutDataPacket failed: ReasonCode=%d!\n", Status)); - DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n", pAd->BulkOutReq, pAd->BulkOutComplete, pAd->BulkOutCompleteOther)); - DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOut Header:%x %x %x %x %x %x %x %x\n", pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7])); - //DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOutCompleteCancel=0x%x, BulkOutCompleteOther=0x%x\n", pAd->BulkOutCompleteCancel, pAd->BulkOutCompleteOther)); - - if (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | - fRTMP_ADAPTER_HALT_IN_PROGRESS | - fRTMP_ADAPTER_NIC_NOT_EXIST | - fRTMP_ADAPTER_BULKOUT_RESET))) - { - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - pAd->bulkResetPipeid = BulkOutPipeId; - } - } - - // - // bInUse = TRUE, means some process are filling TX data, after that must turn on bWaitingBulkOut - // bWaitingBulkOut = TRUE, means the TX data are waiting for bulk out. - // - //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - if ((pHTTXContext->ENextBulkOutPosition != pHTTXContext->CurWritePosition) && - (pHTTXContext->ENextBulkOutPosition != (pHTTXContext->CurWritePosition+8)) && - !RTUSB_TEST_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId))) - { - // Indicate There is data avaliable - RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); - } - //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - - // Always call Bulk routine, even reset bulk. - // The protection of rest bulk should be in BulkOut routine - RTUSBKickBulkOut(pAd); - - - //DBGPRINT(RT_DEBUG_LOUD,("Done-A(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d\n", BulkOutPipeId, in_interrupt(), - // pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); - - switch (BulkOutPipeId) - { - case 0: - pObj->ac0_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->ac0_dma_done_task); - break; - case 1: - pObj->ac1_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->ac1_dma_done_task); - break; - case 2: - pObj->ac2_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->ac2_dma_done_task); - break; - case 3: - pObj->ac3_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->ac3_dma_done_task); - break; - case 4: - pObj->hcca_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->hcca_dma_done_task); - break; - } -#else - -{ PHT_TX_CONTEXT pHTTXContext; PRTMP_ADAPTER pAd; POS_COOKIE pObj; @@ -622,10 +487,6 @@ VOID RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs) break; } } -#endif - - -} /* @@ -667,10 +528,6 @@ VOID RTUSBBulkOutNullFrame( // Clear Null frame bulk flag RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL); -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pNullContext->TransferBuffer, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // - // Init Tx context descriptor RTUSBInitTxDesc(pAd, pNullContext, 0, (usb_complete_t)RTUSBBulkOutNullFrameComplete); @@ -695,9 +552,6 @@ VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs) PRTMP_ADAPTER pAd; PTX_CONTEXT pNullContext; NTSTATUS Status; -#if 0 // sample, IRQ LOCK - unsigned long IrqFlags; -#endif POS_COOKIE pObj; @@ -705,173 +559,10 @@ VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs) pAd = pNullContext->pAd; Status = pUrb->status; -#if 0 // sample, IRQ LOCK - // Reset Null frame context flags - pNullContext->IRPPending = FALSE; - pNullContext->InUse = FALSE; - - if (Status == USB_ST_NOERROR) - { - // Don't worry about the queue is empty or not, this function will check itself - //RTMPUSBDeQueuePacket(pAd, 0); - RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } - else // STATUS_OTHER - { - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) - { - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out Null Frame Failed\n")); - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0); - } - } - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags); - pAd->BulkOutPending[0] = FALSE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags); - - // Always call Bulk routine, even reset bulk. - // The protectioon of rest bulk should be in BulkOut routine - RTUSBKickBulkOut(pAd); -#else - pObj = (POS_COOKIE) pAd->OS_Cookie; pObj->null_frame_complete_task.data = (unsigned long)pUrb; tasklet_hi_schedule(&pObj->null_frame_complete_task); -#endif - -} - -#if 0 // For RT2870, RTS frame not used now, but maybe will use it latter. -/* - ======================================================================== - - Routine Description: - - Arguments: - - Return Value: - - Note: RTS frame use BulkOutPipeId = 0 - - ======================================================================== -*/ -VOID RTUSBBulkOutRTSFrame( - IN PRTMP_ADAPTER pAd) -{ - PTX_CONTEXT pRTSContext = &(pAd->RTSContext); - PURB pUrb; - int ret = 0; - unsigned long IrqFlags; - UCHAR PipeID=0; - - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4)) - PipeID= 3; - else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3)) - PipeID= 2; - else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2)) - PipeID= 1; - else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL)) - PipeID= 0; - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[PipeID], IrqFlags); - if ((pAd->BulkOutPending[PipeID] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)) - { - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[PipeID], IrqFlags); - return; - } - pAd->BulkOutPending[PipeID] = TRUE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[PipeID], IrqFlags); - - // Increase Total transmit byte counter - pAd->RalinkCounters.TransmittedByteCount += pRTSContext->BulkOutSize; - - DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutRTSFrame \n")); - - // Clear RTS frame bulk flag - RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_RTS); - -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pRTSContext->TransferBuffer, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // - - // Init Tx context descriptor - RTUSBInitTxDesc(pAd, pRTSContext, PipeID, (usb_complete_t)RTUSBBulkOutRTSFrameComplete); - pRTSContext->IRPPending = TRUE; - - pUrb = pRTSContext->pUrb; - if((ret = RTUSB_SUBMIT_URB(pUrb))!=0) - { - DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutRTSFrame: Submit Tx URB failed %d\n", ret)); - return; - } - - DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutRTSFrame \n")); - -} - -// RTS frame use BulkOutPipeId = 0 -VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs) -{ - PRTMP_ADAPTER pAd; - PTX_CONTEXT pRTSContext; - NTSTATUS Status; -#if 0 // sample, IRQ LOCK - unsigned long IrqFlags; -#endif - POS_COOKIE pObj; - - DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutRTSFrameComplete\n")); - - pRTSContext = (PTX_CONTEXT)pUrb->context; - pAd = pRTSContext->pAd; - Status = pUrb->status; - -#if 0 // sample, IRQ LOCK - // Reset RTS frame context flags - pRTSContext->IRPPending = FALSE; - pRTSContext->InUse = FALSE; - - if (Status == USB_ST_NOERROR) - { - // Don't worry about the queue is empty or not, this function will check itself - //RTMPUSBDeQueuePacket(pAd, pRTSContext->BulkOutPipeId); - RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } - else // STATUS_OTHER - { - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) - { - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out RTS Frame Failed\n")); - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0); - } - } - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId], IrqFlags); - pAd->BulkOutPending[pRTSContext->BulkOutPipeId] = FALSE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId], IrqFlags); - - // Always call Bulk routine, even reset bulk. - // The protectioon of rest bulk should be in BulkOut routine - RTUSBKickBulkOut(pAd); -#else - - pObj = (POS_COOKIE) pAd->OS_Cookie; - pObj->rts_frame_complete_task.data = (unsigned long)pUrb; - tasklet_hi_schedule(&pObj->rts_frame_complete_task); -#endif - - DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutRTSFrameComplete\n")); - } -#endif /* ======================================================================== @@ -930,37 +621,12 @@ VOID RTUSBBulkOutMLMEPacket( // Clear MLME bulk flag RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME); - - //DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacket\n")); -#if 0 // for debug -{ - printk("MLME-Out, C=%d!, D=%d, F=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx); - - //TODO: Need to remove it when formal release - PTXINFO_STRUC pTxInfo; - - pTxInfo = (PTXINFO_STRUC)pMLMEContext->TransferBuffer; - if (pTxInfo->QSEL != FIFO_EDCA) - { - printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL); - printk("\tMLME_Index=%d!\n", Index); - hex_dump("Wrong QSel Pkt:", (PUCHAR)pMLMEContext->TransferBuffer, pTxInfo->USBDMATxPktLen); - } -} -#endif - -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pMLMEContext->TransferBuffer, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // - // Init Tx context descriptor RTUSBInitTxDesc(pAd, pMLMEContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutMLMEPacketComplete); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) //For mgmt urb buffer, because we use sk_buff, so we need to notify the USB controller do dma mapping. pUrb->transfer_dma = 0; pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP); -#endif pUrb = pMLMEContext->pUrb; if((ret = RTUSB_SUBMIT_URB(pUrb))!=0) @@ -988,11 +654,6 @@ VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs) NTSTATUS Status; POS_COOKIE pObj; int index; -#if 0 // sample, IRQ LOCK - unsigned long IrqFlags; - PNDIS_PACKET pPacket; -#endif - //DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacketComplete\n")); pMLMEContext = (PTX_CONTEXT)pUrb->context; @@ -1001,82 +662,8 @@ VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs) Status = pUrb->status; index = pMLMEContext->SelfIdx; - -#if 0 // sample, IRQ LOCK - ASSERT((pAd->MgmtRing.TxDmaIdx == index)); - //printk("MLME-Done-B: C=%d, D=%d, F=%d, Self=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx, pMLMEContext->SelfIdx); - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags); - - - if (Status != USB_ST_NOERROR) - { - //Bulk-Out fail status handle - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) - { - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out MLME Failed, Status=%d!\n", Status)); - // TODO: How to handle about the MLMEBulkOut failed issue. Need to resend the mgmt pkt? - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG); - } - } - pAd->BulkOutPending[MGMTPIPEIDX] = FALSE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags); - - RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags); - // Reset MLME context flags - pMLMEContext->IRPPending = FALSE; - pMLMEContext->InUse = FALSE; - pMLMEContext->bWaitingBulkOut = FALSE; - pMLMEContext->BulkOutSize = 0; - - pPacket = pAd->MgmtRing.Cell[index].pNdisPacket; - pAd->MgmtRing.Cell[index].pNdisPacket = NULL; - - // Increase MgmtRing Index - INC_RING_INDEX(pAd->MgmtRing.TxDmaIdx, MGMT_RING_SIZE); - pAd->MgmtRing.TxSwFreeIdx++; - - RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags); - - // No-matter success or fail, we free the mgmt packet. - if (pPacket) - RTMPFreeNdisPacket(pAd, pPacket); - -#if 0 - //Bulk-Out fail status handle - if (Status != USB_ST_NOERROR) - { - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) - { - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out MLME Failed, Status=%d!\n", Status)); - // TODO: How to handle about the MLMEBulkOut failed issue. Need to reset the endpoint? - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG); - } - } -#endif - - //printk("MLME-Done-A: C=%d, D=%d, F=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx); - - pObj->mgmt_dma_done_task.data = (unsigned long)pAd; - tasklet_hi_schedule(&pObj->mgmt_dma_done_task); - - //DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutMLMEPacketComplete\n")); -// printk("<---RTUSBBulkOutMLMEPacketComplete, Cpu=%d, Dma=%d, SwIdx=%d!\n", -// pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx); - -#else - pObj->mgmt_dma_done_task.data = (unsigned long)pUrb; tasklet_hi_schedule(&pObj->mgmt_dma_done_task); -#endif } @@ -1116,10 +703,6 @@ VOID RTUSBBulkOutPsPoll( // Clear PS-Poll bulk flag RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL); -#ifdef RT_BIG_ENDIAN - RTMPDescriptorEndianChange((PUCHAR)pPsPollContext->TransferBuffer, TYPE_TXINFO); -#endif // RT_BIG_ENDIAN // - // Init Tx context descriptor RTUSBInitTxDesc(pAd, pPsPollContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutPsPollComplete); @@ -1144,9 +727,6 @@ VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb,struct pt_regs *pt_regs) PRTMP_ADAPTER pAd; PTX_CONTEXT pPsPollContext; NTSTATUS Status; -#if 0 // sample, IRQ LOCK - unsigned long IrqFlags; -#endif POS_COOKIE pObj; @@ -1154,255 +734,11 @@ VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb,struct pt_regs *pt_regs) pAd = pPsPollContext->pAd; Status = pUrb->status; -#if 0 // sample, IRQ LOCK - // Reset PsPoll context flags - pPsPollContext->IRPPending = FALSE; - pPsPollContext->InUse = FALSE; - - if (Status == USB_ST_NOERROR) - { - // Don't worry about the queue is empty or not, this function will check itself - RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } - else // STATUS_OTHER - { - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) - { - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out PSPoll Failed\n")); - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET); - RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0); - } - } - - RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags); - pAd->BulkOutPending[0] = FALSE; - RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags); - - // Always call Bulk routine, even reset bulk. - // The protectioon of rest bulk should be in BulkOut routine - RTUSBKickBulkOut(pAd); -#else - pObj = (POS_COOKIE) pAd->OS_Cookie; pObj->pspoll_frame_complete_task.data = (unsigned long)pUrb; tasklet_hi_schedule(&pObj->pspoll_frame_complete_task); -#endif -} - - -#if 0 -/* - ======================================================================== - - Routine Description: - USB_RxPacket initializes a URB and uses the Rx IRP to submit it - to USB. It checks if an Rx Descriptor is available and passes the - the coresponding buffer to be filled. If no descriptor is available - fails the request. When setting the completion routine we pass our - Adapter Object as Context. - - Arguments: - - Return Value: - TRUE found matched tuple cache - FALSE no matched found - - Note: - - ======================================================================== -*/ -VOID RTUSBBulkReceive( - IN PRTMP_ADAPTER pAd) -{ - PRX_CONTEXT pRxContext; - PURB pUrb; - int ret = 0; - unsigned long IrqFlags; - - - /* device had been closed */ - if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)) - return; - - RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags); - - // Last is time point between 2 separate URB. - if (pAd->NextRxBulkInPosition == 0) - { - //pAd->NextRxBulkInIndex = (pAd->NextRxBulkInIndex + 1) % (RX_RING_SIZE); - INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE); - } - else if ((pAd->NextRxBulkInPosition&0x1ff) != 0) - { - //pAd->NextRxBulkInIndex = (pAd->NextRxBulkInIndex + 1) % (RX_RING_SIZE); - INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE); - DBGPRINT_RAW(RT_DEBUG_TRACE, ("pAd->NextRxBulkInPosition = 0x%lx. End of URB.\n", pAd->NextRxBulkInPosition )); - pAd->NextRxBulkInPosition = 0; - } - - if (pAd->NextRxBulkInPosition == MAX_RXBULK_SIZE) - pAd->NextRxBulkInPosition = 0; - - pRxContext = &(pAd->RxContext[pAd->NextRxBulkInIndex]); - - // TODO: Why need to check if pRxContext->InUsed == TRUE? - //if ((pRxContext->InUse == TRUE) || (pRxContext->Readable == TRUE)) - if ((pRxContext->InUse == FALSE) && (pRxContext->Readable == TRUE)) - { - DBGPRINT_RAW(RT_DEBUG_TRACE, ("pRxContext[%d] InUse = %d.pRxContext->Readable = %d. Return.\n", pAd->NextRxBulkInIndex,pRxContext->InUse, pRxContext->Readable )); - RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); - - // read RxContext, Since not -#ifdef CONFIG_STA_SUPPORT - STARxDoneInterruptHandle(pAd, TRUE); -#endif // CONFIG_STA_SUPPORT // - - //return; - } - pRxContext->InUse = TRUE; - pRxContext->IRPPending= TRUE; - - RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); - - // Init Rx context descriptor - NdisZeroMemory(pRxContext->TransferBuffer, BUFFER_SIZE); - RTUSBInitRxDesc(pAd, pRxContext); - - pUrb = pRxContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb))!=0) - { - DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkReceive: Submit Rx URB failed %d\n", ret)); - return; - } - else // success - { - NdisInterlockedIncrement(&pAd->PendingRx); - pAd->BulkInReq++; - } - - // read RxContext, Since not -#ifdef CONFIG_STA_SUPPORT - STARxDoneInterruptHandle(pAd, FALSE); -#endif // CONFIG_STA_SUPPORT // -} - -/* - ======================================================================== - - Routine Description: - This routine process Rx Irp and call rx complete function. - - Arguments: - DeviceObject Pointer to the device object for next lower - device. DeviceObject passed in here belongs to - the next lower driver in the stack because we - were invoked via IoCallDriver in USB_RxPacket - AND it is not OUR device object - Irp Ptr to completed IRP - Context Ptr to our Adapter object (context specified - in IoSetCompletionRoutine - - Return Value: - Always returns STATUS_MORE_PROCESSING_REQUIRED - - Note: - Always returns STATUS_MORE_PROCESSING_REQUIRED - ======================================================================== -*/ -VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs) -{ -#if 0 - PRX_CONTEXT pRxContext; - PRTMP_ADAPTER pAd; - NTSTATUS Status; -// POS_COOKIE pObj; - - pRxContext = (PRX_CONTEXT)pUrb->context; - pAd = pRxContext->pAd; -// pObj = (POS_COOKIE) pAd->OS_Cookie; - - - Status = pUrb->status; - //pRxContext->pIrp = NULL; - - pRxContext->InUse = FALSE; - pRxContext->IRPPending = FALSE; - - if (Status == USB_ST_NOERROR) - { - pAd->BulkInComplete++; - pRxContext->Readable = TRUE; - pAd->NextRxBulkInPosition = 0; - - } - else // STATUS_OTHER - { - pAd->BulkInCompleteFail++; - // Still read this packet although it may comtain wrong bytes. - pRxContext->Readable = FALSE; - // Parsing all packets. because after reset, the index will reset to all zero. - - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) - { - - DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk In Failed. Status = %d\n", Status)); - DBGPRINT_RAW(RT_DEBUG_ERROR, ("==>NextRxBulkInIndex=0x%x, NextRxBulkInReadIndex=0x%x, TransferBufferLength= 0x%x\n", - pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex, pRxContext->pUrb->actual_length)); - - RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET); - RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, NULL, 0); - } - //pUrb = NULL; - } - - if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET)) && -// (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && - (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) - { - RTUSBBulkReceive(pAd); -#if 0 -#if 1 - STARxDoneInterruptHandle(pAd, FALSE); -#else - pObj->rx_bh.data = (unsigned long)pUrb; - tasklet_schedule(&pObj->rx_bh); -#endif -#endif - } - - // Call RxPacket to process packet and return the status - NdisInterlockedDecrement(&pAd->PendingRx); -#else - - - // use a receive tasklet to handle received packets; - // or sometimes hardware IRQ will be disabled here, so we can not - // use spin_lock_bh()/spin_unlock_bh() after IRQ is disabled. :< - PRX_CONTEXT pRxContext; - PRTMP_ADAPTER pAd; - POS_COOKIE pObj; - - - pRxContext = (PRX_CONTEXT)pUrb->context; - pAd = pRxContext->pAd; - pObj = (POS_COOKIE) pAd->OS_Cookie; - - pObj->rx_done_task.data = (unsigned long)pUrb; - tasklet_hi_schedule(&pObj->rx_done_task); -#endif } -#else - VOID DoBulkIn(IN RTMP_ADAPTER *pAd) { PRX_CONTEXT pRxContext; @@ -1441,14 +777,6 @@ VOID DoBulkIn(IN RTMP_ADAPTER *pAd) } else { // success -#if 0 - RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags); - pRxContext->IRPPending = TRUE; - //NdisInterlockedIncrement(&pAd->PendingRx); - pAd->PendingRx++; - RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); - pAd->BulkInReq++; -#endif ASSERT((pRxContext->InUse == pRxContext->IRPPending)); //printk("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex); } @@ -1508,10 +836,7 @@ VOID RTUSBBulkReceive( RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); // read RxContext, Since not -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - STARxDoneInterruptHandle(pAd, TRUE); -#endif // CONFIG_STA_SUPPORT // + STARxDoneInterruptHandle(pAd, TRUE); // Finish to handle this bulkIn buffer. RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags); @@ -1579,8 +904,6 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs) } -#endif - /* @@ -1601,51 +924,8 @@ VOID RTUSBKickBulkOut( { // BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged. if (!RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX) -#ifdef RALINK_ATE - && !(ATE_ON(pAd)) -#endif // RALINK_ATE // ) { -#if 0 // not used now in RT28xx, but may used latter. - // 1. Data Fragment has highest priority - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG)) - { - if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || - (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) - )) - { - RTUSBBulkOutDataPacket(pAd, 0, pAd->NextBulkOutIndex[0]); - } - } - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_2)) - { - if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || - (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) - )) - { - RTUSBBulkOutDataPacket(pAd, 1, pAd->NextBulkOutIndex[1]); - } - } - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_3)) - { - if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || - (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) - )) - { - RTUSBBulkOutDataPacket(pAd, 2, pAd->NextBulkOutIndex[2]); - } - } - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_4)) - { - if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || - (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) - )) - { - RTUSBBulkOutDataPacket(pAd, 3, pAd->NextBulkOutIndex[3]); - } - } -#endif - // 2. PS-Poll frame is next if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL)) { @@ -1696,6 +976,17 @@ VOID RTUSBKickBulkOut( RTUSBBulkOutDataPacket(pAd, 3, pAd->NextBulkOutIndex[3]); } } +#ifdef RT30xx + //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA) + if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_5)) + { + if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || + (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) + )) + { + } + } +#endif // 7. Null frame is the last else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL)) @@ -1712,18 +1003,6 @@ VOID RTUSBKickBulkOut( } } -#ifdef RALINK_ATE - /* If the mode is in ATE mode. */ - else if((ATE_ON(pAd)) && - !RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX))// PETER : watch out ! - { - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE)) - { - ATE_RTUSBBulkOutDataPacket(pAd, 0); - } - } -#endif // RALINK_ATE // - } /* @@ -1778,24 +1057,6 @@ VOID RTUSBCleanUpMLMEBulkOutQueue( IN PRTMP_ADAPTER pAd) { DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpMLMEBulkOutQueue\n")); - -#if 0 // Do nothing! - NdisAcquireSpinLock(&pAd->MLMEBulkOutLock); - while (pAd->PrioRingTxCnt > 0) - { - pAd->MLMEContext[pAd->PrioRingFirstIndex].InUse = FALSE; - - pAd->PrioRingFirstIndex++; - if (pAd->PrioRingFirstIndex >= MGMT_RING_SIZE) - { - pAd->PrioRingFirstIndex = 0; - } - - pAd->PrioRingTxCnt--; - } - NdisReleaseSpinLock(&pAd->MLMEBulkOutLock); -#endif - DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpMLMEBulkOutQueue\n")); } @@ -1906,14 +1167,6 @@ VOID RTUSBCancelPendingBulkOutIRP( RTMPusecDelay(200); } -#ifdef RALINK_ATE - pHTTXContext->bCopySavePad = 0; - pHTTXContext->CurWritePosition = 0; - pHTTXContext->CurWriteRealPos = 0; - pHTTXContext->bCurWriting = FALSE; - pHTTXContext->NextBulkOutPosition = 0; - pHTTXContext->ENextBulkOutPosition = 0; -#endif // RALINK_ATE // pAd->BulkOutPending[Idx] = FALSE; } |