0
|
1 |
/*
|
|
2 |
* TIWhaTxRx.cpp
|
|
3 |
*
|
|
4 |
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* This program and the accompanying materials are made available under the
|
|
8 |
* terms of the Eclipse Public License v1.0 or BSD License which accompanies
|
|
9 |
* this distribution. The Eclipse Public License is available at
|
|
10 |
* http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.
|
|
11 |
*
|
|
12 |
* Redistribution and use in source and binary forms, with or without
|
|
13 |
* modification, are permitted provided that the following conditions
|
|
14 |
* are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in
|
|
20 |
* the documentation and/or other materials provided with the
|
|
21 |
* distribution.
|
|
22 |
* * Neither the name Texas Instruments nor the names of its
|
|
23 |
* contributors may be used to endorse or promote products derived
|
|
24 |
* from this software without specific prior written permission.
|
|
25 |
*
|
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37 |
*/
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
/** \file TIWhaTxRx.cpp
|
|
43 |
* \brief Control the data path from UMAC and back to UMAC
|
|
44 |
*
|
|
45 |
* \see
|
|
46 |
*/
|
|
47 |
|
|
48 |
#include "TIWha.h"
|
|
49 |
|
|
50 |
/*******************************************************************************
|
|
51 |
* stuff for C file linking. *
|
|
52 |
*******************************************************************************/
|
|
53 |
|
|
54 |
extern "C"
|
|
55 |
{
|
|
56 |
|
|
57 |
#include "tidef.h"
|
|
58 |
#include "report.h"
|
|
59 |
#include "timer.h"
|
|
60 |
#include "TWDriver.h"
|
|
61 |
#include "version.h"
|
|
62 |
#include "osApi.h"
|
|
63 |
#include "context.h"
|
|
64 |
#include "BusDrv.h"
|
|
65 |
#include "public_types.h"
|
|
66 |
#define __FILE_ID__ FILE_ID_147
|
|
67 |
}
|
|
68 |
|
|
69 |
static const TI_UINT8 WMEQosAcToTid[MAX_NUM_OF_AC] = { 0, 2, 4, 6 };
|
|
70 |
|
|
71 |
#define WORD_SIZE 4
|
|
72 |
#define WORD_ALIGN_MASK 0xFFFC
|
|
73 |
#define GET_EXTRA_BYTES(status) ( (status & 0xc0) >> 6)
|
|
74 |
#define KEY_GEM_TYPE 4
|
|
75 |
#define QOS_PADDING_SIZE 4
|
|
76 |
#define QOS_SHIFT_SIZE 2
|
|
77 |
|
|
78 |
|
|
79 |
/********************************************************************************
|
|
80 |
* *
|
|
81 |
* MACROS and INLINE FUNCTIONS *
|
|
82 |
* *
|
|
83 |
*********************************************************************************/
|
|
84 |
/* Update packet length in the descriptor according to HW interface requirements */
|
|
85 |
static inline TI_UINT16 TranslateLengthToFw (TTxCtrlBlk *pPktCtrlBlk)
|
|
86 |
{
|
|
87 |
TI_UINT16 uPktLen = pPktCtrlBlk->tTxDescriptor.length;
|
|
88 |
TI_UINT16 uLastWordPad = (4 - (uPktLen & 3)) & 0x3; /* Find number of bytes needed to align */
|
|
89 |
|
|
90 |
uPktLen = (uPktLen + uLastWordPad) >> 2; /* Add alignment bytes and convert to words */
|
|
91 |
pPktCtrlBlk->tTxDescriptor.length = ENDIAN_HANDLE_WORD(uPktLen);
|
|
92 |
|
|
93 |
return uLastWordPad;
|
|
94 |
}
|
|
95 |
|
|
96 |
/* Translate packet timestamp to FW time, and update also lifeTime and uDriverDelay */
|
|
97 |
static inline void TranslateTimeToFw (TwdCtrl *iTwdCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT16 uLifeTime)
|
|
98 |
{
|
|
99 |
TI_UINT32 uPktStartTime = pPktCtrlBlk->tTxDescriptor.startTime; /* Contains host start time */
|
|
100 |
|
|
101 |
/* Save host packet handling time until this point (for statistics) */
|
|
102 |
pPktCtrlBlk->tTxPktParams.uDriverDelay = os_timeStampMs (iTwdCtrl->tOsContext.hOsa) - uPktStartTime;
|
|
103 |
|
|
104 |
/* Translate packet timestamp to FW time and undate descriptor */
|
|
105 |
uPktStartTime = TWD_TranslateToFwTime (iTwdCtrl->hTWD, uPktStartTime);
|
|
106 |
pPktCtrlBlk->tTxDescriptor.startTime = ENDIAN_HANDLE_LONG (uPktStartTime);
|
|
107 |
pPktCtrlBlk->tTxDescriptor.lifeTime = ENDIAN_HANDLE_WORD (uLifeTime);
|
|
108 |
}
|
|
109 |
|
|
110 |
|
|
111 |
/**
|
|
112 |
* \fn RxMemFailTimerCb
|
|
113 |
* \brief Call again the rxXfer module to handle all pending packets.
|
|
114 |
* \note
|
|
115 |
* \return
|
|
116 |
* \sa
|
|
117 |
*/
|
|
118 |
void TIWha::RxMemFailTimerCb ()
|
|
119 |
{
|
|
120 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RxMemFailTimerCb uRxMemFailCount %d\n",uRxMemFailCount);
|
|
121 |
|
|
122 |
bRxMemFailTimerRunning = TI_FALSE;
|
|
123 |
|
|
124 |
/* if uRxMemFailCount == 0 it means that Rx allocation is back to life - no need to call RxXfer */
|
|
125 |
if (uRxMemFailCount)
|
|
126 |
{
|
|
127 |
TWD_rxXfer_Handle(iTwdCtrl.hTWD);
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
/**
|
|
132 |
* \fn RequestForBuffer
|
|
133 |
* \brief member function. calls LDD
|
|
134 |
*
|
|
135 |
* \note
|
|
136 |
* \param aLength - aligned length of packet.
|
|
137 |
* \return
|
|
138 |
* \sa
|
|
139 |
*/
|
|
140 |
ERxBufferStatus TIWha::RequestForBufferCb (void **pWbuf, TI_UINT16 aLength, TI_UINT32 uEncryptionFlag)
|
|
141 |
{
|
|
142 |
/* Total security overhead to be asked for in RequestForBuffer () */
|
|
143 |
TI_UINT32 uExtraSecurityLength = 0;
|
|
144 |
/* Offset to be used when returning the buffer pointer. It will be used shifting the header backwards */
|
|
145 |
TI_UINT32 uSecurityOffset = 0;
|
|
146 |
ERxBufferStatus eBufferStatus;
|
|
147 |
TI_UINT8* pRequestedBuf = NULL;
|
|
148 |
|
|
149 |
/*
|
|
150 |
* We should manipulate the packet according to the security mode. See ReceivePacket() for
|
|
151 |
* more details.
|
|
152 |
* We have 2 issues to deal with:
|
|
153 |
* 1) Add additional length to the buffer request.
|
|
154 |
* 2) Change the pointer such that it will point forward by the size that should be added after the header.
|
|
155 |
* It is done in order to pull back the header later in GWSI_AdaptCB_ReceivePacket() to support GWSI spec.
|
|
156 |
*/
|
|
157 |
|
|
158 |
|
|
159 |
switch (uEncryptionFlag)
|
|
160 |
{
|
|
161 |
case KEY_NULL:
|
|
162 |
uExtraSecurityLength = 0;
|
|
163 |
uSecurityOffset = 0;
|
|
164 |
break;
|
|
165 |
|
|
166 |
case KEY_WEP:
|
|
167 |
uExtraSecurityLength = IV_FIELD_SIZE + ICV_FIELD_SIZE;
|
|
168 |
uSecurityOffset = IV_FIELD_SIZE;
|
|
169 |
break;
|
|
170 |
|
|
171 |
case KEY_TKIP:
|
|
172 |
uExtraSecurityLength = IV_FIELD_SIZE + EIV_FIELD_SIZE + MIC_FIELD_SIZE + ICV_FIELD_SIZE;
|
|
173 |
uSecurityOffset = IV_FIELD_SIZE + EIV_FIELD_SIZE;
|
|
174 |
break;
|
|
175 |
|
|
176 |
case KEY_AES:
|
|
177 |
uExtraSecurityLength = AES_AFTER_HEADER_FIELD_SIZE + MIC_FIELD_SIZE;
|
|
178 |
uSecurityOffset = AES_AFTER_HEADER_FIELD_SIZE;
|
|
179 |
break;
|
|
180 |
|
|
181 |
#ifdef GEM_SUPPORT
|
|
182 |
case KEY_GEM_TYPE:
|
|
183 |
uExtraSecurityLength = GEM_AFTER_HEADER_FIELD_SIZE + GEM_MIC_FIELD_SIZE;
|
|
184 |
uSecurityOffset = GEM_AFTER_HEADER_FIELD_SIZE + GEM_BUFFER_ALIGNMENT;
|
|
185 |
break;
|
|
186 |
#endif
|
|
187 |
|
|
188 |
default:
|
|
189 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RequestForBuffer: uEncryptionFlag = %d uExtraSecurityLength = %d\n", uEncryptionFlag, uExtraSecurityLength);
|
|
190 |
break;
|
|
191 |
}
|
|
192 |
|
|
193 |
|
|
194 |
if (iRxPacketsAllocated < MAX_WHA_RX_BUFFERS)
|
|
195 |
{
|
|
196 |
/*
|
|
197 |
* We are requesting extra bytes for security, but decreasing WSPI_PAD_LEN_READ since the spec indicates
|
|
198 |
* that the Rx offset will be added any way
|
|
199 |
*/
|
|
200 |
if( bErrorIndication == TI_FALSE)
|
|
201 |
{
|
|
202 |
pRequestedBuf = (TI_UINT8*) WhaCb()->RequestForBuffer(aLength - sizeof(RxIfDescriptor_t) + uExtraSecurityLength + QOS_PADDING_SIZE + PAYLOAD_ALIGN_PAD_BYTES);
|
|
203 |
}
|
|
204 |
#if TI_DBG
|
|
205 |
else
|
|
206 |
{
|
|
207 |
WLAN_OS_REPORT(("%s : CommandResponse Block call to LDD response \n",__FUNCTION__));
|
|
208 |
}
|
|
209 |
#endif
|
|
210 |
|
|
211 |
if ( pRequestedBuf == NULL )
|
|
212 |
{
|
|
213 |
#ifdef PLT_TESTER
|
|
214 |
return RX_BUF_ALLOC_OUT_OF_MEM;
|
|
215 |
#endif
|
|
216 |
|
|
217 |
uRxMemFailCount++;
|
|
218 |
/* In case no timer is running - start a new timer to call RxXfer later */
|
|
219 |
if (!bRxMemFailTimerRunning)
|
|
220 |
{
|
|
221 |
#ifdef TI_DBG
|
|
222 |
if (uRxMemFailCount == 1)
|
|
223 |
{
|
|
224 |
/* Print error only for the first time */
|
|
225 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "Start hRxMemFailTimer for the first time\n");
|
|
226 |
}
|
|
227 |
#endif
|
|
228 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "Start hRxMemFailTimer uRxMemFailCount %d\n",uRxMemFailCount);
|
|
229 |
/* In case we fail too many times, just mark as OUT_OF_MEM so the Rx packet will be dropped */
|
|
230 |
if (uRxMemFailCount > MAX_CONSECUTIVE_RX_MEM_FAIL)
|
|
231 |
{
|
|
232 |
return RX_BUF_ALLOC_OUT_OF_MEM;
|
|
233 |
}
|
|
234 |
|
|
235 |
bRxMemFailTimerRunning = TI_TRUE;
|
|
236 |
os_timerStart(&iTwdCtrl.tOsContext,hRxMemFailTimer,RX_ALLOC_FAIL_TIME_OUT);
|
|
237 |
}
|
|
238 |
|
|
239 |
/* In this case rxXfer will exit the loop and wait for someone to trigger the SM again */
|
|
240 |
return RX_BUF_ALLOC_PENDING;
|
|
241 |
}
|
|
242 |
|
|
243 |
/* Increase the number of allocated buffers */
|
|
244 |
iRxPacketsAllocated++;
|
|
245 |
|
|
246 |
#ifdef TI_DBG
|
|
247 |
/* Just have a print in case we are out of the bad situation of RX_BUF_ALLOC_OUT_OF_MEM */
|
|
248 |
if (uRxMemFailCount)
|
|
249 |
{
|
|
250 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "Rx allocation succeeded after %d times\n",uRxMemFailCount);
|
|
251 |
}
|
|
252 |
#endif /* TI_DBG */
|
|
253 |
|
|
254 |
/* Rx allocation succeeded so set counter to zero */
|
|
255 |
uRxMemFailCount = 0;
|
|
256 |
|
|
257 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RequestForBuffer: uEncryptionFlag = %d uExtraSecurityLength = %d\n", uEncryptionFlag, uExtraSecurityLength);
|
|
258 |
|
|
259 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RequestForBuffer: len = %d OriginalPointer = 0x%x, allocatedBuffer#= %d \n", aLength, *pWbuf, iRxPacketsAllocated);
|
|
260 |
|
|
261 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RequestForBuffer: Pointer2Buffer= 0x%x, Buffer= 0x%x \n",pWbuf, *pWbuf);
|
|
262 |
|
|
263 |
/* The packet will be read as if it started uSecurityOffset bytes ahead and ReceivePacket() will take it back */
|
|
264 |
/* pWbuf points to the actual start of the data */
|
|
265 |
pRequestedBuf += uSecurityOffset + WSPI_PAD_LEN_READ;
|
|
266 |
|
|
267 |
*pWbuf = (void*)pRequestedBuf;
|
|
268 |
|
|
269 |
eBufferStatus = RX_BUF_ALLOC_COMPLETE;
|
|
270 |
}
|
|
271 |
else
|
|
272 |
{
|
|
273 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_WARNING, "RequestForBuffer: RX_BUF_ALLOC_PENDING");
|
|
274 |
/* RxXfer will try to allocate the buffer again when other buffer will be released */
|
|
275 |
eBufferStatus = RX_BUF_ALLOC_PENDING;
|
|
276 |
}
|
|
277 |
|
|
278 |
return eBufferStatus;
|
|
279 |
}
|
|
280 |
|
|
281 |
|
|
282 |
/**
|
|
283 |
* \fn ReceivePacket
|
|
284 |
* \brief member function. calls LDD
|
|
285 |
*
|
|
286 |
* \note
|
|
287 |
* \param aStatus - not used but retrieved from RxIfDescriptor_t.
|
|
288 |
* \param aBuf - pointer to start of RxIfDescriptor_t.
|
|
289 |
* \return
|
|
290 |
* \sa
|
|
291 |
*/
|
|
292 |
void TIWha::ReceivePacketCb (const void *aBuf)
|
|
293 |
{
|
|
294 |
WHA::TStatus aStatus;
|
|
295 |
TUint16 aLength;
|
|
296 |
WHA::TRate aRate;
|
|
297 |
WHA::TRcpi aRcpi;
|
|
298 |
WHA::TChannelNumber aChannel;
|
|
299 |
TUint32 aFlags;
|
|
300 |
/* move aBuf to begeinnig of MAC heder */
|
|
301 |
const void* aFrame = (TI_UINT8*)aBuf + sizeof(RxIfDescriptor_t);
|
|
302 |
dot11_header_t *pDot11Hdr = (dot11_header_t*)aFrame;
|
|
303 |
RxIfDescriptor_t* pRxParams = (RxIfDescriptor_t*)aBuf;
|
|
304 |
TBool bQos;
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
switch (pRxParams->status)
|
|
309 |
{
|
|
310 |
case RX_FAILURE_NONE:
|
|
311 |
aStatus = WHA::KSuccess;
|
|
312 |
break;
|
|
313 |
|
|
314 |
case RX_FAILURE_MIC_ERROR:
|
|
315 |
aStatus = WHA::KMicFailure;
|
|
316 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR , "ReceivePacket MIC_FAILURE !!! \n");
|
|
317 |
break;
|
|
318 |
|
|
319 |
case RX_FAILURE_DECRYPT:
|
|
320 |
aStatus = WHA::KDecryptFailure;
|
|
321 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR , "ReceivePacket DECRYPT_FAILURE !!! \n");
|
|
322 |
break;
|
|
323 |
|
|
324 |
default:
|
|
325 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR ,"ReceivePacketCb : WHA::KFailed");
|
|
326 |
aStatus = WHA::KFailed;
|
|
327 |
}
|
|
328 |
|
|
329 |
/* convert to LDD rate */
|
|
330 |
aRate = TIWhaUtils::PolicyToWhaRate ((ETxRateClassId)pRxParams->rate);
|
|
331 |
|
|
332 |
/* calculate RCPI form RSSI */
|
|
333 |
if (pRxParams->rx_level >= 0)
|
|
334 |
aRcpi = 220;
|
|
335 |
else
|
|
336 |
if (pRxParams->rx_level <= -110)
|
|
337 |
aRcpi = 0;
|
|
338 |
else
|
|
339 |
aRcpi = (pRxParams->rx_level + 110)*2;
|
|
340 |
|
|
341 |
/* Channel of received frame */
|
|
342 |
aChannel = pRxParams->channel;
|
|
343 |
|
|
344 |
/* pRxParams->length refer to total length form MAC heder in bytes */
|
|
345 |
aLength = pRxParams->length*WORD_SIZE - pRxParams->extraBytes - sizeof(RxIfDescriptor_t);
|
|
346 |
|
|
347 |
/* flags description:
|
|
348 |
1. bits 0 - 15 are optional
|
|
349 |
2. bits 16 - 18 security TBD when security integrated
|
|
350 |
3. bit 19 for more pending frames
|
|
351 |
4. bit 20 packet was received during a measurement process or not
|
|
352 |
*/
|
|
353 |
aFlags = 0;
|
|
354 |
|
|
355 |
/*
|
|
356 |
* The next adaptation code is meant to align with the driver legacy operation of extra padding for security:
|
|
357 |
*
|
|
358 |
* WEP: TnetwDrv HEADER - DATA
|
|
359 |
* Upper layer HEADER - IV (4) - DATA - ICV (4)
|
|
360 |
*
|
|
361 |
* TKIP: TnetwDrv HEADER - DATA
|
|
362 |
* Upper layer HEADER - IV (4) - EIV (4) - DATA - MIC (8) - ICV (4)
|
|
363 |
*
|
|
364 |
* AES: TnetwDrv HEADER - DATA
|
|
365 |
* Upper layer HEADER - RSN (8) - DATA - MIC (8)
|
|
366 |
*
|
|
367 |
* GEM: TnetwDrv HEADER - DATA
|
|
368 |
* Upper layer HEADER - KeyIdx(1) - Reserved(1) - PN(16) - DATA - MIC (16)
|
|
369 |
*
|
|
370 |
* Note: Adding the offset is done even if the packet status is error
|
|
371 |
*/
|
|
372 |
bQos = IS_QOS_FRAME(pDot11Hdr->fc);
|
|
373 |
TUint8 shiftBytes = WSPI_PAD_LEN_READ;
|
|
374 |
|
|
375 |
switch (pRxParams->flags & RX_DESC_ENCRYPT_MASK)
|
|
376 |
{
|
|
377 |
case RX_DESC_ENCRYPT_WEP:
|
|
378 |
ALIGN_HEADER_TO_DATA_BACKWARD (aFrame, WEP_AFTER_HEADER_FIELD_SIZE, bQos)
|
|
379 |
shiftBytes += WEP_AFTER_HEADER_FIELD_SIZE;
|
|
380 |
/* Increase length size by 8 (IV + ICV) */
|
|
381 |
aLength += (WEP_AFTER_HEADER_FIELD_SIZE + ICV_FIELD_SIZE);
|
|
382 |
aFlags |= WHA_WEP;
|
|
383 |
break;
|
|
384 |
|
|
385 |
case RX_DESC_ENCRYPT_TKIP:
|
|
386 |
ALIGN_HEADER_TO_DATA_BACKWARD (aFrame, TKIP_AFTER_HEADER_FIELD_SIZE, bQos)
|
|
387 |
shiftBytes += TKIP_AFTER_HEADER_FIELD_SIZE;
|
|
388 |
/* Increase length size by 20 (IV + EIV + MIC + ICV) */
|
|
389 |
aLength += (TKIP_AFTER_HEADER_FIELD_SIZE + MIC_FIELD_SIZE + ICV_FIELD_SIZE);
|
|
390 |
aFlags |= WHA_TKIP;
|
|
391 |
break;
|
|
392 |
|
|
393 |
case RX_DESC_ENCRYPT_AES:
|
|
394 |
ALIGN_HEADER_TO_DATA_BACKWARD (aFrame, AES_AFTER_HEADER_FIELD_SIZE, bQos)
|
|
395 |
shiftBytes += AES_AFTER_HEADER_FIELD_SIZE;
|
|
396 |
/* Increase length size by 16 (AES(RSN padding) + MIC) */
|
|
397 |
aLength += (AES_AFTER_HEADER_FIELD_SIZE + MIC_FIELD_SIZE);
|
|
398 |
aFlags |= WHA_AES;
|
|
399 |
break;
|
|
400 |
|
|
401 |
#ifdef GEM_SUPPORT
|
|
402 |
case RX_DESC_ENCRYPT_GEM:
|
|
403 |
ALIGN_HEADER_TO_DATA_BACKWARD (aFrame, GEM_AFTER_HEADER_FIELD_SIZE, bQos)
|
|
404 |
shiftBytes += GEM_AFTER_HEADER_FIELD_SIZE + GEM_BUFFER_ALIGNMENT;
|
|
405 |
/* Increase length size by 34 ( GEM_KeyIdx(1) + GEM_Reserved(1) + GEM_PN(16) + GEM_MIC(16) ) */
|
|
406 |
aLength += (GEM_AFTER_HEADER_FIELD_SIZE + GEM_MIC_FIELD_SIZE);
|
|
407 |
aFlags |= WHA_GEM;
|
|
408 |
break;
|
|
409 |
#endif
|
|
410 |
|
|
411 |
default:
|
|
412 |
/* Do nothing */
|
|
413 |
break;
|
|
414 |
}
|
|
415 |
|
|
416 |
/*if QOS frame the pointer starts 2 bytes before so the shiftbytes will be 2 mor bytes*/
|
|
417 |
if (bQos)
|
|
418 |
{
|
|
419 |
shiftBytes += QOS_SHIFT_SIZE;
|
|
420 |
}
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
/* Call upper layer */
|
|
425 |
if( bErrorIndication == TI_FALSE)
|
|
426 |
{
|
|
427 |
WhaCb()->ReceivePacket (aStatus,
|
|
428 |
aFrame,
|
|
429 |
aLength,
|
|
430 |
aRate,
|
|
431 |
aRcpi,
|
|
432 |
aChannel,
|
|
433 |
(TUint8*)aBuf - shiftBytes,
|
|
434 |
aFlags);
|
|
435 |
}
|
|
436 |
#if TI_DBG
|
|
437 |
else
|
|
438 |
{
|
|
439 |
WLAN_OS_REPORT(("%s : CommandResponse Block call to LDD response \n",__FUNCTION__));
|
|
440 |
}
|
|
441 |
#endif
|
|
442 |
|
|
443 |
/* Decrease the number of allocated buffers */
|
|
444 |
iRxPacketsAllocated--;
|
|
445 |
|
|
446 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "end of ReceivePacket(), allocated buffer = %d\n", iRxPacketsAllocated);
|
|
447 |
}
|
|
448 |
|
|
449 |
|
|
450 |
/**
|
|
451 |
* \fn SendPacket
|
|
452 |
* \brief member function.
|
|
453 |
*
|
|
454 |
* \note
|
|
455 |
* \return
|
|
456 |
* \sa
|
|
457 |
*/
|
|
458 |
WHA::TStatus TIWha::SendPacket(
|
|
459 |
const void* aFrame,
|
|
460 |
TUint16 aLength,
|
|
461 |
WHA::TQueueId aQueueId,
|
|
462 |
TUint8 aTxRateClassId,
|
|
463 |
WHA::TRate aMaxTransmitRate,
|
|
464 |
TBool aMore,
|
|
465 |
WHA::TPacketId aPacketId,
|
|
466 |
WHA::TPowerLevel aPowerLevel,
|
|
467 |
TUint32 aExpiryTime,
|
|
468 |
void* aReserved )
|
|
469 |
{
|
|
470 |
TTxCtrlBlk *pPktCtrlBlk;
|
|
471 |
void* aData = (void*)aFrame;
|
|
472 |
WHA::TStatus whaStatus;
|
|
473 |
TI_STATUS tiStatus;
|
|
474 |
|
|
475 |
TRACE4(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " aFrame = 0x%x len = %d aQueue = %d rateClass = %d\n", aFrame, aLength, aQueueId, aTxRateClassId);
|
|
476 |
|
|
477 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " aMaxTransmitRate = 0x%x aPacketId = 0x%x aExpiryTime = %d \n",aMaxTransmitRate, aPacketId, aExpiryTime);
|
|
478 |
|
|
479 |
|
|
480 |
AlignTxForTWD (aData, aLength);
|
|
481 |
|
|
482 |
/*
|
|
483 |
* Prepare packet for transmision by filling up all the fields.
|
|
484 |
*/
|
|
485 |
|
|
486 |
whaStatus = preparePktCtrlBlk ( &pPktCtrlBlk,
|
|
487 |
aData,
|
|
488 |
aLength,
|
|
489 |
aQueueId,
|
|
490 |
aTxRateClassId,
|
|
491 |
aMaxTransmitRate,
|
|
492 |
aMore,
|
|
493 |
aPacketId,
|
|
494 |
aPowerLevel,
|
|
495 |
aExpiryTime);
|
|
496 |
|
|
497 |
if ( whaStatus == WHA::KQueueFull)
|
|
498 |
{
|
|
499 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_WARNING , "****** KQueueFull ****** \n");
|
|
500 |
AlignTxSecurityForUMAC (TRUE);
|
|
501 |
return WHA::KQueueFull;
|
|
502 |
}
|
|
503 |
|
|
504 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "aFrame=%x, Buffer= %x \n", aFrame, pPktCtrlBlk->tTxnStruct.aBuf[0]);
|
|
505 |
|
|
506 |
/*
|
|
507 |
* Call the Tx-Xfer to start packet transfer to the FW and return its result.
|
|
508 |
*/
|
|
509 |
|
|
510 |
tiStatus = TWD_txXfer_SendPacket ( iTwdCtrl.hTWD, pPktCtrlBlk);
|
|
511 |
|
|
512 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " status = %d \n", tiStatus);
|
|
513 |
|
|
514 |
switch (tiStatus)
|
|
515 |
{
|
|
516 |
case TXN_STATUS_COMPLETE:
|
|
517 |
/* TxXferCb () won't be called so Align Tx packet before */
|
|
518 |
AlignTxSecurityForUMAC (TRUE);
|
|
519 |
/* Mark that TxXferCb won't be called */
|
|
520 |
pPktCtrlBlk->tTxPktParams.uFlags = TX_CTRL_FLAG_XFER_DONE_ISSUED;
|
|
521 |
return WHA::KSuccessXfer;
|
|
522 |
case TXN_STATUS_OK:
|
|
523 |
pPktCtrlBlk->tTxPktParams.uFlags = 0;
|
|
524 |
if (whaStatus == WHA::KPending) {
|
|
525 |
return WHA::KPending;
|
|
526 |
}
|
|
527 |
return WHA::KSuccess;
|
|
528 |
case TXN_STATUS_PENDING:
|
|
529 |
/* The packet is pending in spi level and not in driver level */
|
|
530 |
pPktCtrlBlk->tTxPktParams.uFlags = 0;
|
|
531 |
if (whaStatus == WHA::KPending) {
|
|
532 |
return WHA::KPending;
|
|
533 |
}
|
|
534 |
return WHA::KSuccess;
|
|
535 |
case TXN_STATUS_ERROR:
|
|
536 |
/* TxXferCb () won't be called so Align Tx packet before */
|
|
537 |
AlignTxSecurityForUMAC (TRUE);
|
|
538 |
return WHA::KQueueFull;
|
|
539 |
default:
|
|
540 |
/* TxXferCb () won't be called so Align Tx packet before */
|
|
541 |
AlignTxSecurityForUMAC (TRUE);
|
|
542 |
return WHA::KFailed;
|
|
543 |
}
|
|
544 |
}
|
|
545 |
|
|
546 |
/**
|
|
547 |
* \fn preparePktCtrlBlk
|
|
548 |
* \brief prepare the Ctrl Block with the given parameters
|
|
549 |
*
|
|
550 |
* \note
|
|
551 |
* \return txCtrlBlkEntry_t*
|
|
552 |
* \sa
|
|
553 |
*/
|
|
554 |
WHA::TStatus TIWha::preparePktCtrlBlk ( TTxCtrlBlk **pPktCtrlBlk,
|
|
555 |
const void* aFrame,
|
|
556 |
TUint16 aLength,
|
|
557 |
WHA::TQueueId aQueueId,
|
|
558 |
TUint8 aTxRateClassId,
|
|
559 |
WHA::TRate aMaxTransmitRate,
|
|
560 |
TBool aMore,
|
|
561 |
WHA::TPacketId aPacketId,
|
|
562 |
WHA::TPowerLevel aPowerLevel,
|
|
563 |
TUint32 aExpiryTime)
|
|
564 |
{
|
|
565 |
TI_UINT16 txDescAttr; /* Tx-descriptor fields values. */
|
|
566 |
TI_UINT16 uLastWordPad;
|
|
567 |
TI_UINT8 uAligmentPad;
|
|
568 |
TI_UINT32 tempaFrame;
|
|
569 |
*pPktCtrlBlk = NULL;
|
|
570 |
ETxHwQueStatus eHwQueStatus;
|
|
571 |
|
|
572 |
/* Allocates a Control-Block for the packet Tx parameters and descriptor. */
|
|
573 |
*pPktCtrlBlk = TWD_txCtrlBlk_Alloc (iTwdCtrl.hTWD);
|
|
574 |
|
|
575 |
/* If null entry (not expected to happen) return ERROR. */
|
|
576 |
if (!*pPktCtrlBlk)
|
|
577 |
{
|
|
578 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, ": Tx Ctrl-Blk allocation failed!!!\n");
|
|
579 |
return WHA::KQueueFull;
|
|
580 |
}
|
|
581 |
|
|
582 |
/* Save the aPacketId for use in TxXferCb & TxCompleteCb */
|
|
583 |
iPacketIdTable[(*pPktCtrlBlk)->tTxDescriptor.descID] = aPacketId;
|
|
584 |
|
|
585 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, ": iPacketIdTable[%d]= %d\n", (*pPktCtrlBlk)->tTxDescriptor.descID, aPacketId);
|
|
586 |
|
|
587 |
/*
|
|
588 |
* Fill in parameters of pPktCtrlBlk
|
|
589 |
*/
|
|
590 |
/* Move aFrame back in order to leave room for the tx_descriptor */
|
|
591 |
tempaFrame = (TI_UINT32)aFrame - TX_DESCRIPTOR_SIZE;
|
|
592 |
aFrame = (void*)tempaFrame;
|
|
593 |
|
|
594 |
uAligmentPad = ((4 -(aLength & 0x3)) & 0x3);
|
|
595 |
/* data is given with the header, this is different then full driver */
|
|
596 |
(*pPktCtrlBlk)->tTxnStruct.aLen[0] = aLength + TX_DESCRIPTOR_SIZE + uAligmentPad;
|
|
597 |
(*pPktCtrlBlk)->tTxnStruct.aBuf[0] = (TI_UINT8*)aFrame;
|
|
598 |
/* Not relevant since we are not incharge on the memory release */
|
|
599 |
(*pPktCtrlBlk)->tTxPktParams.uInputPktLen = 0;
|
|
600 |
(*pPktCtrlBlk)->tTxPktParams.pInputPkt = 0;
|
|
601 |
|
|
602 |
/*
|
|
603 |
* Build packet descriptor (for FW interface).
|
|
604 |
*/
|
|
605 |
(*pPktCtrlBlk)->tTxDescriptor.tid = WMEQosAcToTid[aQueueId];
|
|
606 |
(*pPktCtrlBlk)->tTxDescriptor.startTime = os_timeStampMs (iTwdCtrl.tOsContext.hOsa);
|
|
607 |
TranslateTimeToFw (&iTwdCtrl, (*pPktCtrlBlk), 2000/*aExpiryTime*/);
|
|
608 |
|
|
609 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, ": aExpiryTime= %d, desc.startTime= %d, desc.lifeTime= %d \n", aExpiryTime, (*pPktCtrlBlk)->tTxDescriptor.startTime, (*pPktCtrlBlk)->tTxDescriptor.lifeTime);
|
|
610 |
|
|
611 |
/* Initialize tTxDescriptor.length with the real packet length in bytes */
|
|
612 |
(*pPktCtrlBlk)->tTxDescriptor.length = aLength + TX_DESCRIPTOR_SIZE;
|
|
613 |
|
|
614 |
/* Call HwQueue for Hw resources allocation. If not available return NULL. */
|
|
615 |
eHwQueStatus = TWD_txHwQueue_AllocResources (iTwdCtrl.hTWD, (*pPktCtrlBlk));
|
|
616 |
|
|
617 |
if (eHwQueStatus == TX_HW_QUE_STATUS_STOP_CURRENT)
|
|
618 |
{
|
|
619 |
/* Free Ctrl block. */
|
|
620 |
TWD_txCtrlBlk_Free(iTwdCtrl.hTWD, (*pPktCtrlBlk));
|
|
621 |
|
|
622 |
TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_WARNING, ": Tx Hw resources allocation failed!!!\n");
|
|
623 |
return WHA::KQueueFull;
|
|
624 |
}
|
|
625 |
|
|
626 |
/* txCtrl_TranslateLengthToFw() will translate it to the length in FW format */
|
|
627 |
uLastWordPad = TranslateLengthToFw((*pPktCtrlBlk));
|
|
628 |
|
|
629 |
/* Upper layer is using '1' for first policy, while TnetwDrv is using '0' for it. */
|
|
630 |
txDescAttr = (aTxRateClassId - 1 ) << TX_ATTR_OFST_RATE_POLICY;
|
|
631 |
|
|
632 |
/* if there is a security padding then the WLAN packet was stuffed with 2 extra bytes for alignment */
|
|
633 |
if (iSecurityPadding != 0)
|
|
634 |
{
|
|
635 |
txDescAttr |= TX_ATTR_HEADER_PAD;
|
|
636 |
}
|
|
637 |
|
|
638 |
txDescAttr |= uLastWordPad << TX_ATTR_OFST_LAST_WORD_PAD;
|
|
639 |
|
|
640 |
(*pPktCtrlBlk)->tTxDescriptor.txAttr = txDescAttr;
|
|
641 |
|
|
642 |
/*
|
|
643 |
* Copy the descriptor parameters to the packet header.
|
|
644 |
*/
|
|
645 |
os_memoryCopy(iTwdCtrl.tOsContext.hOsa, const_cast<void*>(aFrame), (TxIfDescriptor_t*)&(*pPktCtrlBlk)->tTxDescriptor, sizeof(TxIfDescriptor_t));
|
|
646 |
|
|
647 |
return eHwQueStatus == TX_HW_QUE_STATUS_STOP_NEXT ? WHA::KPending : WHA::KSuccess;
|
|
648 |
}
|
|
649 |
|
|
650 |
/**
|
|
651 |
* \fn AlignTxForTWD
|
|
652 |
* \brief Aligment header to TWD structure -- Check HT and Security.
|
|
653 |
*
|
|
654 |
* \note
|
|
655 |
* \return
|
|
656 |
* \sa
|
|
657 |
*/
|
|
658 |
WHA::TStatus TIWha::AlignTxForTWD (void*& aFrame,TUint16& aLength)
|
|
659 |
{
|
|
660 |
/* Use the header to retrieve the frame ctrl of the packet */
|
|
661 |
dot11_header_t *pDot11Hdr = (dot11_header_t*)aFrame;
|
|
662 |
TI_UINT32 tempaFrame;
|
|
663 |
|
|
664 |
/* By default we won't handle any alignment */
|
|
665 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] = 0;
|
|
666 |
#ifdef HT_SUPPORT
|
|
667 |
if (IS_HT_FRAME(pDot11Hdr->fc))
|
|
668 |
{
|
|
669 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] = HT_CONTROL_FILED_SIZE;
|
|
670 |
aLength -= HT_CONTROL_FILED_SIZE;
|
|
671 |
}
|
|
672 |
#endif /* HT_SUPPORT */
|
|
673 |
|
|
674 |
/* Qos heaser is needed to determine the WLAN Header size */
|
|
675 |
iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrSend] = IS_QOS_FRAME(pDot11Hdr->fc);
|
|
676 |
|
|
677 |
/* zero iSecurityPadding for every new packet */
|
|
678 |
iSecurityPadding = 0;
|
|
679 |
|
|
680 |
/* Check if using security. If so we should convert the packet format as the description below */
|
|
681 |
if (IS_WEP_ON(pDot11Hdr->fc))
|
|
682 |
{
|
|
683 |
TI_UINT8* pMac;
|
|
684 |
ECipherSuite eSecurityMode;
|
|
685 |
|
|
686 |
pMac = &pDot11Hdr->address1[0]; /* hold the first mac address */
|
|
687 |
|
|
688 |
/* Use group key on Multicast/broadcast. else use pairwise */
|
|
689 |
if (MAC_MULTICAST(pMac))
|
|
690 |
{
|
|
691 |
eSecurityMode = iTwdCtrl.eGroupKeyMode;
|
|
692 |
}
|
|
693 |
else
|
|
694 |
{
|
|
695 |
eSecurityMode = iTwdCtrl.ePairwiseKeyMode;
|
|
696 |
}
|
|
697 |
|
|
698 |
/*
|
|
699 |
* The next adaptation code is meant to align with the driver legacy operation of extra padding for security:
|
|
700 |
*
|
|
701 |
* WEP: Upper layer HEADER - IV (4) - DATA - ICV (4)
|
|
702 |
* TnetwDrv HEADER - DATA
|
|
703 |
*
|
|
704 |
* TKIP: Upper layer HEADER - IV (4) - EIV (4) - DATA - MIC (8) - ICV (4)
|
|
705 |
* TnetwDrv HEADER - EIV (4) - DATA
|
|
706 |
*
|
|
707 |
* AES: Upper layer HEADER - RSN (8) - DATA - MIC (8)
|
|
708 |
* TnetwDrv HEADER - RSN (8) - DATA
|
|
709 |
*/
|
|
710 |
|
|
711 |
TRACE4(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SendPacket(): send = %d Handle = %d, QoS = %d, encryption = %d\n",iTwdCtrl.TxAlign.uCurrSend, iTwdCtrl.TxAlign.uCurrHandle,
|
|
712 |
iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrSend], eSecurityMode);
|
|
713 |
|
|
714 |
switch (eSecurityMode)
|
|
715 |
{
|
|
716 |
case TWD_CIPHER_WEP:
|
|
717 |
/* Mark the offset between header and data */
|
|
718 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] += WEP_AFTER_HEADER_FIELD_SIZE;
|
|
719 |
/* Decrease length size by 8 (IV + ICV) */
|
|
720 |
aLength -= (IV_FIELD_SIZE + ICV_FIELD_SIZE);
|
|
721 |
break;
|
|
722 |
|
|
723 |
case TWD_CIPHER_TKIP:
|
|
724 |
/* Mark the offset between header and data */
|
|
725 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] += IV_FIELD_SIZE;
|
|
726 |
/* Decrease length size by 16 (IV + MIC + ICV) */
|
|
727 |
aLength -= (IV_FIELD_SIZE + MIC_FIELD_SIZE + ICV_FIELD_SIZE);
|
|
728 |
break;
|
|
729 |
|
|
730 |
case TWD_CIPHER_AES_WRAP:
|
|
731 |
case TWD_CIPHER_AES_CCMP:
|
|
732 |
/* Decrease length size by 8 (MIC) */
|
|
733 |
aLength -= MIC_FIELD_SIZE;
|
|
734 |
break;
|
|
735 |
#ifdef GEM_SUPPORT
|
|
736 |
case TWD_CIPHER_GEM:
|
|
737 |
/* Mark the offset between header and data */
|
|
738 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] += GEM_AFTER_HEADER_FIELD_SIZE;
|
|
739 |
/* Decrease length size by 34 bytes (KEY_IDX_FIELD_SIZE + RESERVED_FIELD_SIZE + PN_FIELD_SIZE + MIC) */
|
|
740 |
aLength -= (GEM_AFTER_HEADER_FIELD_SIZE + GEM_MIC_FIELD_SIZE);
|
|
741 |
/* Add padding of two bytes before wlan header, */
|
|
742 |
/* because it will be unaligned after the header will be moved 18 bytes */
|
|
743 |
iSecurityPadding = GEM_AFTER_HEADER_PAD;
|
|
744 |
break;
|
|
745 |
#endif
|
|
746 |
|
|
747 |
default:
|
|
748 |
/* Unknown security with Encryption ON. return ERROR */
|
|
749 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "SendPacket(): Encryption ON but unknown security mode = %d\n", eSecurityMode);
|
|
750 |
return WHA::KFailed;
|
|
751 |
}
|
|
752 |
}
|
|
753 |
|
|
754 |
/* Check if the header packet should move */
|
|
755 |
if (iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend] > 0)
|
|
756 |
{
|
|
757 |
ALIGN_HEADER_TO_DATA_FORWARD (aFrame, iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend],
|
|
758 |
iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrSend])
|
|
759 |
}
|
|
760 |
|
|
761 |
/* Move the frame iSecurityPadding (2 bytes) backward */
|
|
762 |
tempaFrame = (TI_UINT32)aFrame - iSecurityPadding;
|
|
763 |
aFrame = (void*)tempaFrame;
|
|
764 |
/* Increase the length by size of iSecurityPadding (2 bytes) */
|
|
765 |
aLength+= iSecurityPadding;
|
|
766 |
/* Mark the current packet - Note that it is needed only when we have security */
|
|
767 |
iTwdCtrl.TxAlign.pFrame[iTwdCtrl.TxAlign.uCurrSend] = (void*)aFrame;
|
|
768 |
/* For the next packet to be send */
|
|
769 |
|
|
770 |
iTwdCtrl.TxAlign.uCurrSend++;
|
|
771 |
iTwdCtrl.TxAlign.uCurrSend %= MAX_XFER_WAITING_PACKETS;
|
|
772 |
|
|
773 |
return WHA::KSuccess;
|
|
774 |
}
|
|
775 |
|
|
776 |
|
|
777 |
/**
|
|
778 |
* \fn AlignTxSecurityForUMAC
|
|
779 |
* \brief security alignment.
|
|
780 |
*
|
|
781 |
* Handle packet alignment after Xfer done
|
|
782 |
* It is done here after the pointer was changed in TIWha::SendPacket()
|
|
783 |
* and at this point the pointer is not needed any more.
|
|
784 |
* \note
|
|
785 |
* \return
|
|
786 |
* \sa
|
|
787 |
*/
|
|
788 |
void TIWha::AlignTxSecurityForUMAC (TBool aQFull)
|
|
789 |
{
|
|
790 |
TRACE5(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "AlignTxSecurityForUMAC(): send = %d Handle = %d, QoS = %d, Offset = %d pFrame = %p\n",iTwdCtrl.TxAlign.uCurrSend, iTwdCtrl.TxAlign.uCurrHandle,iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrHandle],
|
|
791 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrHandle],iTwdCtrl.TxAlign.pFrame[iTwdCtrl.TxAlign.uCurrHandle]);
|
|
792 |
|
|
793 |
if (aQFull) {
|
|
794 |
|
|
795 |
iTwdCtrl.TxAlign.uCurrSend = iTwdCtrl.TxAlign.uCurrSend > 0? iTwdCtrl.TxAlign.uCurrSend - 1 : 49;
|
|
796 |
TRACE5(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "AlignTxSecurityForUMAC() -- ** aQFull **: send = %d Handle = %d, QoS = %d, Offset = %d pFrame = %p\n",iTwdCtrl.TxAlign.uCurrSend, iTwdCtrl.TxAlign.uCurrHandle,iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrHandle],
|
|
797 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrHandle],iTwdCtrl.TxAlign.pFrame[iTwdCtrl.TxAlign.uCurrHandle]);
|
|
798 |
|
|
799 |
ALIGN_HEADER_TO_DATA_BACKWARD (iTwdCtrl.TxAlign.pFrame[iTwdCtrl.TxAlign.uCurrSend],
|
|
800 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrSend],
|
|
801 |
iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrSend])
|
|
802 |
return;
|
|
803 |
}
|
|
804 |
|
|
805 |
/* Check if the packet should be aligned */
|
|
806 |
if (iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrHandle])
|
|
807 |
{
|
|
808 |
ALIGN_HEADER_TO_DATA_BACKWARD (iTwdCtrl.TxAlign.pFrame[iTwdCtrl.TxAlign.uCurrHandle],
|
|
809 |
iTwdCtrl.TxAlign.uHeaderToDataOffset[iTwdCtrl.TxAlign.uCurrHandle],
|
|
810 |
iTwdCtrl.TxAlign.bIsQosHeader[iTwdCtrl.TxAlign.uCurrHandle])
|
|
811 |
}
|
|
812 |
|
|
813 |
/* For the next packet to be handled */
|
|
814 |
iTwdCtrl.TxAlign.uCurrHandle++;
|
|
815 |
iTwdCtrl.TxAlign.uCurrHandle %= MAX_XFER_WAITING_PACKETS;
|
|
816 |
}
|
|
817 |
|
|
818 |
|
|
819 |
/**
|
|
820 |
* \fn TxXferCb
|
|
821 |
* \brief
|
|
822 |
* Called by the TNETW driver upon Xfer-Done of transmitted packet.
|
|
823 |
* Calls the UMAC Xfer-Done handler.
|
|
824 |
*
|
|
825 |
* \note
|
|
826 |
* \return
|
|
827 |
* \sa
|
|
828 |
*/
|
|
829 |
void TIWha::TxXferCb ( TTxCtrlBlk *pPktCtrlBlk)
|
|
830 |
{
|
|
831 |
TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxXferCb(): packetId=0x%x flags = 0x%x\n",iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID], pPktCtrlBlk->tTxPktParams.uFlags);
|
|
832 |
|
|
833 |
#ifdef TI_DBG
|
|
834 |
/* If the pointed entry is already free, print error and exit (not expected to happen). */
|
|
835 |
if (pPktCtrlBlk->pNextFreeEntry != NULL)
|
|
836 |
{
|
|
837 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxXferCb(): Pkt already free!!, DescID=%d, flags=%d, packetId=0x%x\n",pPktCtrlBlk->tTxDescriptor.descID, pPktCtrlBlk->tTxPktParams.uFlags,iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]);
|
|
838 |
|
|
839 |
return;
|
|
840 |
}
|
|
841 |
#endif
|
|
842 |
|
|
843 |
/* Check If this is the second time we call TxXferCb for this packet (i.e. TxCompleteCb called it explicitly) */
|
|
844 |
if (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_XFER_DONE_ISSUED)
|
|
845 |
{
|
|
846 |
|
|
847 |
/* TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, TIWLANWHA_MODULE_LOG, MSG_2262, "TxXferCb(): already called for this packet!!, DescID=%d, flags=%d, packetId=0x%x\n",pPktCtrlBlk->tTxDescriptor.descID, pPktCtrlBlk->tTxPktParams.uFlagsiPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]); */
|
|
848 |
}
|
|
849 |
else /* TxXferCB called for the first time. call UMAC */
|
|
850 |
{
|
|
851 |
pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_XFER_DONE_ISSUED;
|
|
852 |
|
|
853 |
AlignTxSecurityForUMAC ();
|
|
854 |
|
|
855 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxXferCb(): call WhaCb()->SendPacketTransfer, descID= %d\n", pPktCtrlBlk->tTxDescriptor.descID);
|
|
856 |
TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxXferCb(): call WhaCb()->SendPacketTransfer, PacketID= %d\n", iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]);
|
|
857 |
|
|
858 |
if( bErrorIndication == TI_FALSE)
|
|
859 |
{
|
|
860 |
WhaCb()->SendPacketTransfer ((WHA::TPacketId)iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]);
|
|
861 |
}
|
|
862 |
#if TI_DBG
|
|
863 |
else
|
|
864 |
{
|
|
865 |
WLAN_OS_REPORT(("%s : CommandResponse Block call to LDD response \n",__FUNCTION__));
|
|
866 |
}
|
|
867 |
#endif
|
|
868 |
}
|
|
869 |
}
|
|
870 |
|
|
871 |
/**
|
|
872 |
* \fn TxCompleteCb
|
|
873 |
* \brief Called upon Tx-complete of transmitted packet.
|
|
874 |
* Handles it as follows:
|
|
875 |
* 1) Update the HwQueue to free queue resources.
|
|
876 |
* 2) Call the upper driver's tx-complete handler.
|
|
877 |
* 3) Free the packet's Control-Block if Xfer-Done already occured.
|
|
878 |
*
|
|
879 |
* \note
|
|
880 |
* \return
|
|
881 |
* \sa
|
|
882 |
*/
|
|
883 |
void TIWha::TxCompleteCb ( TxResultDescriptor_t *pTxResultInfo, TI_UINT32 backpressure)
|
|
884 |
{
|
|
885 |
/* Get the packet's control block pointer by the descId index. */
|
|
886 |
TTxCtrlBlk *pPktCtrlBlk = TWD_txCtrlBlk_GetPointer(iTwdCtrl.hTWD, pTxResultInfo->descID);
|
|
887 |
WHA::TStatus status;
|
|
888 |
|
|
889 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxCompleteCb(): DescID=%d, flags=%d, packetId=0x%x\n",
|
|
890 |
pTxResultInfo->descID, pPktCtrlBlk->tTxPktParams.uFlags,
|
|
891 |
iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]);
|
|
892 |
|
|
893 |
#ifdef TI_DBG
|
|
894 |
/* If the pointed entry is already free, print error and exit (not expected to happen). */
|
|
895 |
if (pPktCtrlBlk->pNextFreeEntry != NULL)
|
|
896 |
{
|
|
897 |
TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxCompleteCb(): Pkt already free!!, DescID=%d, flags=%d, packetId=0x%x\n",
|
|
898 |
pPktCtrlBlk->tTxDescriptor.descID, pPktCtrlBlk->tTxPktParams.uFlags,
|
|
899 |
iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID]);
|
|
900 |
|
|
901 |
return;
|
|
902 |
}
|
|
903 |
#endif
|
|
904 |
|
|
905 |
|
|
906 |
/* Check if TxXferCb was called for this packet */
|
|
907 |
if ((pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_XFER_DONE_ISSUED) == 0)
|
|
908 |
{
|
|
909 |
/* Xfer was not called, so call it here. Note that once TxComplete was called, there will be no TxXfer */
|
|
910 |
TxXferCb (pPktCtrlBlk);
|
|
911 |
}
|
|
912 |
|
|
913 |
/* We return Success on every tx result because of stange behaviour in the upper layer */
|
|
914 |
/* It seems that on results other than success the OS closes the socket */
|
|
915 |
switch (pTxResultInfo->status)
|
|
916 |
{
|
|
917 |
case TX_SUCCESS:
|
|
918 |
status = WHA::KSuccess;
|
|
919 |
break;
|
|
920 |
case TX_RETRY_EXCEEDED:
|
|
921 |
status = WHA::KErrorRetryExceeded;
|
|
922 |
WLAN_OS_REPORT(("ERROR: TxCompletewith status = %d",pTxResultInfo->status));
|
|
923 |
break;
|
|
924 |
case TX_TIMEOUT:
|
|
925 |
status = WHA::KErrorLifetimeExceeded;
|
|
926 |
WLAN_OS_REPORT(("ERROR: TxCompletewith status = %d",pTxResultInfo->status));
|
|
927 |
break;
|
|
928 |
case TX_PEER_NOT_FOUND:
|
|
929 |
status = WHA::KErrorNoLink;
|
|
930 |
WLAN_OS_REPORT(("ERROR: TxCompletewith status = %d",pTxResultInfo->status));
|
|
931 |
break;
|
|
932 |
case TX_DISABLED:
|
|
933 |
status = WHA::KErrorMacNotResponding;
|
|
934 |
WLAN_OS_REPORT(("ERROR: TxCompletewith status = %d",pTxResultInfo->status));
|
|
935 |
break;
|
|
936 |
default:
|
|
937 |
status = WHA::KFailed;
|
|
938 |
WLAN_OS_REPORT(("ERROR: TxCompletewith status = %d",pTxResultInfo->status));
|
|
939 |
break;
|
|
940 |
}
|
|
941 |
|
|
942 |
/* Call the UMAC tx-complete handler */
|
|
943 |
if( bErrorIndication == TI_FALSE)
|
|
944 |
{
|
|
945 |
WhaCb()->SendPacketComplete( status,
|
|
946 |
(WHA::TPacketId)iPacketIdTable[pPktCtrlBlk->tTxDescriptor.descID],
|
|
947 |
TIWhaUtils::PolicyToWhaRate ((ETxRateClassId)pTxResultInfo->rate),
|
|
948 |
pTxResultInfo->mediumDelay, /* aPacketQueueDelay */
|
|
949 |
pTxResultInfo->fwHandlingTime, /* aMediaDelay */
|
|
950 |
pTxResultInfo->ackFailures);
|
|
951 |
}
|
|
952 |
#if TI_DBG
|
|
953 |
else
|
|
954 |
{
|
|
955 |
WLAN_OS_REPORT(("%s : CommandResponse Block call to LDD response \n",__FUNCTION__));
|
|
956 |
}
|
|
957 |
#endif
|
|
958 |
|
|
959 |
/* Free Ctrl block. */
|
|
960 |
TWD_txCtrlBlk_Free(iTwdCtrl.hTWD, pPktCtrlBlk);
|
|
961 |
}
|
|
962 |
|
|
963 |
|