00001
00078 #ifndef IXOSBUFFPOOLMGT_H
00079 #define IXOSBUFFPOOLMGT_H
00080
00081
00082
00083
00084
00085 #ifdef __vxworks
00086 #include <netBufLib.h>
00087 #endif
00088
00089
00090
00091
00092
00093 #ifdef __vxworks
00094 #include "IxOsServices.h"
00095 #endif
00096 #include "IxTypes.h"
00097 #include "IxOsBuffMgt.h"
00098 #include "IxOsCacheMMU.h"
00099
00100
00101
00102
00103
00104
00117 #define IX_MBUF_POOL_SIZE_ALIGN(size) \
00118 ((((size) + (IX_XSCALE_CACHE_LINE_SIZE - 1)) / \
00119 IX_XSCALE_CACHE_LINE_SIZE) * \
00120 IX_XSCALE_CACHE_LINE_SIZE)
00121
00122
00141 #define IX_MBUF_POOL_MBUF_AREA_SIZE_ALIGNED(count) \
00142 ixOsBuffPoolMbufAreaSizeGet(count)
00143
00144
00165 #define IX_MBUF_POOL_DATA_AREA_SIZE_ALIGNED(count, size) \
00166 ixOsBuffPoolDataAreaSizeGet((count), (size))
00167
00168
00182 #define IX_MBUF_POOL_MBUF_AREA_ALLOC(count, memAreaSize) \
00183 IX_ACC_DRV_DMA_MALLOC((memAreaSize = \
00184 IX_MBUF_POOL_MBUF_AREA_SIZE_ALIGNED(count)))
00185
00204 #define IX_MBUF_POOL_DATA_AREA_ALLOC(count, size, memAreaSize) \
00205 IX_ACC_DRV_DMA_MALLOC((memAreaSize = \
00206 IX_MBUF_POOL_DATA_AREA_SIZE_ALIGNED(count,size)))
00207
00217 #ifndef __vxworks
00218 # define IX_MBUF_POOL_FREE_COUNT(poolPtr) ((poolPtr)->freeBufsInPool)
00219 #else
00220 # define IX_MBUF_POOL_FREE_COUNT(poolPtr) ix_get_free_mblk_count(poolPtr)
00221
00222
00223
00224
00225
00226 static __inline__ int
00227 ix_get_free_mblk_count(NET_POOL *poolPtr)
00228 {
00229 int i = 0;
00230 IX_MBUF *head = poolPtr->pmBlkHead;
00231 while(head)
00232 {
00233 head = head->mBlkHdr.mNext;
00234 i++;
00235 }
00236 return i;
00237 }
00238
00239 #endif
00240
00241
00248 #define IX_MBUF_MAX_POOLS 32
00249
00255 #define IX_MBUF_POOL_NAME_LEN 64
00256
00257
00258 #ifndef __vxworks
00259
00265 typedef enum
00266 {
00267 IX_MBUF_POOL_TYPE_SYS_ALLOC = 0,
00268 IX_MBUF_POOL_TYPE_USER_ALLOC,
00269 } IxMbufPoolAllocationType;
00270
00271
00276 typedef struct
00277 {
00278 IX_MBUF *nextFreeBuf;
00279 void *mbufMemPtr;
00280 void *dataMemPtr;
00281 int bufDataSize;
00282 int totalBufsInPool;
00283 int freeBufsInPool;
00284 int mbufMemSize;
00285 int dataMemSize;
00286 char name[IX_MBUF_POOL_NAME_LEN + 1];
00287 IxMbufPoolAllocationType poolAllocType;
00288 } IxMbufPool;
00289
00290 typedef IxMbufPool IX_MBUF_POOL;
00291
00292 #else
00293
00300 typedef NET_POOL IX_MBUF_POOL;
00301
00302 #endif
00303
00304
00311 #define IX_MBUF_POOL_INIT(poolPtrPtr, count, size, name) \
00312 ixOsBuffPoolInit((poolPtrPtr), (count), (size), (name))
00313
00320 #define IX_MBUF_POOL_INIT_NO_ALLOC(poolPtrPtr, bufPtr, dataPtr, count, size, name) \
00321 ixOsBuffPoolInitNoAlloc((poolPtrPtr), (bufPtr), (dataPtr), (count), (size), (name))
00322
00329 #define IX_MBUF_POOL_GET(poolPtr, bufPtrPtr) \
00330 ixOsBuffPoolUnchainedBufGet((poolPtr), (bufPtrPtr))
00331
00338 #define IX_MBUF_POOL_PUT(bufPtr) \
00339 ixOsBuffPoolBufFree(bufPtr)
00340
00347 #define IX_MBUF_POOL_PUT_CHAIN(bufPtr) \
00348 ixOsBuffPoolBufChainFree(bufPtr)
00349
00356 #define IX_MBUF_POOL_SHOW(poolPtr) \
00357 ixOsBuffPoolShow(poolPtr)
00358
00365 #define IX_MBUF_POOL_MDATA_RESET(bufPtr) \
00366 ixOsBuffPoolBufDataPtrReset(bufPtr)
00367
00368
00369
00370
00371
00372
00373
00418 IX_STATUS
00419 ixOsBuffPoolInit (IX_MBUF_POOL **poolPtrPtr, int count, int size, char *name);
00420
00421
00434 IX_MBUF_POOL *
00435 ixOsBuffPoolAllocate (void);
00436
00437
00455 UINT32
00456 ixOsBuffPoolDataAreaSizeGet(int count, int size);
00457
00458
00478 IX_MBUF *
00479 ixOsBuffPoolMbufInit (int mbufSizeAligned,
00480 int dataSizeAligned,
00481 IX_MBUF_POOL *poolPtr);
00482
00483
00501 UINT32
00502 ixOsBuffPoolMbufAreaSizeGet(int count);
00503
00565 IX_STATUS
00566 ixOsBuffPoolInitNoAlloc (IX_MBUF_POOL **poolPtrPtr, void *poolBufPtr,
00567 void *poolDataPtr, int count, int size, char *name);
00568
00598 IX_STATUS
00599 ixOsBuffPoolUnchainedBufGet (IX_MBUF_POOL *poolPtr, IX_MBUF **newBufPtrPtr);
00600
00629 IX_MBUF *
00630 ixOsBuffPoolBufFree (IX_MBUF *bufPtr);
00631
00658 void
00659 ixOsBuffPoolBufChainFree (IX_MBUF *bufPtr);
00660
00685 IX_STATUS
00686 ixOsBuffPoolShow (IX_MBUF_POOL *poolPtr);
00687
00688
00727 IX_STATUS
00728 ixOsBuffPoolBufDataPtrReset (IX_MBUF *bufPtr);
00729
00743 IX_STATUS
00744 ixOsBuffPoolUninit(IX_MBUF_POOL *pool);
00745
00746 #endif
00747
00748