|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of the MgmtFrameMemMngr class. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 19 % |
|
20 */ |
|
21 |
|
22 #include "WlLddWlanLddConfig.h" |
|
23 #include "MgmtFrameMemMngr.h" |
|
24 #include "osachunk.h" |
|
25 #include <kern_priv.h> |
|
26 |
|
27 extern TAny* os_alloc( const TUint32 ); |
|
28 extern void os_free( const TAny* ); |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 TInt MgmtFrameMemMngr::DoAllocate( DChunk*& aSharedMemoryChunk ) |
|
35 { |
|
36 TraceDump( INIT_LEVEL, |
|
37 ("WLANLDD: MgmtFrameMemMngr::DoAllocate:") ); |
|
38 |
|
39 // determine if cached memory shall be used |
|
40 TUint cacheOption = iUseCachedMemory ? |
|
41 EMapAttrCachedMax : |
|
42 EMapAttrFullyBlocking; |
|
43 |
|
44 // Start creating the chunk |
|
45 |
|
46 TChunkCreateInfo info; |
|
47 info.iType = TChunkCreateInfo::ESharedKernelMultiple; |
|
48 info.iMaxSize = iChunkSize; |
|
49 info.iMapAttr = EMapAttrReadUser | |
|
50 EMapAttrWriteUser | |
|
51 EMapAttrShared | |
|
52 cacheOption; |
|
53 info.iOwnsMemory = ETrue; |
|
54 info.iDestroyedDfc = NULL; |
|
55 |
|
56 DChunk* chunk; |
|
57 |
|
58 TraceDump( INIT_LEVEL, |
|
59 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: create chunk of size: %d"), |
|
60 iChunkSize) ); |
|
61 |
|
62 TUint32 chunkMapAttrNotNeeded ( 0 ); |
|
63 |
|
64 // Enter critical section so we can't die and leak the object we are |
|
65 // creating, i.e. DChunk (shared memory chunk) |
|
66 NKern::ThreadEnterCS(); |
|
67 |
|
68 TInt r = Kern::ChunkCreate( |
|
69 info, |
|
70 chunk, |
|
71 iChunkKernelAddr, |
|
72 chunkMapAttrNotNeeded ); |
|
73 |
|
74 if( r != KErrNone) |
|
75 { |
|
76 TraceDump( WARNING_LEVEL, |
|
77 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: create chunk failed. Status: %d"), |
|
78 r ) ); |
|
79 |
|
80 NKern::ThreadLeaveCS(); |
|
81 return r; |
|
82 } |
|
83 |
|
84 TraceDump(MEMORY, (("WLANLDD: new DChunk: 0x%08x"), |
|
85 reinterpret_cast<TUint32>(chunk))); |
|
86 |
|
87 TraceDump(INIT_LEVEL, |
|
88 (("MgmtFrameMemMngr::DoAllocate: Platform Hw Chunk create success with cacheOption: 0x%08x"), |
|
89 cacheOption)); |
|
90 |
|
91 TUint32 physicalAddressNotNeeded ( 0 ); |
|
92 |
|
93 // Map our device's memory into the chunk (at offset 0) |
|
94 r = Kern::ChunkCommitContiguous( chunk, 0, iChunkSize, physicalAddressNotNeeded ); |
|
95 |
|
96 if ( r != KErrNone) |
|
97 { |
|
98 TraceDump( WARNING_LEVEL, |
|
99 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: chunk commit failed. Status: %d"), |
|
100 r ) ); |
|
101 |
|
102 // Commit failed so tidy-up. |
|
103 // Close chunk, which will then get deleted at some point |
|
104 Kern::ChunkClose( chunk ); |
|
105 } |
|
106 else |
|
107 { |
|
108 TraceDump( INIT_LEVEL, |
|
109 ("WLANLDD: MgmtFrameMemMngr::DoAllocate: chunk commit success") ); |
|
110 |
|
111 // Commit succeeded so pass back the chunk pointer |
|
112 aSharedMemoryChunk = chunk; |
|
113 } |
|
114 |
|
115 // Can leave critical section now that we have saved pointer to created object |
|
116 NKern::ThreadLeaveCS(); |
|
117 |
|
118 TraceDump( INIT_LEVEL, |
|
119 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: chunk map attr: %d"), |
|
120 chunkMapAttrNotNeeded ) ); |
|
121 TraceDump( INIT_LEVEL, |
|
122 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: iChunkKernelAddr: 0x%08x"), |
|
123 static_cast<TUint32>(iChunkKernelAddr) ) ); |
|
124 TraceDump( INIT_LEVEL, |
|
125 (("WLANLDD: MgmtFrameMemMngr::DoAllocate: chunk physical address: 0x%08x"), |
|
126 physicalAddressNotNeeded ) ); |
|
127 |
|
128 return r; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 TInt MgmtFrameMemMngr::DoOpenHandle( |
|
136 DThread& aThread, |
|
137 TSharedChunkInfo& aSharedChunkInfo, |
|
138 DChunk* aSharedMemoryChunk ) |
|
139 { |
|
140 TInt ret ( KErrGeneral ); |
|
141 |
|
142 if ( aSharedMemoryChunk ) |
|
143 { |
|
144 |
|
145 // Need to be in critical section while creating handles |
|
146 NKern::ThreadEnterCS(); |
|
147 |
|
148 // Create handle to shared memory chunk for client thread |
|
149 TInt r = Kern::MakeHandleAndOpen( &aThread, aSharedMemoryChunk ); |
|
150 |
|
151 // Leave critical section |
|
152 NKern::ThreadLeaveCS(); |
|
153 |
|
154 // positive r value is a handle, negative value is an error code |
|
155 if( r >= 0 ) |
|
156 { |
|
157 // mapping success |
|
158 |
|
159 TraceDump( INIT_LEVEL, |
|
160 (("WLANLDD: MgmtFrameMemMngr::OnInitialiseMemory: Handle create & open ok: handle: %d"), |
|
161 r ) ); |
|
162 |
|
163 // store the handle & the chunk size |
|
164 aSharedChunkInfo.iChunkHandle = r; |
|
165 aSharedChunkInfo.iSize = iChunkSize; |
|
166 |
|
167 // store the kernel addresses |
|
168 |
|
169 TUint8* start_of_mem = reinterpret_cast<TUint8*>(iChunkKernelAddr ); |
|
170 |
|
171 const TUint KRxDataChunkSize( |
|
172 iChunkSize |
|
173 - ( sizeof( TDataBuffer ) |
|
174 + KMgmtSideTxBufferLength |
|
175 + KProtocolStackSideTxDataChunkSize |
|
176 + sizeof( RFrameXferBlock ) |
|
177 + sizeof( RFrameXferBlockProtocolStack ) ) ); |
|
178 |
|
179 TraceDump( INIT_LEVEL, |
|
180 (("WLANLDD: MgmtFrameMemMngr::DoOpenHandle: KRxDataChunkSize: %d"), |
|
181 KRxDataChunkSize ) ); |
|
182 |
|
183 iRxDataChunk = start_of_mem; |
|
184 |
|
185 TraceDump( INIT_LEVEL, |
|
186 (("WLANLDD: MgmtFrameMemMngr::DoOpenHandle: iRxDataChunk start addr: 0x%08x"), |
|
187 reinterpret_cast<TUint32>(iRxDataChunk) ) ); |
|
188 TraceDump( INIT_LEVEL, |
|
189 (("WLANLDD: MgmtFrameMemMngr::DoOpenHandle: iRxDataChunk end addr: 0x%08x"), |
|
190 reinterpret_cast<TUint32>(iRxDataChunk + KRxDataChunkSize) ) ); |
|
191 |
|
192 // create the Rx frame memory pool manager |
|
193 iRxFrameMemoryPool = new WlanChunk( |
|
194 iRxDataChunk, |
|
195 iRxDataChunk + KRxDataChunkSize, |
|
196 iRxFrameBufAllocationUnit ); |
|
197 |
|
198 if ( iRxFrameMemoryPool && iRxFrameMemoryPool->IsValid() ) |
|
199 { |
|
200 ret = KErrNone; |
|
201 |
|
202 TraceDump(MEMORY, (("WLANLDD: new WlanChunk: 0x%08x"), |
|
203 reinterpret_cast<TUint32>(iRxFrameMemoryPool))); |
|
204 |
|
205 iTxDataBuffer = reinterpret_cast<TDataBuffer*>( |
|
206 start_of_mem |
|
207 + KRxDataChunkSize ); |
|
208 |
|
209 TraceDump( INIT_LEVEL, |
|
210 (("WLANLDD: MgmtFrameMemMngr::DoOpenHandle: Engine TxDataBuf start addr: 0x%08x"), |
|
211 reinterpret_cast<TUint32>(iTxDataBuffer) ) ); |
|
212 |
|
213 // for the single Tx buffer the actual buffer memory immediately |
|
214 // follows the Tx frame meta header |
|
215 iTxDataBuffer->KeSetBufferOffset( sizeof( TDataBuffer ) ); |
|
216 |
|
217 iFrameXferBlock = reinterpret_cast<RFrameXferBlock*>( |
|
218 start_of_mem |
|
219 + KRxDataChunkSize |
|
220 + sizeof( TDataBuffer ) |
|
221 + KMgmtSideTxBufferLength |
|
222 + KProtocolStackSideTxDataChunkSize ); |
|
223 |
|
224 TraceDump( INIT_LEVEL, |
|
225 (("WLANLDD: MgmtFrameMemMngr::DoOpenHandle: Engine RFrameXferBlock addr: 0x%08x"), |
|
226 reinterpret_cast<TUint32>(iFrameXferBlock) ) ); |
|
227 |
|
228 // initiliase xfer block |
|
229 iFrameXferBlock->Initialize( KMgmtSideTxBufferLength ); |
|
230 |
|
231 iRxBufAlignmentPadding = RxBufAlignmentPadding(); |
|
232 |
|
233 iParent.SetRxBufAlignmentPadding( iRxBufAlignmentPadding ); |
|
234 } |
|
235 else |
|
236 { |
|
237 // create failed |
|
238 delete iRxFrameMemoryPool; |
|
239 iRxFrameMemoryPool = NULL; |
|
240 // error is returned |
|
241 } |
|
242 } |
|
243 else |
|
244 { |
|
245 // handle creation & open failed. Error is returned |
|
246 |
|
247 TraceDump( INIT_LEVEL | ERROR_LEVEL, |
|
248 (("WLANLDD: MgmtFrameMemMngr::OnInitialiseMemory: Handle create & open error: %d"), |
|
249 r ) ); |
|
250 } |
|
251 } |
|
252 else |
|
253 { |
|
254 // at this point the shared memory chunk should always exist. However, |
|
255 // as it doesn't exist in this case, we return an error |
|
256 |
|
257 TraceDump( INIT_LEVEL | ERROR_LEVEL, |
|
258 ("WLANLDD: MgmtFrameMemMngr::OnInitialiseMemory: Error aSharedMemoryChunk is NULL") ); |
|
259 } |
|
260 |
|
261 return ret; |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 TUint8* MgmtFrameMemMngr::DoGetNextFreeRxBuffer( TUint aLengthinBytes ) |
|
269 { |
|
270 TraceDump( RX_FRAME, |
|
271 ("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer") ); |
|
272 |
|
273 // if there are any Rx buffers which have been handled and |
|
274 // can already be re-used, free them first |
|
275 |
|
276 const TUint32* rxHandledBuffersArray ( NULL ); |
|
277 TUint32 numOfHandled ( 0 ); |
|
278 |
|
279 iFrameXferBlock->KeGetHandledRxBuffers( |
|
280 rxHandledBuffersArray, |
|
281 numOfHandled ); |
|
282 |
|
283 if ( numOfHandled ) |
|
284 { |
|
285 // there are buffers which can be freed, so free them |
|
286 for ( TUint i = 0; i < numOfHandled; ++i ) |
|
287 { |
|
288 // first free the actual Rx frame buffer |
|
289 |
|
290 TraceDump( RX_FRAME, |
|
291 (("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer: free Rx buf at addr: 0x%08x"), |
|
292 reinterpret_cast<TUint32>(reinterpret_cast<TDataBuffer*>( |
|
293 iRxDataChunk |
|
294 + rxHandledBuffersArray[i])->KeGetBufferStart()) ) ); |
|
295 |
|
296 iRxFrameMemoryPool->Free( |
|
297 reinterpret_cast<TDataBuffer*>( |
|
298 iRxDataChunk + rxHandledBuffersArray[i])->KeGetBufferStart() |
|
299 // take into account the alignment padding |
|
300 - iRxBufAlignmentPadding ); |
|
301 |
|
302 // then free the Rx frame meta header |
|
303 |
|
304 TraceDump( RX_FRAME, |
|
305 (("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer: free Rx meta header at addr: 0x%08x"), |
|
306 reinterpret_cast<TUint32>( iRxDataChunk + rxHandledBuffersArray[i])) ); |
|
307 |
|
308 iRxFrameMemoryPool->Free( iRxDataChunk + rxHandledBuffersArray[i] ); |
|
309 } |
|
310 |
|
311 // remove the buffers we freed above from the completed buffers of this |
|
312 // object so that they are not tried to be freed again once the Mgmt |
|
313 // Client issues the next Rx request |
|
314 |
|
315 iCountCompleted -= numOfHandled; |
|
316 assign( |
|
317 iCompletedBuffers + numOfHandled, |
|
318 iCompletedBuffers, |
|
319 iCountCompleted ); |
|
320 } |
|
321 |
|
322 // reserve a new Rx buffer. |
|
323 |
|
324 TUint8* buffer ( NULL ); |
|
325 |
|
326 if ( iRxFrameMemoryPool ) |
|
327 { |
|
328 buffer = reinterpret_cast<TUint8*>(iRxFrameMemoryPool->Alloc( |
|
329 aLengthinBytes |
|
330 + iRxBufAlignmentPadding, |
|
331 EFalse ) ); // no need to zero stamp the buffer content |
|
332 |
|
333 if ( buffer ) |
|
334 { |
|
335 // allocation succeeded |
|
336 |
|
337 // the alignment padding is before the Rx buffer |
|
338 buffer += iRxBufAlignmentPadding; |
|
339 |
|
340 TraceDump(RX_FRAME, |
|
341 (("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer: addr of allocated Rx buf: 0x%08x"), |
|
342 reinterpret_cast<TUint32>(buffer)) ); |
|
343 } |
|
344 else |
|
345 { |
|
346 TraceDump(RX_FRAME | WARNING_LEVEL, |
|
347 ("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer: WARNING: not enough free memory => failed")); |
|
348 } |
|
349 } |
|
350 else |
|
351 { |
|
352 TraceDump(RX_FRAME | WARNING_LEVEL, |
|
353 ("WLANLDD: MgmtFrameMemMngr::DoGetNextFreeRxBuffer: WARNING: no Rx mem pool mgr => failed")); |
|
354 } |
|
355 |
|
356 return buffer; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 TBool MgmtFrameMemMngr::DoEthernetFrameRxComplete( |
|
364 const TDataBuffer*& aBufferStart, |
|
365 TUint32 aNumOfBuffers ) |
|
366 { |
|
367 TraceDump( RX_FRAME, |
|
368 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: aNumOfBuffers: %d"), |
|
369 aNumOfBuffers) ); |
|
370 |
|
371 if ( aNumOfBuffers + iCountTobeCompleted > KMaxToBeCompletedRxBufs ) |
|
372 { |
|
373 // too little space reserved for Rx buffer handles |
|
374 os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
375 } |
|
376 |
|
377 TBool ret( EFalse ); |
|
378 |
|
379 if ( iReadStatus == EPending ) |
|
380 { |
|
381 // read pending |
|
382 if ( !iCountTobeCompleted ) |
|
383 { |
|
384 // no existing Rx buffers to complete in queue |
|
385 // we may complete these ones on the fly |
|
386 |
|
387 // note the completed Rx buffers first so that we can change |
|
388 // their addresses to offsets |
|
389 assign( |
|
390 reinterpret_cast<TUint32*>(&aBufferStart), |
|
391 iCompletedBuffers, |
|
392 aNumOfBuffers ); |
|
393 |
|
394 // update the new Rx buffer start addresses added above to be |
|
395 // offsets from the Rx memory pool beginning |
|
396 for( TUint i = 0; i < aNumOfBuffers; ++i ) |
|
397 { |
|
398 TraceDump( RX_FRAME, |
|
399 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: supplied Rx buf addr: 0x%08x"), |
|
400 iCompletedBuffers[i]) ); |
|
401 |
|
402 iCompletedBuffers[i] |
|
403 -= reinterpret_cast<TUint32>(iRxDataChunk); |
|
404 |
|
405 TraceDump( RX_FRAME, |
|
406 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: Rx buf offset addr: 0x%08x"), |
|
407 iCompletedBuffers[i]) ); |
|
408 } |
|
409 |
|
410 iCountCompleted = aNumOfBuffers; |
|
411 |
|
412 iFrameXferBlock->KeRxComplete( iCompletedBuffers, iCountCompleted); |
|
413 } |
|
414 else |
|
415 { |
|
416 // existing rx buffers to complete in queue. |
|
417 // We must append these at the rear and after that |
|
418 // complete the existing read request |
|
419 assign( |
|
420 reinterpret_cast<TUint32*>(&aBufferStart), |
|
421 iTobeCompletedBuffers + iCountTobeCompleted, |
|
422 aNumOfBuffers ); |
|
423 |
|
424 // update the new Rx buffer start addresses added above to be |
|
425 // offsets from the Rx memory pool beginning |
|
426 for( TUint i = 0; i < aNumOfBuffers; ++i ) |
|
427 { |
|
428 TraceDump( RX_FRAME, |
|
429 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: supplied Rx buf addr: 0x%08x"), |
|
430 iTobeCompletedBuffers[iCountTobeCompleted + i]) ); |
|
431 |
|
432 iTobeCompletedBuffers[iCountTobeCompleted + i] |
|
433 -= reinterpret_cast<TUint32>(iRxDataChunk); |
|
434 |
|
435 TraceDump( RX_FRAME, |
|
436 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: Rx buf offset addr: 0x%08x"), |
|
437 iTobeCompletedBuffers[iCountTobeCompleted + i]) ); |
|
438 } |
|
439 |
|
440 iCountCompleted = iCountTobeCompleted + aNumOfBuffers; |
|
441 |
|
442 iFrameXferBlock->KeRxComplete( |
|
443 iTobeCompletedBuffers, |
|
444 iCountCompleted ); |
|
445 |
|
446 // note the completed Rx buffers |
|
447 assign( iTobeCompletedBuffers, iCompletedBuffers, iCountCompleted ); |
|
448 iCountTobeCompleted = 0; |
|
449 } |
|
450 |
|
451 ret = ETrue; |
|
452 } |
|
453 else |
|
454 { |
|
455 // no read pending |
|
456 // append at the rear |
|
457 assign( |
|
458 reinterpret_cast<TUint32*>(&aBufferStart), |
|
459 iTobeCompletedBuffers + iCountTobeCompleted, |
|
460 aNumOfBuffers ); |
|
461 |
|
462 // update the new Rx buffer start addresses added above to be |
|
463 // offsets from the Rx memory pool beginning |
|
464 for( TUint i = 0; i < aNumOfBuffers; ++i ) |
|
465 { |
|
466 TraceDump( RX_FRAME, |
|
467 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: supplied Rx buf addr: 0x%08x"), |
|
468 iTobeCompletedBuffers[iCountTobeCompleted + i]) ); |
|
469 |
|
470 iTobeCompletedBuffers[iCountTobeCompleted + i] |
|
471 -= reinterpret_cast<TUint32>(iRxDataChunk); |
|
472 |
|
473 TraceDump( RX_FRAME, |
|
474 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: Rx buf offset addr: 0x%08x"), |
|
475 iTobeCompletedBuffers[iCountTobeCompleted + i]) ); |
|
476 } |
|
477 |
|
478 iCountTobeCompleted += aNumOfBuffers; |
|
479 } |
|
480 |
|
481 TraceDump( RX_FRAME, |
|
482 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: end: iCountCompleted: %d"), |
|
483 iCountCompleted) ); |
|
484 |
|
485 TraceDump( RX_FRAME, |
|
486 (("WLANLDD: MgmtFrameMemMngr::DoEthernetFrameRxComplete: end: iCountTobeCompleted: %d"), |
|
487 iCountTobeCompleted) ); |
|
488 |
|
489 return ret; |
|
490 } |
|
491 |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 // --------------------------------------------------------------------------- |
|
495 // |
|
496 TUint32* MgmtFrameMemMngr::DoGetTobeCompletedBuffersStart() |
|
497 { |
|
498 return iTobeCompletedBuffers; |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 TUint32* MgmtFrameMemMngr::DoGetCompletedBuffersStart() |
|
506 { |
|
507 return iCompletedBuffers; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 void MgmtFrameMemMngr::DoFreeRxBuffers() |
|
515 { |
|
516 if ( IsMemInUse() ) |
|
517 { |
|
518 for ( TUint i = 0; i < iCountCompleted; ++i ) |
|
519 { |
|
520 TDataBuffer* metaHdr ( reinterpret_cast<TDataBuffer*>( |
|
521 iRxDataChunk + iCompletedBuffers[i]) ); |
|
522 |
|
523 // first free the actual Rx frame buffer |
|
524 TraceDump( RX_FRAME, |
|
525 (("WLANLDD: MgmtFrameMemMngr::DoFreeRxBuffers: free Rx buf at addr: 0x%08x"), |
|
526 reinterpret_cast<TUint32>(metaHdr->KeGetBufferStart()) ) ); |
|
527 |
|
528 iRxFrameMemoryPool->Free( |
|
529 metaHdr->KeGetBufferStart() |
|
530 // take into account the alignment padding |
|
531 - iRxBufAlignmentPadding ); |
|
532 |
|
533 // free the Rx frame meta header |
|
534 |
|
535 TraceDump( RX_FRAME, |
|
536 (("WLANLDD: MgmtFrameMemMngr::DoFreeRxBuffers: free Rx meta header at addr: 0x%08x"), |
|
537 reinterpret_cast<TUint32>(metaHdr)) ); |
|
538 |
|
539 iRxFrameMemoryPool->Free( metaHdr ); |
|
540 } |
|
541 } |
|
542 else |
|
543 { |
|
544 // the whole Rx memory pool has already been deallocated, so nothing |
|
545 // is done in this case |
|
546 TraceDump( RX_FRAME, |
|
547 ("WLANLDD: MgmtFrameMemMngr::DoFreeRxBuffers: Rx memory pool already deallocated; no action needed") ); |
|
548 } |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 void MgmtFrameMemMngr::DoMarkRxBufFree( TUint8* aBufferToFree ) |
|
556 { |
|
557 TraceDump( RX_FRAME, |
|
558 (("WLANLDD: MgmtFrameMemMngr::DoMarkRxBufFree: free Rx buf at addr: 0x%08x"), |
|
559 reinterpret_cast<TUint32>(aBufferToFree) ) ); |
|
560 |
|
561 if ( IsMemInUse() ) |
|
562 { |
|
563 iRxFrameMemoryPool->Free( |
|
564 aBufferToFree |
|
565 // take into account the alignment padding |
|
566 - iRxBufAlignmentPadding ); |
|
567 } |
|
568 else |
|
569 { |
|
570 // the whole Rx memory pool - including aBufferToFree - has already |
|
571 // been deallocated, so nothing is done in this case |
|
572 TraceDump( RX_FRAME, |
|
573 ("WLANLDD: MgmtFrameMemMngr::DoMarkRxBufFree: Rx memory pool already deallocated; no action needed") ); |
|
574 } |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 TInt MgmtFrameMemMngr::RxBufAlignmentPadding() const |
|
582 { |
|
583 const TInt KMemMgrHdrLen = iRxFrameMemoryPool->HeaderSize(); |
|
584 const TInt KRemainder ( KMemMgrHdrLen % iRxFrameBufAllocationUnit ); |
|
585 TInt padding = KRemainder ? |
|
586 ( iRxFrameBufAllocationUnit - KRemainder ) : KRemainder; |
|
587 |
|
588 TraceDump(INIT_LEVEL, (("WLANLDD: MgmtFrameMemMngr::RxBufAlignmentPadding: %d"), |
|
589 padding)); |
|
590 |
|
591 return padding; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 void MgmtFrameMemMngr::OnReleaseMemory() |
|
599 { |
|
600 TraceDump(INIT_LEVEL, ("WLANLDD: MgmtFrameMemMngr::OnReleaseMemory")); |
|
601 |
|
602 TraceDump(MEMORY, (("WLANLDD: delete WlanChunk: 0x%08x"), |
|
603 reinterpret_cast<TUint32>(iRxFrameMemoryPool))); |
|
604 |
|
605 delete iRxFrameMemoryPool; |
|
606 iRxFrameMemoryPool = NULL; |
|
607 |
|
608 if ( iParent.SharedMemoryChunk() ) |
|
609 { |
|
610 TraceDump(MEMORY, (("WLANLDD: delete DChunk: 0x%08x"), |
|
611 reinterpret_cast<TUint32>(iParent.SharedMemoryChunk()))); |
|
612 |
|
613 // schedule the shared memory chunk for destruction |
|
614 Kern::ChunkClose( iParent.SharedMemoryChunk() ); |
|
615 iParent.SharedMemoryChunk() = NULL; |
|
616 MarkMemFree(); // mark as free |
|
617 } |
|
618 else |
|
619 { |
|
620 // nothing here |
|
621 } |
|
622 } |