Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *************************************************************************
  3  * Ralink Tech Inc.
  4  * 5F., No.36, Taiyuan St., Jhubei City,
  5  * Hsinchu County 302,
  6  * Taiwan, R.O.C.
  7  *
  8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  9  *
 10  * This program is free software; you can redistribute it and/or modify  *
 11  * it under the terms of the GNU General Public License as published by  *
 12  * the Free Software Foundation; either version 2 of the License, or     *
 13  * (at your option) any later version.                                   *
 14  *                                                                       *
 15  * This program is distributed in the hope that it will be useful,       *
 16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 18  * GNU General Public License for more details.                          *
 19  *                                                                       *
 20  * You should have received a copy of the GNU General Public License     *
 21  * along with this program; if not, write to the                         *
 22  * Free Software Foundation, Inc.,                                       *
 23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 24  *                                                                       *
 25  *************************************************************************
 26 
 27         Module Name:
 28         rtusb_data.c
 29 
 30         Abstract:
 31         Ralink USB driver Tx/Rx functions.
 32 
 33         Revision History:
 34         Who         When          What
 35         --------    ----------    ----------------------------------------------
 36         Jan            03-25-2006    created
 37 
 38 */
 39 #include "../rt_config.h"
 40 
 41 extern  UCHAR Phy11BGNextRateUpward[]; // defined in mlme.c
 42 extern UCHAR    EpToQueue[];
 43 
 44 VOID REPORT_AMSDU_FRAMES_TO_LLC(
 45         IN      PRTMP_ADAPTER   pAd,
 46         IN      PUCHAR                  pData,
 47         IN      ULONG                   DataSize)
 48 {
 49         PNDIS_PACKET    pPacket;
 50         UINT                    nMSDU;
 51         struct                  sk_buff *pSkb;
 52 
 53         nMSDU = 0;
 54         /* allocate a rx packet */
 55         pSkb = dev_alloc_skb(RX_BUFFER_AGGRESIZE);
 56         pPacket = (PNDIS_PACKET)OSPKT_TO_RTPKT(pSkb);
 57         if (pSkb)
 58         {
 59 
 60                 /* convert 802.11 to 802.3 packet */
 61                 pSkb->dev = get_netdev_from_bssid(pAd, BSS0);
 62                 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
 63                 deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
 64         }
 65         else
 66         {
 67                 DBGPRINT(RT_DEBUG_ERROR,("Can't allocate skb\n"));
 68         }
 69 }
 70 
 71 NDIS_STATUS     RTUSBFreeDescriptorRequest(
 72         IN      PRTMP_ADAPTER   pAd,
 73         IN      UCHAR                   BulkOutPipeId,
 74         IN      UINT32                  NumberRequired)
 75 {
 76 //      UCHAR                   FreeNumber = 0;
 77 //      UINT                    Index;
 78         NDIS_STATUS             Status = NDIS_STATUS_FAILURE;
 79         unsigned long   IrqFlags;
 80         HT_TX_CONTEXT   *pHTTXContext;
 81 
 82 
 83         pHTTXContext = &pAd->TxContext[BulkOutPipeId];
 84         RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
 85         if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition) && ((pHTTXContext->CurWritePosition + NumberRequired + LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition))
 86         {
 87 
 88                 RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
 89         }
 90         else if ((pHTTXContext->CurWritePosition == 8) && (pHTTXContext->NextBulkOutPosition < (NumberRequired + LOCAL_TXBUF_SIZE)))
 91         {
 92                 RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
 93         }
 94         else if (pHTTXContext->bCurWriting == TRUE)
 95         {
 96                 DBGPRINT(RT_DEBUG_TRACE,("RTUSBFreeD c3 --> QueIdx=%d, CWPos=%ld, NBOutPos=%ld!\n", BulkOutPipeId, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition));
 97                 RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
 98         }
 99         else
100         {
101                 Status = NDIS_STATUS_SUCCESS;
102         }
103         RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
104 
105 
106         return (Status);
107 }
108 
109 NDIS_STATUS RTUSBFreeDescriptorRelease(
110         IN RTMP_ADAPTER *pAd,
111         IN UCHAR                BulkOutPipeId)
112 {
113         unsigned long   IrqFlags;
114         HT_TX_CONTEXT   *pHTTXContext;
115 
116         pHTTXContext = &pAd->TxContext[BulkOutPipeId];
117         RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
118         pHTTXContext->bCurWriting = FALSE;
119         RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
120 
121         return (NDIS_STATUS_SUCCESS);
122 }
123 
124 
125 BOOLEAN RTUSBNeedQueueBackForAgg(
126         IN RTMP_ADAPTER *pAd,
127         IN UCHAR                BulkOutPipeId)
128 {
129         unsigned long   IrqFlags;
130         HT_TX_CONTEXT   *pHTTXContext;
131         BOOLEAN                 needQueBack = FALSE;
132 
133         pHTTXContext = &pAd->TxContext[BulkOutPipeId];
134 
135         RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
136         if ((pHTTXContext->IRPPending == TRUE)  /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */)
137         {
138                 if ((pHTTXContext->CurWritePosition < pHTTXContext->ENextBulkOutPosition) &&
139                         (((pHTTXContext->ENextBulkOutPosition+MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT) || (pHTTXContext->CurWritePosition > MAX_AGGREGATION_SIZE)))
140                 {
141                         needQueBack = TRUE;
142                 }
143                 else if ((pHTTXContext->CurWritePosition > pHTTXContext->ENextBulkOutPosition) &&
144                                  ((pHTTXContext->ENextBulkOutPosition + MAX_AGGREGATION_SIZE) < pHTTXContext->CurWritePosition))
145                 {
146                         needQueBack = TRUE;
147                 }
148         }
149         RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
150 
151         return needQueBack;
152 
153 }
154 
155 
156 /*
157         ========================================================================
158 
159         Routine Description:
160 
161         Arguments:
162 
163         Return Value:
164 
165         IRQL =
166 
167         Note:
168 
169         ========================================================================
170 */
171 VOID    RTUSBRejectPendingPackets(
172         IN      PRTMP_ADAPTER   pAd)
173 {
174         UCHAR                   Index;
175         PQUEUE_ENTRY    pEntry;
176         PNDIS_PACKET    pPacket;
177         PQUEUE_HEADER   pQueue;
178 
179 
180         for (Index = 0; Index < 4; Index++)
181         {
182                 NdisAcquireSpinLock(&pAd->TxSwQueueLock[Index]);
183                 while (pAd->TxSwQueue[Index].Head != NULL)
184                 {
185                         pQueue = (PQUEUE_HEADER) &(pAd->TxSwQueue[Index]);
186                         pEntry = RemoveHeadQueue(pQueue);
187                         pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
188                         RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
189                 }
190                 NdisReleaseSpinLock(&pAd->TxSwQueueLock[Index]);
191 
192         }
193 
194 }
195 
196 VOID RTMPWriteTxInfo(
197         IN      PRTMP_ADAPTER   pAd,
198         IN      PTXINFO_STRUC   pTxInfo,
199         IN        USHORT                USBDMApktLen,
200         IN        BOOLEAN               bWiv,
201         IN        UCHAR                 QueueSel,
202         IN        UCHAR                 NextValid,
203         IN        UCHAR                 TxBurst)
204 {
205         pTxInfo->USBDMATxPktLen = USBDMApktLen;
206         pTxInfo->QSEL = QueueSel;
207         if (QueueSel != FIFO_EDCA)
208                 DBGPRINT(RT_DEBUG_TRACE, ("====> QueueSel != FIFO_EDCA<============\n"));
209         pTxInfo->USBDMANextVLD = FALSE; //NextValid;  // Need to check with Jan about this.
210         pTxInfo->USBDMATxburst = TxBurst;
211         pTxInfo->WIV = bWiv;
212         pTxInfo->SwUseLastRound = 0;
213         pTxInfo->rsv = 0;
214         pTxInfo->rsv2 = 0;
215 }
216 
217 
  This page was automatically generated by the LXR engine.