diff options
Diffstat (limited to 'drivers/staging/rt2870/common/rtusb_data.c')
-rw-r--r-- | drivers/staging/rt2870/common/rtusb_data.c | 173 |
1 files changed, 82 insertions, 91 deletions
diff --git a/drivers/staging/rt2870/common/rtusb_data.c b/drivers/staging/rt2870/common/rtusb_data.c index 807b32a..d662f7f 100644 --- a/drivers/staging/rt2870/common/rtusb_data.c +++ b/drivers/staging/rt2870/common/rtusb_data.c @@ -39,40 +39,33 @@ #ifdef RTMP_MAC_USB - #include "../rt_config.h" -extern UCHAR Phy11BGNextRateUpward[]; // defined in mlme.c -extern UCHAR EpToQueue[]; +extern UCHAR Phy11BGNextRateUpward[]; // defined in mlme.c +extern UCHAR EpToQueue[]; -VOID REPORT_AMSDU_FRAMES_TO_LLC( - IN PRTMP_ADAPTER pAd, - IN PUCHAR pData, - IN ULONG DataSize) +VOID REPORT_AMSDU_FRAMES_TO_LLC(IN PRTMP_ADAPTER pAd, + IN PUCHAR pData, IN ULONG DataSize) { - PNDIS_PACKET pPacket; - UINT nMSDU; - struct sk_buff *pSkb; + PNDIS_PACKET pPacket; + UINT nMSDU; + struct sk_buff *pSkb; nMSDU = 0; /* allocate a rx packet */ pSkb = dev_alloc_skb(RX_BUFFER_AGGRESIZE); - pPacket = (PNDIS_PACKET)OSPKT_TO_RTPKT(pSkb); - if (pSkb) - { + pPacket = (PNDIS_PACKET) OSPKT_TO_RTPKT(pSkb); + if (pSkb) { /* convert 802.11 to 802.3 packet */ pSkb->dev = get_netdev_from_bssid(pAd, BSS0); RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS); deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize); - } - else - { - DBGPRINT(RT_DEBUG_ERROR,("Can't allocate skb\n")); + } else { + DBGPRINT(RT_DEBUG_ERROR, ("Can't allocate skb\n")); } } - /* ======================================================================== @@ -92,50 +85,53 @@ VOID REPORT_AMSDU_FRAMES_TO_LLC( ======================================================================== */ -NDIS_STATUS RTUSBFreeDescriptorRequest( - IN PRTMP_ADAPTER pAd, - IN UCHAR BulkOutPipeId, - IN UINT32 NumberRequired) +NDIS_STATUS RTUSBFreeDescriptorRequest(IN PRTMP_ADAPTER pAd, + IN UCHAR BulkOutPipeId, + IN UINT32 NumberRequired) { -// UCHAR FreeNumber = 0; -// UINT Index; - NDIS_STATUS Status = NDIS_STATUS_FAILURE; - unsigned long IrqFlags; - HT_TX_CONTEXT *pHTTXContext; - +// UCHAR FreeNumber = 0; +// UINT Index; + NDIS_STATUS Status = NDIS_STATUS_FAILURE; + unsigned long IrqFlags; + HT_TX_CONTEXT *pHTTXContext; pHTTXContext = &pAd->TxContext[BulkOutPipeId]; RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition) && ((pHTTXContext->CurWritePosition + NumberRequired + LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition)) - { - - RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); - } - else if ((pHTTXContext->CurWritePosition == 8) && (pHTTXContext->NextBulkOutPosition < (NumberRequired + LOCAL_TXBUF_SIZE))) - { - RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); - } - else if (pHTTXContext->bCurWriting == TRUE) - { - DBGPRINT(RT_DEBUG_TRACE,("RTUSBFreeD c3 --> QueIdx=%d, CWPos=%ld, NBOutPos=%ld!\n", BulkOutPipeId, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition)); - RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); - } - else - { + if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition) + && + ((pHTTXContext->CurWritePosition + NumberRequired + + LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition)) { + + RTUSB_SET_BULK_FLAG(pAd, + (fRTUSB_BULK_OUT_DATA_NORMAL << + BulkOutPipeId)); + } else if ((pHTTXContext->CurWritePosition == 8) + && (pHTTXContext->NextBulkOutPosition < + (NumberRequired + LOCAL_TXBUF_SIZE))) { + RTUSB_SET_BULK_FLAG(pAd, + (fRTUSB_BULK_OUT_DATA_NORMAL << + BulkOutPipeId)); + } else if (pHTTXContext->bCurWriting == TRUE) { + DBGPRINT(RT_DEBUG_TRACE, + ("RTUSBFreeD c3 --> QueIdx=%d, CWPos=%ld, NBOutPos=%ld!\n", + BulkOutPipeId, pHTTXContext->CurWritePosition, + pHTTXContext->NextBulkOutPosition)); + RTUSB_SET_BULK_FLAG(pAd, + (fRTUSB_BULK_OUT_DATA_NORMAL << + BulkOutPipeId)); + } else { Status = NDIS_STATUS_SUCCESS; } RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - return (Status); } -NDIS_STATUS RTUSBFreeDescriptorRelease( - IN RTMP_ADAPTER *pAd, - IN UCHAR BulkOutPipeId) +NDIS_STATUS RTUSBFreeDescriptorRelease(IN RTMP_ADAPTER * pAd, + IN UCHAR BulkOutPipeId) { - unsigned long IrqFlags; - HT_TX_CONTEXT *pHTTXContext; + unsigned long IrqFlags; + HT_TX_CONTEXT *pHTTXContext; pHTTXContext = &pAd->TxContext[BulkOutPipeId]; RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); @@ -145,28 +141,32 @@ NDIS_STATUS RTUSBFreeDescriptorRelease( return (NDIS_STATUS_SUCCESS); } - -BOOLEAN RTUSBNeedQueueBackForAgg( - IN RTMP_ADAPTER *pAd, - IN UCHAR BulkOutPipeId) +BOOLEAN RTUSBNeedQueueBackForAgg(IN RTMP_ADAPTER * pAd, IN UCHAR BulkOutPipeId) { - unsigned long IrqFlags; - HT_TX_CONTEXT *pHTTXContext; - BOOLEAN needQueBack = FALSE; + unsigned long IrqFlags; + HT_TX_CONTEXT *pHTTXContext; + BOOLEAN needQueBack = FALSE; pHTTXContext = &pAd->TxContext[BulkOutPipeId]; RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - if ((pHTTXContext->IRPPending == TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */) - { - if ((pHTTXContext->CurWritePosition < pHTTXContext->ENextBulkOutPosition) && - (((pHTTXContext->ENextBulkOutPosition+MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT) || (pHTTXContext->CurWritePosition > MAX_AGGREGATION_SIZE))) - { + if ((pHTTXContext->IRPPending == + TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */ ) { + if ((pHTTXContext->CurWritePosition < + pHTTXContext->ENextBulkOutPosition) + && + (((pHTTXContext->ENextBulkOutPosition + + MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT) + || (pHTTXContext->CurWritePosition > + MAX_AGGREGATION_SIZE))) { needQueBack = TRUE; - } - else if ((pHTTXContext->CurWritePosition > pHTTXContext->ENextBulkOutPosition) && - ((pHTTXContext->ENextBulkOutPosition + MAX_AGGREGATION_SIZE) < pHTTXContext->CurWritePosition)) - { + } else + if ((pHTTXContext->CurWritePosition > + pHTTXContext->ENextBulkOutPosition) + && + ((pHTTXContext->ENextBulkOutPosition + + MAX_AGGREGATION_SIZE) < + pHTTXContext->CurWritePosition)) { needQueBack = TRUE; } } @@ -176,7 +176,6 @@ BOOLEAN RTUSBNeedQueueBackForAgg( } - /* ======================================================================== @@ -192,21 +191,17 @@ BOOLEAN RTUSBNeedQueueBackForAgg( ======================================================================== */ -VOID RTUSBRejectPendingPackets( - IN PRTMP_ADAPTER pAd) +VOID RTUSBRejectPendingPackets(IN PRTMP_ADAPTER pAd) { - UCHAR Index; - PQUEUE_ENTRY pEntry; - PNDIS_PACKET pPacket; - PQUEUE_HEADER pQueue; + UCHAR Index; + PQUEUE_ENTRY pEntry; + PNDIS_PACKET pPacket; + PQUEUE_HEADER pQueue; - - for (Index = 0; Index < 4; Index++) - { + for (Index = 0; Index < 4; Index++) { NdisAcquireSpinLock(&pAd->TxSwQueueLock[Index]); - while (pAd->TxSwQueue[Index].Head != NULL) - { - pQueue = (PQUEUE_HEADER) &(pAd->TxSwQueue[Index]); + while (pAd->TxSwQueue[Index].Head != NULL) { + pQueue = (PQUEUE_HEADER) & (pAd->TxSwQueue[Index]); pEntry = RemoveHeadQueue(pQueue); pPacket = QUEUE_ENTRY_TO_PACKET(pEntry); RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE); @@ -217,7 +212,6 @@ VOID RTUSBRejectPendingPackets( } - /* ======================================================================== @@ -246,21 +240,18 @@ VOID RTUSBRejectPendingPackets( ======================================================================== */ - -VOID RTMPWriteTxInfo( - IN PRTMP_ADAPTER pAd, - IN PTXINFO_STRUC pTxInfo, - IN USHORT USBDMApktLen, - IN BOOLEAN bWiv, - IN UCHAR QueueSel, - IN UCHAR NextValid, - IN UCHAR TxBurst) +VOID RTMPWriteTxInfo(IN PRTMP_ADAPTER pAd, + IN PTXINFO_STRUC pTxInfo, + IN USHORT USBDMApktLen, + IN BOOLEAN bWiv, + IN UCHAR QueueSel, IN UCHAR NextValid, IN UCHAR TxBurst) { pTxInfo->USBDMATxPktLen = USBDMApktLen; pTxInfo->QSEL = QueueSel; if (QueueSel != FIFO_EDCA) - DBGPRINT(RT_DEBUG_TRACE, ("====> QueueSel != FIFO_EDCA<============\n")); - pTxInfo->USBDMANextVLD = FALSE; //NextValid; // Need to check with Jan about this. + DBGPRINT(RT_DEBUG_TRACE, + ("====> QueueSel != FIFO_EDCA<============\n")); + pTxInfo->USBDMANextVLD = FALSE; //NextValid; // Need to check with Jan about this. pTxInfo->USBDMATxburst = TxBurst; pTxInfo->WIV = bWiv; pTxInfo->SwUseLastRound = 0; |